Device Generator: devices whose model, OS, browser, user agent, screen and IP address fit together at a date.
More...
|
|
| dvg ()=default |
| | Default constructor — creates an empty generator with no data.
|
| |
|
| dvg (const dvg &)=delete |
| | Not copyable.
|
| |
|
dvg & | operator= (const dvg &)=delete |
| | Not copyable.
|
| |
|
| dvg (dvg &&) noexcept=default |
| | Movable.
|
| |
|
dvg & | operator= (dvg &&) noexcept=default |
| | Movable.
|
| |
|
| ~dvg ()=default |
| | Destructor.
|
| |
| device | get_device (const device_request &request) |
| | Generate a random device. Use device_request{} for the defaults.
|
| |
| device | get_device (const device_request &request, std::uint64_t call_seed) const |
| | Generate a deterministic device.
|
| |
| std::vector< device > | get_device_batch (const device_request &request, const core::batch_options &options) |
| | Generate a batch of devices from a seed drawn like get_device() draws its own.
|
| |
| std::vector< device > | get_device_batch (const device_request &request, const core::batch_options &options, std::uint64_t batch_seed) const |
| | Generate a batch of devices, deterministically.
|
| |
| template<typename Sink > |
| void | for_each_device (const device_request &request, const core::batch_options &options, std::uint64_t batch_seed, Sink &&sink) const |
| | Stream a batch of devices to a sink without holding the whole batch.
|
| |
| template<typename Sink > |
| void | for_each_device (const device_request &request, const core::batch_options &options, Sink &&sink) |
| | Stream a batch of devices with a batch seed drawn like get_device() draws its own.
|
| |
| std::vector< std::string > | countries () const |
| | The countries a request can name: those with a row in countries.tsv, sorted.
|
| |
| std::vector< std::string > | platforms () const |
| | The platform keys a request can name, in table order.
|
| |
| std::size_t | country_count () const |
| | The number of countries loaded.
|
| |
| std::size_t | model_count () const |
| | The number of device models loaded.
|
| |
| bool | has_data () const |
| | Check whether the data needed to generate is loaded.
|
| |
| void | load (const std::filesystem::path &dir) |
| | Load data from a resource directory, replacing all data and layers loaded before.
|
| |
| bool | load (dataset tier) |
| | Load a dataset tier, replacing all data and layers loaded before.
|
| |
| void | extend (const std::filesystem::path &path, core::layer_mode mode=core::layer_mode::override) |
| | Add data layers from a directory or a file.
|
| |
| const core::layer_info & | extend (device_table which, core::tsv_document doc, core::layer_mode mode=core::layer_mode::override) |
| | Add a data layer to one table.
|
| |
| const core::layer_info & | extend_from_string (device_table which, std::string_view text, std::string source, core::layer_mode mode=core::layer_mode::override) |
| | Add a data layer to one table from TSV text (for example from a WebAssembly host).
|
| |
| const std::vector< core::layer_info > & | layers (device_table which) const |
| | The layers in effect for one table, in order.
|
| |
| std::uint64_t | data_hash () const |
| | Hash of the loaded data, recorded in each result's signature().
|
| |
Device Generator: devices whose model, OS, browser, user agent, screen and IP address fit together at a date.
A call draws, from streams split from the call seed: the country ("country"), the platform ("platform"), the maker and model ("model"), the OS version ("os-version"), the browser ("browser") and its version ("browser-version"), the screen ("screen"), the IP family ("ip-version") and the address ("ip"). Fixing one in the request leaves the others' draws unchanged. Output is identical on every compiler and platform (dasmig-core).
Can be used as a singleton via instance() or constructed independently.
- Thread safety
- Each instance is independent. Concurrent calls to get_device(request) on the same instance require external synchronisation; the seeded overload is const and safe to call concurrently.
Definition at line 308 of file devicegen.hpp.
| std::vector< device > dasmig::dvg::get_device_batch |
( |
const device_request & |
request, |
|
|
const core::batch_options & |
options, |
|
|
std::uint64_t |
batch_seed |
|
) |
| const |
|
inline |
Generate a batch of devices, deterministically.
Item i is exactly get_device(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 device, for example keyed by the IP). |
| 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 434 of file devicegen.hpp.
| bool dasmig::dvg::load |
( |
dataset |
tier | ) |
|
|
inline |
Load a dataset tier, replacing all data and layers loaded before.
Uses the compiled-in copy when the library is built with DASMIG_DEVICE_EMBED, otherwise searches resources/, ../resources, device-generator/resources and ../device-generator/resources.
- Parameters
-
- Returns
- False when the tier was not found.
- Exceptions
-
| core::tsv_error | If a file is malformed. |
Definition at line 544 of file devicegen.hpp.