A generated entity holding component values in registration order.
More...
#include <entitygen.hpp>
|
| template<typename T > |
| T | get (const std::wstring &component_key) const |
| | Typed retrieval of a component value by key.
|
| |
| const std::any & | get_any (const std::wstring &component_key) const |
| | Type-erased retrieval of a component value by key.
|
| |
| bool | has (const std::wstring &component_key) const |
| | Check if a component value exists by key.
|
| |
| std::uint64_t | seed (const std::wstring &component_key) const |
| | Retrieve the random seed used to generate a specific component.
|
| |
| std::uint64_t | seed () const |
| | Retrieve the random seed used to generate this entity.
|
| |
| std::vector< std::wstring > | keys () const |
| | Get all component keys present in this entity, in generation order.
|
| |
| std::map< std::wstring, std::wstring > | to_map () const |
| | Return component values as a map of key to display string.
|
| |
| std::size_t | size () const |
| | Number of component values in this entity.
|
| |
| bool | empty () const |
| | Check if the entity has no component values.
|
| |
| std::wstring | to_string () const |
| | Convert all component values to a single formatted string.
|
| |
|
| class | eg |
| |
| std::wostream & | operator<< (std::wostream &wos, const entity &e) |
| | Stream all component values in generation order.
|
| |
A generated entity holding component values in registration order.
Entities are produced by eg::generate() and provide typed access to component values, seed signatures for replay, and serialization.
- See also
- eg::generate()
Definition at line 431 of file entitygen.hpp.
◆ empty()
| bool dasmig::entity::empty |
( |
| ) |
const |
|
inline |
Check if the entity has no component values.
Definition at line 516 of file entitygen.hpp.
◆ get()
template<typename T >
| T dasmig::entity::get |
( |
const std::wstring & |
component_key | ) |
const |
|
inline |
Typed retrieval of a component value by key.
- Template Parameters
-
| T | The expected type of the stored value. |
- Parameters
-
| component_key | The component key to retrieve. |
- Returns
- The value cast to
T.
- Exceptions
-
| std::out_of_range | If the key is not present. |
| std::bad_any_cast | If T does not match the stored type. |
Definition at line 441 of file entitygen.hpp.
◆ get_any()
| const std::any & dasmig::entity::get_any |
( |
const std::wstring & |
component_key | ) |
const |
|
inline |
Type-erased retrieval of a component value by key.
- Parameters
-
| component_key | The component key to retrieve. |
- Returns
- A const reference to the stored
std::any.
- Exceptions
-
| std::out_of_range | If the key is not present. |
Definition at line 450 of file entitygen.hpp.
◆ has()
| bool dasmig::entity::has |
( |
const std::wstring & |
component_key | ) |
const |
|
inline |
Check if a component value exists by key.
- Parameters
-
| component_key | The component key to look up. |
- Returns
true if the entity contains a value for the key.
Definition at line 458 of file entitygen.hpp.
◆ keys()
| std::vector< std::wstring > dasmig::entity::keys |
( |
| ) |
const |
|
inline |
Get all component keys present in this entity, in generation order.
- Returns
- A vector of component keys.
Definition at line 492 of file entitygen.hpp.
◆ seed() [1/2]
| std::uint64_t dasmig::entity::seed |
( |
| ) |
const |
|
inline |
Retrieve the random seed used to generate this entity.
This seed can reproduce all component seeds and thus the entire entity.
- Returns
- The entity-level seed.
Definition at line 485 of file entitygen.hpp.
◆ seed() [2/2]
| std::uint64_t dasmig::entity::seed |
( |
const std::wstring & |
component_key | ) |
const |
|
inline |
Retrieve the random seed used to generate a specific component.
- Parameters
-
| component_key | The component key. |
- Returns
- The per-component seed for replay.
- Exceptions
-
| std::out_of_range | If the key is not present. |
Definition at line 469 of file entitygen.hpp.
◆ size()
| std::size_t dasmig::entity::size |
( |
| ) |
const |
|
inline |
Number of component values in this entity.
Definition at line 513 of file entitygen.hpp.
◆ to_map()
| std::map< std::wstring, std::wstring > dasmig::entity::to_map |
( |
| ) |
const |
|
inline |
Return component values as a map of key to display string.
- Returns
- An ordered map of key → formatted value.
Definition at line 502 of file entitygen.hpp.
◆ to_string()
| std::wstring dasmig::entity::to_string |
( |
| ) |
const |
|
inline |
Convert all component values to a single formatted string.
Each entry is rendered as "key: display" separated by two spaces.
- Returns
- The formatted string, or empty if the entity is empty.
Definition at line 522 of file entitygen.hpp.
◆ eg
◆ operator<<
| std::wostream & operator<< |
( |
std::wostream & |
wos, |
|
|
const entity & |
e |
|
) |
| |
|
friend |
Stream all component values in generation order.
Definition at line 536 of file entitygen.hpp.
The documentation for this class was generated from the following file: