|
| | psg () |
| | Draws from the singletons of the eight libraries.
|
| |
| | psg (sources from) |
| | Draws from the given library instances (which must outlive this generator).
|
| |
|
| psg (const psg &)=delete |
| | Not copyable.
|
| |
|
psg & | operator= (const psg &)=delete |
| | Not copyable.
|
| |
|
| psg (psg &&) noexcept=default |
| | Movable.
|
| |
|
psg & | operator= (psg &&) noexcept=default |
| | Movable.
|
| |
|
| ~psg ()=default |
| | Destructor.
|
| |
| bool | has_data () const |
| | Check whether every library has data.
|
| |
| bool | load (dataset tier) |
| | Load a tier into every library.
|
| |
| std::uint64_t | data_hash () const |
| | Hash of the data of all eight libraries.
|
| |
| persona | get_persona (const persona_request &request) |
| | Generate a persona with a new random seed.
|
| |
| persona | get_persona (const persona_request &request, std::uint64_t call_seed) const |
| | Generate the persona for a call seed. Deterministic; does not touch the generator's engine.
|
| |
| std::vector< persona > | get_persona_batch (const persona_request &request, const core::batch_options &options) |
| | Generate a batch of persona results from a seed drawn like get_persona() draws its own.
|
| |
| std::vector< persona > | get_persona_batch (const persona_request &request, const core::batch_options &options, std::uint64_t batch_seed) const |
| | Generate a batch of persona results, deterministically.
|
| |
| template<typename Sink > |
| void | for_each_persona (const persona_request &request, const core::batch_options &options, std::uint64_t batch_seed, Sink &&sink) const |
| | Stream a batch of persona results to a sink without holding the whole batch.
|
| |
| template<typename Sink > |
| void | for_each_persona (const persona_request &request, const core::batch_options &options, Sink &&sink) |
| | Stream a batch of persona results with a batch seed drawn like get_persona() draws its own.
|
| |
persona-generator: runs the persona pipeline.
The pipeline draws a country, then a city, a birth, a body, a name, interests, an occupation and a personality, each conditioned on what was drawn before (the order and dependencies are declared as entity-generator fields, so they are checked, not assumed). Each library gets its own call seed, split from the persona's seed by the field's key, so the persona's seed replays all of it, and forcing one choice (a country, a sex) does not shift the draws of the others. Output is identical on every compiler and platform (dasmig-core).
The generator holds no data of its own: it calls the instances of the eight libraries it was built on (the singletons by default), so their data, their layers and their lite or full tiers are the persona's.
- Thread safety
- get_persona(request, seed) is const and only calls const members of the libraries, so it may run concurrently. get_persona(request) draws from the generator's engine and needs external synchronisation on the same instance.
Definition at line 224 of file personagen.hpp.
| std::vector< persona > dasmig::psg::get_persona_batch |
( |
const persona_request & |
request, |
|
|
const core::batch_options & |
options, |
|
|
std::uint64_t |
batch_seed |
|
) |
| const |
|
inline |
Generate a batch of persona results, deterministically.
Item i is exactly get_persona(request, core::item_seed(batch_seed, options.first + i)), so an item replays on its own, a range can be generated directly, two batches that follow each other equal one, and the output does not depend on options.threads.
- Parameters
-
| request | What every item is generated from. |
| options | Count, first index, threads and uniqueness (see core::unique_rule; the rule must be made for persona). |
| batch_seed | Seed of the whole batch. |
- Returns
- The results, in index order.
- Exceptions
-
| std::invalid_argument | If the request or options are invalid. |
| std::runtime_error | If no data has been loaded, or a unique batch runs out of attempts. |
Definition at line 433 of file personagen.hpp.