Flow123d
JS_before_hm-1804-gf2ad740aa
|
The purpose of the classes in the Input::Type
namespace is to declare structure of the input data. There are few basic data types (scalar types), further there is Array type to declare sequences of data of common type. Similarly to C++ struct type, we provide type Record which is set of data of possibly different types indexed by string keys. Finally, we introduce kind of polymorphism through AbstractRecord
type that mimics abstract classes.
More...
Classes | |
class | Input::Type::Abstract |
Class for declaration of polymorphic Record. More... | |
class | Input::Type::AdHocAbstract |
Class for declaration of polymorphic Record. More... | |
class | Input::Type::TypeBase |
Base of classes for declaring structure of the input data. More... | |
class | Input::Type::Array |
Class for declaration of inputs sequences. More... | |
class | Input::Type::Scalar |
Base of all scalar types. More... | |
class | Input::Type::Bool |
Class for declaration of the input of type Bool. More... | |
class | Input::Type::Integer |
Class for declaration of the integral input data. More... | |
class | Input::Type::Double |
Class for declaration of the input data that are floating point numbers. More... | |
class | Input::Type::String |
Class for declaration of the input data that are in string format. More... | |
class | Input::Type::FileName |
Class for declaration of the input data that are file names. More... | |
class | Input::Type::OutputBase |
Base abstract class for output description of the Input::Type tree. More... | |
class | Input::Type::OutputText |
Class for create text documentation. More... | |
class | Input::Type::OutputJSONMachine |
Class for create JSON machine readable documentation. More... | |
class | Input::Type::Default |
Class Input::Type::Default specifies default value of keys of a Input::Type::Record . More... | |
class | Input::Type::Record |
Record type proxy class. More... | |
class | Input::Type::Selection |
Template for classes storing finite set of named values. More... | |
The purpose of the classes in the Input::Type
namespace is to declare structure of the input data. There are few basic data types (scalar types), further there is Array type to declare sequences of data of common type. Similarly to C++ struct type, we provide type Record which is set of data of possibly different types indexed by string keys. Finally, we introduce kind of polymorphism through AbstractRecord
type that mimics abstract classes.
Types that are simple to construct (Array
and scalar types) are cloned when the copy constructor is called (e.g. in Record::declare_key) On the other hand, some other types have nontrivial initialization (Record, AbstractRecord, Selection). The latter group is not cloned on copy operations, since these are mere boost::shared_ptr
to structure with actual type. The copy constructor makes only copy of the shared pointer. These types are also named and their description can be provided.
The basic scalar types are String
, Bool
, Integer
, Double
, and FileName
. First four types directly corresponds to C++ types. Individual instances of String
and Bool
classes are identical. On the other hand, instances of Integer and Double classes can differ since you can specify the interval of the valid values. Finally, the type FileName
is used for initialization of FilePath
objects and thus can be either for input or for output file.
Nontrivial scalar type is Selection
which mimics and should be used to initialize C++ enum variables. The Selection object identifies possible integer values (that should corrspond to enum values) strings that should correspond to names of the values (should be same as names in enum).
Unfortunately there is no way to get names of an enum type as strings so this information has to be provided through method add_value
.
Every Selection
object has particular name and description. Description of individual values is optional.
The particular Array
type is given by the type of its elementsand possibly by the limits for the array size. All the elements of the array must have same type, but you can use polymorphism provided by AbstractRecord.
One instance of Record
is like one class definition in C++. You specify its members calling the method declare_key
. Key names should be valid C++ keywords. Every key represents a value of arbitrary but given type. For every key, you can provide a default value and key description.
Mimics polymorphism of C++ classes. Any Record can be derived (using Recrod::derive
method) from an AbstractRecord. This has two effects. First, all keys of the AbstractRecord are also members of the inheriting Record. Second, the actual input data for an AbstractRecord has to specify value of the special key 'TYPE' that provides name of one of descendants of the AbstractRecord. This mechanism allows to influence type of the input data by the input itself, but only from the declared set of descendants of the AbstractRecord.