TUV-x
|
Model configuration data. More...
Public Member Functions | |
procedure | empty |
Empties the configuration. | |
procedure | from_file => construct_from_file |
Loads a configuration with data from a file. | |
procedure | to_file |
Writes a configuration to a file. | |
procedure | number_of_children |
Returns the number of child objects. | |
procedure | get_iterator |
Gets an iterator for the configuration data. | |
procedure | key |
Gets the key name for a key-value pair. | |
procedure | merge_in |
Merges another config_t object into the config_t object. | |
procedure | validate |
Validates the format of the configuration file. | |
procedure | print => do_print |
Print the raw contents of the configuration. | |
procedure | pack_size |
Returns the number of bytes required to pack the object onto a buffer. | |
procedure | mpi_pack |
Packs the object onto a character buffer. | |
procedure | mpi_unpack |
Unpacks an object from a character buffer. | |
final | finalize |
Cleans up memory. | |
finalize_1d_array | |
Private Member Functions | |
procedure, private | find_by_prefix |
Find a JSON key by prefix. | |
Private Attributes | |
type(c_ptr) | node_ = c_null_ptr |
Pointer to YAML node. | |
Model configuration data.
Instances of type config_t
can be used to access model configuration data in json
format. If there is a need to use model configuration in another format (e.g., XML) in the future, an abstract config_t
type could be set up, that this type and an XML-based type could extend. The rest of the model code would be unaffected.
It is assumed that most configuration datasets will be small enough that returned subsets of configuration data can just be a copy of the original data (instead of using a pointer to the start of the subset in the original dataset, or something like this). This avoids ownership problems with cleaning up the memory after a config_t
object goes out of scope.
Only use config_t
objects during initialization. They are not designed for efficiency.
IMPORTANT: The order of elements is arbitrary. No user of a config_t
object can assume anything by the order of key-value pairs in the data. This dataset:
... is the same as:
There is no guarantee that an iterator over the elements of a config_t object will return them in the same order they exist in the original file or string.
Example of a config_t object generated from a file:
data/config_example.json
:
Output: