Flow123d
release_3.0.0-968-gc359144
|
We assume that the input data of the program can be represented by a tree. The leave nodes of the tree contain actual data and has one of the 'scalar' types represented by the classes in Input::Type namespace : Bool, Integer, Double, String, and FileName. The branching nodes of the input tree can be either of type Array or type Record (or Abstract). Classes derived from Input::Type::TypeBase
only describes structure of the input tree which is independent of actual format of the input data. All nodes of tree allows definition of input attributes, which are optional for every node. Base attributes are defined in Input::Type::Attributes, special attributes of Flow123D in FlowAttributes. These structures contain common attributes, user can define other else.
Instances of the classes from the Input::Type namespace form a declaration-tree that is later used by a reader of the particular file format (currently we support YAML and JSON through the Input::ReaderToStorage reader) to interpret the input data, check its structure, possibly use default values and put the raw data into an intermediate storage-tree formed be Input:Storage classes.
Finally, the data are accessible through accessors Input::Record, Input::Array, and Input::AbstractRecord. These accessors holds pointers into declaration tree as well as into the data storage tree and provides unified access to the data.
Furthermore, the declaration-tree can output itself provided a basic documentation of the input data structure, that is consistent with the actual state.
Here is simple scheme of information exchange between classes:
In order to use input interface you have to create declaration-tree, namely Selection, Record, and Abstract types has to be declared by specification of its keys. We suggest to have a static method that returns Input::Type::Record for ever class which is initialized from input interface. Example of usage follows:
The accessor for the root Input::Record is provided by the reader class ( ReaderToStorage.get_root_interface<>() )