Entity Generator 4.2.0
Composable, deterministic entity generation for C++23
Loading...
Searching...
No Matches
entitygen.hpp File Reference

Entity generator library — composable, deterministic entity generation for C++23. More...

#include "core.hpp"
#include <algorithm>
#include <any>
#include <bit>
#include <cmath>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <functional>
#include <future>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <ostream>
#include <ranges>
#include <set>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <variant>
#include <vector>

Go to the source code of this file.

Classes

class  dasmig::json_value
 A component value as JSON: null, a boolean, an integer, a number, a (UTF-8) string, an array or an object. More...
 
class  dasmig::generation_context
 Context passed to components during generation. More...
 
class  dasmig::component
 Abstract base for entity components. More...
 
struct  dasmig::use_default_formatter
 Tag type indicating that generic components should use default_to_string(). More...
 
class  dasmig::constant_component< T, Formatter >
 Component that always returns a fixed value. More...
 
class  dasmig::choice_component< T, Formatter >
 Component that picks uniformly at random from a list of values. More...
 
class  dasmig::range_component< T, Formatter >
 Component that generates a uniform random value: integers in [lo, hi], floating-point values in [lo, hi). More...
 
class  dasmig::callback_component< T, GenFn, Formatter >
 Component that wraps a callable for one-off or computed values. More...
 
class  dasmig::field_component< T >
 A component built from a callable, with every optional hook set by a chained call; see field(). More...
 
class  dasmig::weighted_choice_component< T, Formatter >
 Component that picks from a list of values using per-option weights. More...
 
struct  dasmig::weighted_choice_component< T, Formatter >::option
 A value–weight pair for weighted selection. More...
 
class  dasmig::entity
 A generated entity holding component values in registration order. More...
 
class  dasmig::generation_observer
 Observer interface for hooking into generation lifecycle events. More...
 
struct  dasmig::entity_request
 Per-call entity generation and selection options. More...
 
class  dasmig::eg
 The entity generator — produces entities with configurable components. More...
 

Typedefs

using dasmig::input_value = std::variant< bool, std::int64_t, double, std::string >
 A per-call input value: a boolean, an integer, a number or a string.
 
using dasmig::input_map = std::map< std::string, input_value, std::less<> >
 Per-call inputs by name (ordered, so their hash is reproducible).
 

Functions

Generic Components

Reusable component templates for common patterns.

template<typename GenFn , typename Formatter = use_default_formatter>
 dasmig::callback_component (std::wstring, GenFn, Formatter={}) -> callback_component< std::invoke_result_t< GenFn, const generation_context & >, GenFn, Formatter >
 Deduction guide for callback_component.
 
template<typename Fn >
auto dasmig::field (std::wstring key, Fn fn)
 Build a field from a callable; T is what the callable returns.
 

Detailed Description

Entity generator library — composable, deterministic entity generation for C++23.

Author
Diego Dasso Migotto (diegomigotto at hotmail dot com)
See also
See doc/usage.md for the narrative tutorial.

Definition in file entitygen.hpp.

Typedef Documentation

◆ input_map

using dasmig::input_map = typedef std::map<std::string, input_value, std::less<> >

Per-call inputs by name (ordered, so their hash is reproducible).

Definition at line 132 of file entitygen.hpp.

◆ input_value

using dasmig::input_value = typedef std::variant<bool, std::int64_t, double, std::string>

A per-call input value: a boolean, an integer, a number or a string.

Scalars only, so the inputs can be part of the replay signature.

See also
entity_request::inputs, generation_context::input()

Definition at line 129 of file entitygen.hpp.

Function Documentation

◆ callback_component()

template<typename GenFn , typename Formatter = use_default_formatter>
dasmig::callback_component ( std::wstring  ,
GenFn  ,
Formatter  = {} 
) -> callback_component< std::invoke_result_t< GenFn, const generation_context & >, GenFn, Formatter >

Deduction guide for callback_component.

Deduces T from the return type of GenFn so users don't need to spell out the lambda type explicitly.

◆ field()

template<typename Fn >
auto dasmig::field ( std::wstring  key,
Fn  fn 
)

Build a field from a callable; T is what the callable returns.

Parameters
keyUnique component key.
fnCallable taking const generation_context&.
Returns
The field, to be configured with chained calls and added with eg::add().
See also
field_component

Definition at line 810 of file entitygen.hpp.