|
DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
|
pybind11-style configuration registration with macro-based field declaration and namespace-scoped tag kwargs. More...
Go to the source code of this file.
Namespaces | |
| namespace | DNDS |
| the host side operators are provided as implemented | |
| namespace | DNDS::detail |
| namespace | DNDS::Config |
| Namespace for config field tag kwargs. | |
Macros | |
| #define | DNDS_FIELD(name_, desc_, ...) config.field(&T::name_, #name_, desc_, ##__VA_ARGS__) |
| Register a field inside a DNDS_DECLARE_CONFIG body. | |
| #define | DNDS_DECLARE_CONFIG(Type_) |
| Open a config section registration body. | |
Functions | |
| std::string | DNDS::schemaTypeString (ConfigTypeTag tag) |
| RangeTag | DNDS::Config::range (double min) |
| Create a minimum-only range constraint. | |
| RangeTag | DNDS::Config::range (double min, double max) |
| Create a min+max range constraint. | |
| InfoTag | DNDS::Config::info (std::string key, std::string value) |
| Create an auxiliary info tag. | |
| EnumValuesTag | DNDS::Config::enum_values (std::vector< std::string > vals) |
| Create an enum allowed-values tag. | |
| void | DNDS::detail::applyTag (FieldMeta &meta, const Config::RangeTag &tag) |
| void | DNDS::detail::applyTag (FieldMeta &meta, const Config::InfoTag &tag) |
| void | DNDS::detail::applyTag (FieldMeta &meta, const Config::EnumValuesTag &tag) |
| void | DNDS::detail::applyTags (FieldMeta &) |
| template<typename Tag , typename... Rest> | |
| void | DNDS::detail::applyTags (FieldMeta &meta, Tag &&tag, Rest &&...rest) |
| template<typename T , typename V > | |
| std::function< nlohmann::ordered_json()> | DNDS::detail::makeSchemaEntry (V T::*member, const char *desc, const FieldMeta &meta) |
| Build the schemaEntry closure from a fully-tagged FieldMeta. | |
| template<typename T , typename V > | |
| std::function< void(const nlohmann::ordered_json &, const char *)> | DNDS::detail::makeRangeChecker (const FieldMeta &meta) |
| Build a runtime range-check closure. | |
pybind11-style configuration registration with macro-based field declaration and namespace-scoped tag kwargs.
Config sections are plain structs. Metadata is registered in a static method opened by the DNDS_DECLARE_CONFIG(Type) macro. Inside that body the user calls DNDS_FIELD(member, "description", tags...) which is a macro that auto-stringifies the member name — no name duplication.
DNDS_FIELD(member, "description") in the DNDS_DECLARE_CONFIG body.Tags are passed as extra arguments to DNDS_FIELD:
| Tag | Purpose | Example |
|---|---|---|
DNDS::Config::range(min) | Min constraint (schema + runtime check) | DNDS::Config::range(0) |
DNDS::Config::range(min,max) | Min+max constraint | DNDS::Config::range(0.0, 1.0) |
DNDS::Config::info(k,v) | Aux info ("x-<key>" in schema) | DNDS::Config::info("unit","Pa") |
DNDS::Config::enum_values(v) | Allowed string values for enum fields | DNDS::Config::enum_values({"Roe","HLLC"}) |
When a field has a range() tag, readFromJson() checks the parsed value against the min/max bounds and throws std::runtime_error with a clear message on violation. This catches bad config values at load time.
Use explicit config.* calls (not the DNDS_FIELD macro) for these:
The struct has no base class, no virtual methods, no instance-level data introduced by the macro. DNDS_DECLARE_CONFIG only generates static methods and friend functions.
Definition in file ConfigParam.hpp.
| #define DNDS_DECLARE_CONFIG | ( | Type_ | ) |
Open a config section registration body.
Expands to:
using T = Type (so DNDS_FIELD can reference &T::member)._dnds_ensure_registered() with one-time init guard.to_json / from_json calling ensureRegistered first.schema(), validate(), validateWithContext(), validateKeys().static void _dnds_do_register(ConfigSectionBuilder<T>& config) — the user provides the { ... } body after the macro.Definition at line 662 of file ConfigParam.hpp.
| #define DNDS_FIELD | ( | name_, | |
| desc_, | |||
| ... | |||
| ) | config.field(&T::name_, #name_, desc_, ##__VA_ARGS__) |
Register a field inside a DNDS_DECLARE_CONFIG body.
Auto-stringifies the member name so you never write it twice. The JSON key equals the C++ member name.
| name_ | Member name (unquoted). |
| desc_ | Description string literal. |
| ... | Zero or more DNDS::Config tag objects. |
Definition at line 633 of file ConfigParam.hpp.