|
Flow123d
jenkins-Flow123d-windows32-release-multijob-163
|
Base of classes for declaring structure of the input data. More...
#include <type_base.hh>

Public Member Functions | |
| virtual bool | is_finished () const |
| virtual string | type_name () const |
| Returns an identification of the type. Useful for error messages. More... | |
| virtual string | full_type_name () const |
| Returns an identification of the type in format "type_name():parent->type_name()". More... | |
| string | desc () const |
| virtual bool | operator== (const TypeBase &other) const |
| bool | operator!= (const TypeBase &other) const |
| Comparison of types. More... | |
| virtual | ~TypeBase () |
| virtual bool | finish () |
| virtual bool | valid_default (const string &str) const =0 |
| virtual std::size_t | content_hash () const =0 |
Static Public Member Functions | |
| static void | lazy_finish () |
| Finishes all registered lazy types. More... | |
Protected Types | |
| typedef string | KeyHash |
| typedef std::vector < boost::shared_ptr< TypeBase > > | LazyTypeVector |
| typedef std::set< const TypeBase * > | LazyObjectsSet |
Protected Member Functions | |
| TypeBase () | |
| TypeBase (const TypeBase &other) | |
Static Protected Member Functions | |
| static KeyHash | key_hash (const string &str) |
| Hash function. More... | |
| static bool | is_valid_identifier (const string &key) |
| static LazyTypeVector & | lazy_type_list () |
| static LazyObjectsSet & | lazy_object_set () |
| static bool | was_constructed (const TypeBase *ptr) |
Friends | |
| class | Array |
| class | Record |
Base of classes for declaring structure of the input data.
Provides methods common to all types. Namely, the type name, finished status (nontrivial only for types with complex initialization - Record, AbstractRecosd, Selection) and output of the documentation.
Definition at line 63 of file type_base.hh.
|
protected |
Type of hash values used in associative array that translates key names to indices in Record and Selection.
For simplicity, we currently use whole strings as "hash".
Definition at line 168 of file type_base.hh.
|
protected |
Set of pointers to all constructed (even temporaries) lazy types. This list contains ALL instances (including copies and empty handles) of lazy types.
Definition at line 204 of file type_base.hh.
|
protected |
The Singleton class LazyTypes serves for handling the lazy-evaluated input types, derived from the base class LazyType. When all static variables are initialized, the method LazyTypes::instance().finish() can be called in order to finish initialization of lazy types such as Records, AbstractRecords, Arrays and Selections. Selections have to be finished after all other types since they are used by AbstractRecords to register all derived types. For this reason LazyTypes contains two arrays - one for Selections, one for the rest.
This is list of unique instances that may contain raw pointers to possibly not yet constructed (static) objects. Unique instance is the instance that creates unique instance of the data class in pimpl idiom. These has to be completed/finished before use.
Definition at line 193 of file type_base.hh.
|
virtual |
Destructor removes type object from lazy_object_set.
Definition at line 59 of file type_base.cc.
|
protected |
Default constructor. Register type object into lazy_object_set.
Definition at line 46 of file type_base.cc.
|
protected |
Copy constructor. Register type object into lazy_object_set.
Definition at line 52 of file type_base.cc.
|
pure virtual |
Hash of the type specification. Provides unique id computed from its content (definition) so that same types have same hash.
Implemented in Input::Type::AdHocAbstractRecord, Input::Type::AbstractRecord, Input::Type::FileName, Input::Type::String, Input::Type::Double, Input::Type::Integer, Input::Type::Bool, Input::Type::Array, Input::Type::Record, and Input::Type::Selection.
| string Input::Type::TypeBase::desc | ( | ) | const |
Returns string with Type extensive documentation. We need this to pass Type description at throw points since the Type object can be deallocated during stack unrolling so it is not good idea to pass pointer. Maybe we can pass smart pointers. Actually this method is used in various exceptions in json_to_storage.
Some old note on this topic: !!! how to pass instance of descendant of TypeBase through EI -
Definition at line 73 of file type_base.cc.

|
inlinevirtual |
Finish method. Finalize construction of "Lazy types": Record, Selection, AbstractRecord, and Array. These input types are typically defined by means of static variables, whose order of initialization is not known a priori. Since e.g. a Record can link to other input types through its keys, these input types cannot be accessed directly at the initialization phase. The remaining part of initialization can be done later, typically from main(), by calling the method finish().
Finish try to convert all raw pointers pointing to lazy types into smart pointers to valid objects. If there are still raw pointers to not constructed objects the method returns false.
Reimplemented in Input::Type::AdHocAbstractRecord, Input::Type::Record, Input::Type::Array, and Input::Type::Selection.
Definition at line 131 of file type_base.hh.
|
inlinevirtual |
Returns an identification of the type in format "type_name():parent->type_name()".
Reimplemented in Input::Type::Scalar, Input::Type::Array, Input::Type::Record, and Input::Type::Selection.
Definition at line 78 of file type_base.hh.
|
inlinevirtual |
Returns true if the type is fully specified and ready for read access. For Record and Array types this say nothing about child types referenced in particular type object. In particular for Record and Selection, it returns true after finish() method is called.
Reimplemented in Input::Type::Array, Input::Type::Record, and Input::Type::Selection.
Definition at line 71 of file type_base.hh.
|
staticprotected |
Check that a key is valid identifier, i.e. consists only of valid characters, that are lower-case letters, digits and underscore, we allow identifiers starting with a digit, but it is discouraged since it slows down parsing of the input file.
Definition at line 67 of file type_base.cc.

|
inlinestaticprotected |
Hash function.
Definition at line 171 of file type_base.hh.

|
static |
Finishes all registered lazy types.
Definition at line 88 of file type_base.cc.

|
staticprotected |
|
staticprotected |
The reference to the singleton instance of lazy_type_list.
Definition at line 81 of file type_base.cc.

|
inline |
Comparison of types.
Definition at line 107 of file type_base.hh.
|
inlinevirtual |
Comparison of types. It compares kind of type (Integer, Double, String, Record, ..), for complex types it also compares names. For arrays compare subtypes.
Reimplemented in Input::Type::FileName, Input::Type::Array, Input::Type::Record, and Input::Type::Selection.
Definition at line 103 of file type_base.hh.
|
inlinevirtual |
Returns an identification of the type. Useful for error messages.
Reimplemented in Input::Type::FileName, Input::Type::String, Input::Type::Double, Input::Type::Integer, Input::Type::Bool, Input::Type::Array, Input::Type::Record, and Input::Type::Selection.
Definition at line 75 of file type_base.hh.

|
pure virtual |
For types that can be initialized from a default string, this method check validity of the default string. For invalid string an exception is thrown.
Return false if the validity can not be decided due to presence of unconstructed types (Record, Selection)
Implemented in Input::Type::AbstractRecord, Input::Type::String, Input::Type::Double, Input::Type::Integer, Input::Type::Bool, Input::Type::Array, Input::Type::Record, and Input::Type::Selection.

|
staticprotected |
|
friend |
Definition at line 210 of file type_base.hh.
|
friend |
Definition at line 211 of file type_base.hh.
1.8.8