|
Entity Generator 1.1.0
Composable, deterministic entity generation for C++23
|
Abstract base for entity components. More...
#include <entitygen.hpp>
Public Member Functions | |
| virtual | ~component ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
| virtual std::wstring | key () const =0 |
Unique key identifying this component (e.g. "name", "age"). | |
| virtual std::any | generate (const generation_context &ctx) const =0 |
| Generate a random value for this component. | |
| virtual std::wstring | to_string (const std::any &value) const =0 |
| Convert a generated value to a displayable string. | |
| virtual double | weight () const |
| Inclusion weight for this component (0.0 to 1.0). | |
| virtual bool | validate (const std::any &value) const |
| Validate a generated value. | |
| virtual bool | should_generate (const generation_context &ctx) const |
| Decide whether this component should be generated. | |
Static Protected Member Functions | |
| static std::wstring | default_to_string (const std::any &value) |
| Default conversion covering common standard types. | |
Abstract base for entity components.
Implement this interface to define custom components that the entity generator can produce. Each component has a unique key, generates typed random values, and converts them to display strings.
Definition at line 87 of file entitygen.hpp.
|
inlinestaticprotected |
Default conversion covering common standard types.
Handles std::wstring, int, double, float, long, and bool. Returns "[?]" for unrecognized types.
| value | The value to convert. |
Definition at line 147 of file entitygen.hpp.
|
pure virtual |
Generate a random value for this component.
| ctx | Context providing access to previously generated values and a seeded random engine. |
std::any. Implemented in dasmig::constant_component< T, Formatter >, dasmig::choice_component< T, Formatter >, dasmig::range_component< T, Formatter >, dasmig::callback_component< T, GenFn, Formatter >, and dasmig::weighted_choice_component< T, Formatter >.
|
pure virtual |
Unique key identifying this component (e.g. "name", "age").
Implemented in dasmig::constant_component< T, Formatter >, dasmig::choice_component< T, Formatter >, dasmig::range_component< T, Formatter >, dasmig::callback_component< T, GenFn, Formatter >, and dasmig::weighted_choice_component< T, Formatter >.
|
inlinevirtual |
Decide whether this component should be generated.
Unlike weight() (probabilistic), this is logic-driven. Return false to skip generation entirely based on the current context.
| ctx | Context with previously generated component values. |
true to generate, false to skip. Definition at line 134 of file entitygen.hpp.
|
pure virtual |
Convert a generated value to a displayable string.
| value | The value previously returned by generate(). |
Implemented in dasmig::constant_component< T, Formatter >, dasmig::choice_component< T, Formatter >, dasmig::range_component< T, Formatter >, dasmig::callback_component< T, GenFn, Formatter >, and dasmig::weighted_choice_component< T, Formatter >.
|
inlinevirtual |
Validate a generated value.
| value | The value to validate. |
true to accept, false to retry generation. Definition at line 123 of file entitygen.hpp.
|
inlinevirtual |
Inclusion weight for this component (0.0 to 1.0).
A value of 1.0 means always included; 0.5 means included roughly half the time. The generator may override this per-component at registration time via eg::add(comp, weight) or eg::weight().
Definition at line 117 of file entitygen.hpp.