|
FEAT 3
Finite Element Analysis Toolbox
|
A class organizing a tree of key-value pairs. More...
#include <property_map.hpp>
Public Types | |
| typedef EntryMap::const_iterator | ConstEntryIterator |
| const entry iterator type More... | |
| typedef SectionMap::const_iterator | ConstSectionIterator |
| const section iterator type More... | |
| typedef EntryMap::iterator | EntryIterator |
| entry iterator type More... | |
| typedef std::map< String, String, String::NoCaseLess > | EntryMap |
| entry-map type More... | |
| typedef SectionMap::iterator | SectionIterator |
| section iterator type More... | |
| typedef std::map< String, std::shared_ptr< PropertyMap >, String::NoCaseLess > | SectionMap |
| section-map type More... | |
Public Member Functions | |
| PropertyMap (const PropertyMap &)=delete | |
| Delete copy constructor. | |
| PropertyMap (PropertyMap *parent=nullptr) | |
| Default Constructor. More... | |
| virtual | ~PropertyMap () |
| Virtual Destructor. More... | |
| bool | add_entry (String key, String value, bool replace=true) |
| Adds a new key-value pair to this map. More... | |
| PropertyMap * | add_section (String name) |
| Adds a new sub-section to this map. More... | |
| EntryIterator | begin_entry () |
| Returns the first entry iterator. More... | |
| ConstEntryIterator | begin_entry () const |
| Returns the first entry iterator. More... | |
| SectionIterator | begin_section () |
| Returns the first section iterator. More... | |
| ConstSectionIterator | begin_section () const |
| Returns the first section iterator. More... | |
| EntryIterator | end_entry () |
| Returns the last entry iterator. More... | |
| ConstEntryIterator | end_entry () const |
| Returns the last entry iterator. More... | |
| SectionIterator | end_section () |
| Returns the last section iterator. More... | |
| ConstSectionIterator | end_section () const |
| Returns the last section iterator. More... | |
| bool | erase_entry (String key) |
| Erases a key-value pair. More... | |
| bool | erase_section (String name) |
| Erases a sub-section. More... | |
| std::pair< String, bool > | get_entry (String key) const |
| Retrieves a value by its key. More... | |
| EntryMap & | get_entry_map () |
| Returns a reference to the entry map. More... | |
| const EntryMap & | get_entry_map () const |
| Returns a reference to the entry map. More... | |
| PropertyMap * | get_parent () |
| Returns a pointer to the parent section. More... | |
| const PropertyMap * | get_parent () const |
| Returns a pointer to the parent section. More... | |
| PropertyMap * | get_root () |
| Returns a pointer to the root section. More... | |
| const PropertyMap * | get_root () const |
| Returns a pointer to the root section. More... | |
| PropertyMap * | get_sub_section (String name) |
| Retrieves a sub-section by its name. More... | |
| const PropertyMap * | get_sub_section (String name) const |
| void | merge (const PropertyMap §ion, bool replace=true) |
Merges another PropertyMap into this. More... | |
| PropertyMap & | operator= (const PropertyMap &)=delete |
| Delete copy assignment operator. | |
| template<typename T_ > | |
| bool | parse_entry (const String &key, T_ &x, bool rtn_non_exist=true) const |
| Parses an object from the value of an entry. More... | |
| std::pair< String, bool > | query (String key_path) const |
| Queries a value by its key path. More... | |
| String | query (String key_path, String default_value) const |
| Queries a value by its key path. More... | |
| PropertyMap * | query_section (String sec_path) |
| Queries a section by its section path. More... | |
| const PropertyMap * | query_section (String sec_path) const |
| Queries a section by its section path. More... | |
| void | read (const Dist::Comm &comm, String filename, bool replace=true) |
| Parses a file in INI-format. More... | |
| void | read (std::istream &ifs, bool replace=true) |
| Parses an input stream. More... | |
| void | read (String filename, bool replace=true) |
| Parses a file in INI-format. More... | |
| std::unique_ptr< PropertyMap > | treeify_structures () const |
| Builds a new property map by inserting subsection based on section names. More... | |
| void | write (const Dist::Comm &comm, String filename) const |
| Writes the property map into a file. More... | |
| void | write (std::ostream &os, String::size_type indent=0) const |
| Writes the property map into an output stream. More... | |
| void | write (String filename) const |
| Writes the property map into a file. More... | |
Protected Attributes | |
| PropertyMap * | _parent |
| pointer to the parent node More... | |
| SectionMap | _sections |
| a map storing the sub-sections More... | |
| EntryMap | _values |
| a map storing the key-value-pairs More... | |
A class organizing a tree of key-value pairs.
Path Specification:
Some functions of this class, namely the query() and query_section() functions, use paths for their search. Paths allow to search for sections and key-value pairs (either relatively or absolutely) within the whole property map tree instead of only within the current property map represented by the ProperyMap object itself.
For this, three characters are reserved as special characters in the path:
/ represents a path separator (just as in file-system paths).! represents the root section.~ represents the parent section (as the double-dot .. in file-system paths).Examples:
SecName/KeyName: searches for a key named KeyName inside a sub-section named SecName within the current section.!/SecName/KeyName: searches for key named KeyName inside a sub-section named SecName within the root section; independent of which section is represented by the current section.~/KeyName: searches for a key named KeyName inside the parent section of the current section.Definition at line 47 of file property_map.hpp.
| typedef EntryMap::const_iterator FEAT::PropertyMap::ConstEntryIterator |
const entry iterator type
Definition at line 58 of file property_map.hpp.
| typedef SectionMap::const_iterator FEAT::PropertyMap::ConstSectionIterator |
const section iterator type
Definition at line 62 of file property_map.hpp.
| typedef EntryMap::iterator FEAT::PropertyMap::EntryIterator |
entry iterator type
Definition at line 56 of file property_map.hpp.
| typedef std::map<String, String, String::NoCaseLess> FEAT::PropertyMap::EntryMap |
entry-map type
Definition at line 51 of file property_map.hpp.
| typedef SectionMap::iterator FEAT::PropertyMap::SectionIterator |
section iterator type
Definition at line 60 of file property_map.hpp.
| typedef std::map<String, std::shared_ptr<PropertyMap>, String::NoCaseLess> FEAT::PropertyMap::SectionMap |
section-map type
Definition at line 53 of file property_map.hpp.
|
explicit |
Default Constructor.
Definition at line 16 of file property_map.cpp.
|
virtual |
Virtual Destructor.
Definition at line 21 of file property_map.cpp.
Adds a new key-value pair to this map.
This function adds a new key-value pair to this section or, if desired, overwrites an existing one.
| [in] | key | A String containing the key of the entry. |
| [in] | value | A String containing the value of the entry. |
| [in] | replace | Specifies the behavior when an entry with the same key already exists in the section:
|
true, if the key-value-pair has been stored or false, if an entry with the key already exists and replace was set to false. Definition at line 25 of file property_map.cpp.
References _values, and FEAT::value.
| PropertyMap * FEAT::PropertyMap::add_section | ( | String | name | ) |
Adds a new sub-section to this map.
This function adds a new sub-section and returns a pointer to it. If a sub-section with the corresponding name already exists, a pointer to that section is returned instead of allocating a new one.
| [in] | name | The name of the section to be added. |
PropertyMap associated to the name.Definition at line 44 of file property_map.cpp.
References _sections.
|
inline |
Returns the first entry iterator.
Definition at line 319 of file property_map.hpp.
References _values.
|
inline |
Returns the first entry iterator.
Definition at line 325 of file property_map.hpp.
References _values.
|
inline |
Returns the first section iterator.
Definition at line 343 of file property_map.hpp.
References _sections.
|
inline |
Returns the first section iterator.
Definition at line 349 of file property_map.hpp.
References _sections.
|
inline |
Returns the last entry iterator.
Definition at line 331 of file property_map.hpp.
References _values.
|
inline |
Returns the last entry iterator.
Definition at line 337 of file property_map.hpp.
References _values.
|
inline |
Returns the last section iterator.
Definition at line 355 of file property_map.hpp.
References _sections.
|
inline |
Returns the last section iterator.
Definition at line 361 of file property_map.hpp.
References _sections.
| bool FEAT::PropertyMap::erase_entry | ( | String | key | ) |
Erases a key-value pair.
| [in] | key | The key of the entry to be erased. |
true if the entry was erased or false if no entry with that key was found. Definition at line 59 of file property_map.cpp.
References _values.
| bool FEAT::PropertyMap::erase_section | ( | String | name | ) |
Erases a sub-section.
| [in] | name | The name of the sub-section to be erased. |
true if the section was erased or false if no section with that name was found. Definition at line 70 of file property_map.cpp.
References _sections.
Retrieves a value by its key.
this for the key. If you want to search whole paths, use the query() function instead.| [in] | key | The key of the entry whose value is to be returned. |
pair<String, bool>, where the second component marks, whether an entry with the key has been found or not. If the bool-component is true, then the String-component contains the value associated with the key, otherwise the String-component is empty. Definition at line 165 of file property_map.cpp.
References _values.
Referenced by FEAT::Solver::IterativeSolver< Vector_ >::IterativeSolver(), FEAT::Solver::NLOptLS< Functional_, Filter_ >::NLOptLS(), parse_entry(), and query().
|
inline |
Returns a reference to the entry map.
Definition at line 307 of file property_map.hpp.
References _values.
|
inline |
Returns a reference to the entry map.
Definition at line 313 of file property_map.hpp.
References _values.
|
inline |
Returns a pointer to the parent section.
nullptr if this section has no parent. Definition at line 277 of file property_map.hpp.
References _parent.
Referenced by query_section().
|
inline |
Returns a pointer to the parent section.
nullptr if this section has no parent. Definition at line 283 of file property_map.hpp.
References _parent.
|
inline |
Returns a pointer to the root section.
Definition at line 291 of file property_map.hpp.
References _parent, and get_root().
Referenced by get_root(), and query_section().
|
inline |
Returns a pointer to the root section.
Definition at line 297 of file property_map.hpp.
References _parent, and get_root().
| PropertyMap * FEAT::PropertyMap::get_sub_section | ( | String | name | ) |
Retrieves a sub-section by its name.
this for the sub-section. If you want to search whole paths, use the query_section() function instead.| [in] | name | The name of the sub-section which is to be returned. |
name or nullptr if no section with that name exists.Definition at line 185 of file property_map.cpp.
References _sections.
Referenced by query_section().
| const PropertyMap * FEAT::PropertyMap::get_sub_section | ( | String | name | ) | const |
Definition at line 175 of file property_map.cpp.
References _sections.
| void FEAT::PropertyMap::merge | ( | const PropertyMap & | section, |
| bool | replace = true |
||
| ) |
Merges another PropertyMap into this.
| [in] | section | The section to be merged into this. |
| [in] | replace | Specifies the behavior when conflicting key-value pairs are encountered. See add_entry() for more details. |
Definition at line 195 of file property_map.cpp.
References _sections, _values, add_entry(), add_section(), and merge().
Referenced by merge().
|
inline |
Parses an object from the value of an entry.
If an entry for the given key exists, this function is equivalent to this->get_entry(key).first.parse(x).
| [in] | key | The key of the entry whose value is to be parsed. |
| [out] | x | A reference to the object that is to be parsed into. |
| [in] | rtn_non_exist | The value that this function should return if there exists no entry for the given key. |
true, if the entry exists and was parsed successfully,false, if the entry exists but could not be parsed,rtn_non_exist, if the entry does not exist Definition at line 262 of file property_map.hpp.
References get_entry().
Queries a value by its key path.
| [in] | key_path | A path to the key whose value is to be returned. |
pair<String,bool>, where the second component marks, whether an entry with the key path has been found or not. If the bool-component is true, then the String-component contains the value associated with the key, otherwise the String-component is empty. Definition at line 125 of file property_map.cpp.
References get_entry(), query_section(), FEAT::String::trim(), and FEAT::String::trim_me().
Referenced by FEAT::Solver::ALGLIBMinCG< Functional_, Filter_ >::ALGLIBMinCG(), FEAT::Solver::ALGLIBMinLBFGS< Functional_, Filter_ >::ALGLIBMinLBFGS(), FEAT::Solver::BiCGStab< Matrix_, Filter_ >::BiCGStab(), FEAT::Solver::BiCGStabL< Matrix_, Filter_ >::BiCGStabL(), FEAT::Solver::Chebyshev< Matrix_, Filter_ >::Chebyshev(), FEAT::Solver::Descent< Matrix_, Filter_ >::Descent(), FEAT::Solver::FixedStepLinesearch< Functional_, Filter_ >::FixedStepLinesearch(), FEAT::Solver::JacobiPrecond< Matrix_, Filter_ >::JacobiPrecond(), FEAT::Solver::Linesearch< Functional_, Filter_ >::Linesearch(), FEAT::Solver::NLCG< Functional_, Filter_ >::NLCG(), FEAT::Solver::NLSD< Functional_, Filter_ >::NLSD(), FEAT::Control::Time::NvsBdfQ< DT_ >::NvsBdfQ(), FEAT::Solver::PCGNRILU< Matrix_, Filter_ >::PCGNRILU(), FEAT::Solver::PolynomialPrecond< Matrix_, Filter_ >::PolynomialPrecond(), FEAT::Solver::QPenalty< Functional_ >::QPenalty(), FEAT::Solver::Richardson< Matrix_, Filter_ >::Richardson(), FEAT::Solver::ScalePrecond< Vector_, Filter_ >::ScalePrecond(), FEAT::Solver::SchwarzPrecond< Global::Vector< LocalVector_, Mirror_ >, Global::Filter< LocalFilter_, Mirror_ > >::SchwarzPrecond(), FEAT::Solver::SecantLinesearch< Functional_, Filter_ >::SecantLinesearch(), FEAT::Solver::SORPrecondWithBackend< PreferredBackend::generic, LAFEM::SparseMatrixBCSR< DT_, IT_, BlockHeight_, BlockWidth_ >, Filter_ >::SORPrecondWithBackend(), FEAT::Solver::SORPrecondWithBackend< PreferredBackend::generic, LAFEM::SparseMatrixCSR< DT_, IT_ >, Filter_ >::SORPrecondWithBackend(), FEAT::Control::Meshopt::ControlFactory< DT_, IT_ >::create_hyperelasticity_control(), FEAT::Control::Meshopt::ControlFactory< DT_, IT_ >::create_hyperelasticity_control_with_cell_functional(), FEAT::Control::Meshopt::MeshoptPrecondFactory::create_nlopt_precond(), FEAT::Control::Domain::PartiDomainControlBase< DomainLevel_ >::parse_property_map(), FEAT::Control::Domain::PartiDomainControl< DomainLevel_ >::parse_property_map(), and query().
Queries a value by its key path.
| [in] | key_path | A path to the key whose value is to be returned. |
| [in] | default_value | A string that is to be returned in the case that the key was not found. |
default_value if no such key was found. Definition at line 156 of file property_map.cpp.
References query().
| PropertyMap * FEAT::PropertyMap::query_section | ( | String | sec_path | ) |
Queries a section by its section path.
| [in] | sec_path | A path to the section that is to be found. |
path or nullptr if no such section was found.Definition at line 81 of file property_map.cpp.
References query_section().
Referenced by FEAT::Control::Meshopt::HyperelasticityFunctionalControl< DT_, IT_, DomainControl_, Hyperelasticity_ >::HyperelasticityFunctionalControl(), FEAT::Meshopt::MeshConcentrationFunctionFactory< Trafo_, RefCellTrafo_ >::create(), FEAT::Control::Meshopt::ControlFactory< DT_, IT_ >::create_dudv_control(), FEAT::Control::Meshopt::ControlFactory< DT_, IT_ >::create_hyperelasticity_control(), FEAT::Control::Meshopt::ControlFactory< DT_, IT_ >::create_meshopt_control(), query(), and query_section().
| const PropertyMap * FEAT::PropertyMap::query_section | ( | String | sec_path | ) | const |
Queries a section by its section path.
| [in] | sec_path | A path to the section that is to be found. |
path or nullptr if no such section was found.Definition at line 87 of file property_map.cpp.
References get_parent(), get_root(), get_sub_section(), query_section(), FEAT::String::trim(), and FEAT::String::trim_me().
| void FEAT::PropertyMap::read | ( | const Dist::Comm & | comm, |
| String | filename, | ||
| bool | replace = true |
||
| ) |
Parses a file in INI-format.
| [in] | filename | The name of the file to be parsed. |
| [in] | replace | Specifies the behavior when an entry with the same key already exists:
|
Definition at line 217 of file property_map.cpp.
References read(), and FEAT::DistFileIO::read_common().
| void FEAT::PropertyMap::read | ( | std::istream & | ifs, |
| bool | replace = true |
||
| ) |
Parses an input stream.
| [in] | ifs | A reference to an input stream to be parsed. |
| [in] | replace | Specifies the behavior when an entry with the same key already exists:
|
Definition at line 224 of file property_map.cpp.
References add_entry(), add_section(), FEAT::String::pop_back(), FEAT::String::pop_front(), FEAT::stringify(), FEAT::String::trim(), FEAT::String::trim_me(), and FEAT::value.
|
inline |
Parses a file in INI-format.
| [in] | filename | The name of the file to be parsed. |
| [in] | replace | Specifies the behavior when an entry with the same key already exists:
|
Definition at line 390 of file property_map.hpp.
References read(), and FEAT::Dist::Comm::world().
Referenced by read().
| std::unique_ptr< PropertyMap > FEAT::PropertyMap::treeify_structures | ( | ) | const |
Builds a new property map by inserting subsection based on section names.
This function transforms a all sections consisting of "sec1/sec2" into real subsections. i.e. transform [sec1] \ [sec1] key1=val1 === \ { key1=val1 [sec1/sec2] === / [sec2] key2=val2 / key2=val2 }
This appears to be necessary due to the oversight?! that "/" is not a reserved charset in sections.
Definition at line 518 of file property_map.cpp.
| void FEAT::PropertyMap::write | ( | const Dist::Comm & | comm, |
| String | filename | ||
| ) | const |
Writes the property map into a file.
This function writes the whole property map into a file, which can be parsed by the read() function.
| [in] | filename | The name of the file into which to dump to. |
Definition at line 445 of file property_map.cpp.
References FEAT::Dist::Comm::rank(), and write().
| void FEAT::PropertyMap::write | ( | std::ostream & | os, |
| String::size_type | indent = 0 |
||
| ) | const |
Writes the property map into an output stream.
This function writes the whole property map into an output stream, which can be parsed.
| [in,out] | os | A reference to an output stream to which to write to. It is silently assumed that the output stream is open. |
| [in] | indent | Specifies the number of indenting whitespaces to be inserted at the beginning of each line. |
indent parameter is used internally for output formatting and does not need to be specified by the caller. Definition at line 465 of file property_map.cpp.
|
inline |
Writes the property map into a file.
This function writes the whole property map into a file, which can be parsed by the read() function.
| [in] | filename | The name of the file into which to dump to. |
Definition at line 434 of file property_map.hpp.
References FEAT::Dist::Comm::world(), and write().
Referenced by write().
|
protected |
pointer to the parent node
Definition at line 66 of file property_map.hpp.
Referenced by get_parent(), and get_root().
|
protected |
a map storing the sub-sections
Definition at line 72 of file property_map.hpp.
Referenced by add_section(), begin_section(), end_section(), erase_section(), get_sub_section(), merge(), and write().
|
protected |
a map storing the key-value-pairs
Definition at line 69 of file property_map.hpp.
Referenced by add_entry(), begin_entry(), end_entry(), erase_entry(), get_entry(), get_entry_map(), merge(), and write().