|
Flow123d
jenkins-Flow123d-linux-release-multijob-282
|
Template for classes storing finite set of named values. More...
#include <type_selection.hh>


Classes | |
| struct | Key |
| class | SelectionData |
Public Types | |
| typedef std::vector< struct Key >::const_iterator | keys_const_iterator |
Public Member Functions | |
| TYPEDEF_ERR_INFO (EI_Selection, const Selection) | |
| TYPEDEF_ERR_INFO (EI_Value, const int) | |
| DECLARE_EXCEPTION (ExcSelectionKeyNotFound,<< "Key "<< EI_KeyName::qval<<" not found in Selection:\n"<< EI_Selection::val) | |
| DECLARE_EXCEPTION (ExcSelectionValueNotFound,<< "Value "<< EI_Value::val<<" not found in Selection:\n"<< EI_Selection::val) | |
| Selection () | |
| Selection (const Selection &other) | |
| Selection (const string &name, const std::string &description="") | |
| Selection & | add_value (const int value, const std::string &key, const std::string &description="") |
| const Selection & | close () const |
| std::size_t | content_hash () const override |
| virtual bool | is_finished () const |
Implements TypeBase::is_finished. More... | |
| virtual string | type_name () const |
Implements TypeBase::type_name. More... | |
| virtual string | full_type_name () const |
Implements TypeBase::full_type_name. More... | |
| virtual bool | operator== (const TypeBase &other) const |
Implements TypeBase::operator== compare also Selection names. More... | |
| keys_const_iterator | begin () const |
| keys_const_iterator | end () const |
| keys_const_iterator | key_iterator (const string &key) const |
| int | name_to_int (const string &key) const |
| string | int_to_name (const int &value) const |
| Selection & | copy_values (const Selection &sel) |
| int | from_default (const string &str) const |
| virtual bool | valid_default (const string &str) const |
Implements Type::TypeBase::valid_defaults. More... | |
| bool | has_name (const string &key) const |
| bool | has_value (const int &val) const |
| unsigned int | size () const |
| bool | finish () |
Public Member Functions inherited from Input::Type::TypeBase | |
| string | desc () const |
| bool | operator!= (const TypeBase &other) const |
| Comparison of types. More... | |
| virtual | ~TypeBase () |
Private Member Functions | |
| void | finished_check () const |
| string | key_list () const |
Private Attributes | |
| boost::shared_ptr< SelectionData > | data_ |
| Handle to actual Selection data. More... | |
Friends | |
| class | OutputBase |
Additional Inherited Members | |
Static Public Member Functions inherited from Input::Type::TypeBase | |
| static void | lazy_finish () |
| Finishes all registered lazy types. More... | |
Protected Types inherited from Input::Type::TypeBase | |
| typedef string | KeyHash |
| typedef std::vector < boost::shared_ptr< TypeBase > > | LazyTypeVector |
| typedef std::set< const TypeBase * > | LazyObjectsSet |
Protected Member Functions inherited from Input::Type::TypeBase | |
| TypeBase () | |
| TypeBase (const TypeBase &other) | |
Static Protected Member Functions inherited from Input::Type::TypeBase | |
| 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) |
Template for classes storing finite set of named values.
The primary purpose of this class is initialization of enum variables. Since C++ provides no reflection, in particular no access to enum identifiers as strings, you has to construct the Selection object consistent with an enum you want to initialize.
Similarly to Type::Record and Type::AbstractRecord the Selection class is only proxy to the actual data.
Usage:
TODO: We can not guarantee full compatibility of the Selection with corresponding Enum type the Selection can have fewer values since we can not get number of values in the Enum. Therefore we either have to move under C++11, where enum classes may provide elementary reflection or have Selection of simple ints.
Definition at line 50 of file type_selection.hh.
| typedef std::vector<struct Key>::const_iterator Input::Type::Selection::keys_const_iterator |
Public typedef of constant iterator into array of keys
Definition at line 77 of file type_selection.hh.
| Input::Type::Selection::Selection | ( | ) |
Default constructor. Empty selection.
Definition at line 16 of file type_selection.cc.
| Input::Type::Selection::Selection | ( | const Selection & | other | ) |
Copy constructor.
Definition at line 24 of file type_selection.cc.
| Input::Type::Selection::Selection | ( | const string & | name, |
| const std::string & | description = "" |
||
| ) |
Creates a handle pointing to the new SelectionData.
| Selection & Input::Type::Selection::add_value | ( | const int | value, |
| const std::string & | key, | ||
| const std::string & | description = "" |
||
| ) |
Adds one new value with name given by key to the Selection. The description of meaning of the value could be provided.
Definition at line 41 of file type_selection.cc.

