|
DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
|
Per-type singleton registry of config field metadata and validation checks. More...
#include <ConfigRegistry.hpp>
Static Public Member Functions | |
| static bool | registerField (FieldMeta meta) |
| Register a single field's metadata. | |
| static bool | registerCheck (CrossFieldCheck check) |
| Register a cross-field validation check (no runtime context needed). | |
| static bool | registerContextualCheck (ContextualCheck check) |
| Register a cross-field validation check that needs runtime context. | |
| static void | registerPostReadHook (std::function< void(T &)> hook) |
| Register a post-read hook called after all fields are deserialized. Useful for recomputing derived quantities (e.g. CpGas from gamma and Rgas). | |
| static const std::vector< FieldMeta > & | fields () |
| All registered field descriptors, in declaration order. | |
| static const std::vector< CrossFieldCheck > & | checks () |
| All registered context-free checks. | |
| static const std::vector< ContextualCheck > & | contextualChecks () |
| All registered context-aware checks. | |
| static void | readFromJson (const nlohmann::ordered_json &j, T &obj) |
| Deserialize all registered fields from a JSON object into a struct. | |
| static void | writeToJson (nlohmann::ordered_json &j, const T &obj) |
| Serialize all registered fields from a struct into a JSON object. | |
| static nlohmann::ordered_json | emitSchema (const std::string §ionDescription="") |
| Emit a JSON Schema (draft-07) object describing all registered fields. | |
| static std::vector< CheckResult > | validate (const T &obj) |
| Run all context-free cross-field checks on a struct instance. | |
| static std::vector< CheckResult > | validateWithContext (const T &obj, const ConfigContext &ctx) |
| Run all checks (both context-free and context-aware) on a struct instance. | |
| static void | validateKeys (const nlohmann::ordered_json &userJson) |
| Check that every key in a user-supplied JSON object corresponds to a registered field. Throws on the first unknown key found. | |
Per-type singleton registry of config field metadata and validation checks.
| T | The config section struct type (e.g. LimiterControl, VRSettings). |
Registration happens lazily on first use of to_json, from_json, or schema() (via _dnds_ensure_registered()). After the one-time init completes, the registry is read-only. All const accessors and operations (readFromJson, writeToJson, emitSchema, validate) are safe to call concurrently from multiple threads.
Fields are stored in the order the DNDS_FIELD / config.field() calls execute inside the _dnds_do_register() body, which matches the source order. This gives deterministic JSON key ordering and schema property ordering.
Definition at line 229 of file ConfigRegistry.hpp.
|
inlinestatic |
All registered context-free checks.
Definition at line 306 of file ConfigRegistry.hpp.
|
inlinestatic |
All registered context-aware checks.
Definition at line 309 of file ConfigRegistry.hpp.
|
inlinestatic |
Emit a JSON Schema (draft-07) object describing all registered fields.
The output looks like:
| sectionDescription | Optional description for the section itself. |
Definition at line 379 of file ConfigRegistry.hpp.
|
inlinestatic |
All registered field descriptors, in declaration order.
Definition at line 303 of file ConfigRegistry.hpp.
|
inlinestatic |
Deserialize all registered fields from a JSON object into a struct.
For each field, reads j[field.name] and writes it into the corresponding member of obj. If the field has a range constraint (from DNDS::Config::range()), the parsed numeric value is checked against min/max bounds before assignment.
| j | Source JSON object. |
| obj | Destination struct instance. |
| std::runtime_error | on missing keys, type mismatch, or range constraint violation. |
Definition at line 326 of file ConfigRegistry.hpp.
|
inlinestatic |
Register a cross-field validation check (no runtime context needed).
| check | Lambda taking const void* and returning CheckResult. |
Definition at line 276 of file ConfigRegistry.hpp.
|
inlinestatic |
Register a cross-field validation check that needs runtime context.
| check | Lambda taking const void* and const ConfigContext&, returning CheckResult. |
Definition at line 285 of file ConfigRegistry.hpp.
|
inlinestatic |
Register a single field's metadata.
| meta | The field descriptor to store. |
Definition at line 267 of file ConfigRegistry.hpp.
|
inlinestatic |
Register a post-read hook called after all fields are deserialized. Useful for recomputing derived quantities (e.g. CpGas from gamma and Rgas).
Definition at line 293 of file ConfigRegistry.hpp.
|
inlinestatic |
Run all context-free cross-field checks on a struct instance.
| obj | The struct to validate. |
Definition at line 399 of file ConfigRegistry.hpp.
|
inlinestatic |
Check that every key in a user-supplied JSON object corresponds to a registered field. Throws on the first unknown key found.
This is the equivalent of EulerP's valid_patch_keys(), but generated automatically from the registry instead of requiring a hand-written default config to compare against.
| userJson | The user-supplied JSON object to validate. |
| std::runtime_error | with the offending key path. |
Definition at line 441 of file ConfigRegistry.hpp.
|
inlinestatic |
Run all checks (both context-free and context-aware) on a struct instance.
| obj | The struct to validate. |
| ctx | Runtime context (nVars, dim, model, etc.). |
Definition at line 416 of file ConfigRegistry.hpp.
|
inlinestatic |
Serialize all registered fields from a struct into a JSON object.
Fields are written in registration order, producing deterministic key ordering in the output JSON.
| j | Destination JSON object (existing keys are overwritten). |
| obj | Source struct instance. |
Definition at line 352 of file ConfigRegistry.hpp.