Parameters system¶
The Parameters class manages all runtime configuration for the eOn client.
This page documents the design decisions behind its decomposition.
Architecture¶
The system has three layers:
Option-group structs (
Parameters.h): 33 structs with C++20 NSDMI defaults. Each struct is independently constructable without parsing.INI parser (
ParametersINI.cpp): readsconfig.inivia inih and populates option groups.JSON serializer (
ParametersJSON.cpp): providesto_json()/from_json()for library usage, RPC transport, and debugging.
A validate_and_link() function resolves cross-group dependencies (time unit
conversions, default inheritance) after loading from any source.
NSDMI defaults¶
All ~290 configuration fields have default values as Non-Static Data Member Initializers directly on the struct members:
struct main_options_t {
JobType job{JobType::Process_Search};
long randomSeed{-1};
double temperature{300.0};
// ...
} main_options;
The constructor calls only validate_and_link() to resolve computed fields
(time unit conversions). This means a default-constructed Parameters object
is immediately usable.
Cross-group dependencies¶
Some fields depend on values from other groups. These are resolved in
validate_and_link() after all groups have their raw values:
Dependent field |
Source |
|---|---|
|
|
|
|
|
|
|
|
All |
|
Narrow parameter passing¶
Core classes receive only the option groups they need via config structs:
Class |
Config struct |
Fields |
|---|---|---|
|
Direct members |
|
|
|
|
|
|
12 fields from 5 groups |
|
|
No Parameters dependency |
Deprecated backward-compatibility constructors are retained for callers that
still pass the full Parameters object.
JSON serialization¶
ParametersJSON.cpp provides round-trip JSON serialization using
nlohmann/json. This enables:
Library usage: configure eOn programmatically without INI files
RPC transport: send config as JSON text via capnp serve mode
Debugging: dump current config to human-readable JSON
Parameters params;
params.load_json(R"({"Main": {"job": "Nudged_Elastic_Band", "temperature": 500}})");
std::string json = params.to_json(); // pretty-printed JSON
History¶
The v3c branch (2024) attempted to switch from INI to TOML and restructure all parameters simultaneously. It was abandoned because it changed too many axes at once. The current approach is incremental: extract defaults (Phase 1), narrow passing (Phase 2), add JSON (Phase 3). Each step is independently mergeable.