|
inline |
Container-like access to the keys of the Record. Returns iterator to the first key.
Definition at line 266 of file type_selection.hh.

| const Selection & Input::Type::Selection::close | ( | ) | const |
Close the Selection, no more values can be added.
Definition at line 50 of file type_selection.cc.

|
overridevirtual |
Hash of the type specification. Provides unique id computed from its content (definition) so that same types have same hash.
Implements Input::Type::TypeBase.
Definition at line 57 of file type_selection.cc.

Definition at line 123 of file type_selection.cc.
| Input::Type::Selection::DECLARE_EXCEPTION | ( | ExcSelectionKeyNotFound | , |
| << "Key "<< EI_KeyName::qval<<" not found in Selection:\n"<< EI_Selection::val | |||
| ) |
| Input::Type::Selection::DECLARE_EXCEPTION | ( | ExcSelectionValueNotFound | , |
| << "Value "<< EI_Value::val<<" not found in Selection:\n"<< EI_Selection::val | |||
| ) |
|
inline |
Container-like access to the keys of the Record. Returns iterator to the last key.
Definition at line 274 of file type_selection.hh.

|
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 from Input::Type::TypeBase.
Definition at line 173 of file type_selection.hh.
|
inlineprivate |
Assertion for finished Selection (methods are called in correct order).
Definition at line 260 of file type_selection.hh.

| int Input::Type::Selection::from_default | ( | const string & | str | ) | const |
Same as Selection::name_to_int, but throws different exception, when string comes from default value.
Definition at line 137 of file type_selection.cc.
|
virtual |
Implements TypeBase::full_type_name.
Reimplemented from Input::Type::Scalar.
Definition at line 90 of file type_selection.cc.

|
inline |
Just check if there is a particular name in the Selection.
Definition at line 234 of file type_selection.hh.

|
inline |
Check if there is a particular value in the Selection.
Definition at line 242 of file type_selection.hh.
| string Input::Type::Selection::int_to_name | ( | const int & | value | ) | const |
Returns value name for the given value. Throws exception if the value does not exist.
Definition at line 113 of file type_selection.cc.

|
virtual |
Implements TypeBase::is_finished.
Reimplemented from Input::Type::TypeBase.
Definition at line 80 of file type_selection.cc.

|
inline |
Returns iterator to the key struct for given key string.
Definition at line 281 of file type_selection.hh.
|
private |
Used in error messaged, where we can not use desc(), which can lead to infinite loop due to TYPE selection of AbstractRecord.
Definition at line 147 of file type_selection.cc.

| int Input::Type::Selection::name_to_int | ( | const string & | key | ) | const |
Converts given value name key to the value. Throws exception if the value name does not exist.
Definition at line 102 of file type_selection.cc.

|
virtual |
Implements TypeBase::operator== compare also Selection names.
Reimplemented from Input::Type::TypeBase.
Definition at line 96 of file type_selection.cc.
|
inline |
Returns number of values in the Selection.
Definition at line 249 of file type_selection.hh.

|
virtual |
Implements TypeBase::type_name.
Reimplemented from Input::Type::TypeBase.
Definition at line 85 of file type_selection.cc.

| Input::Type::Selection::TYPEDEF_ERR_INFO | ( | EI_Selection | , |
| const Selection | |||
| ) |
| Input::Type::Selection::TYPEDEF_ERR_INFO | ( | EI_Value | , |
| const int | |||
| ) |
|
virtual |
Implements Type::TypeBase::valid_defaults.
Implements Input::Type::TypeBase.
Definition at line 73 of file type_selection.cc.
|
friend |
Definition at line 51 of file type_selection.hh.
|
private |
Handle to actual Selection data.
Definition at line 222 of file type_selection.hh.
1.8.5