
#include <Component/ParamMap.H>
Collaboration diagram for ParamMap:

ParamMap allows reading and writing of arbitrarily nested data structes to and from files or other streams.
Definition at line 49 of file ParamMap.H.
Public Types | |
| enum | ReturnCode { MISSING, UNCHANGED, CHANGED } |
| Return codes when getting params from the map. More... | |
Public Member Functions | |
| ParamMap () | |
| Default construct with an empty map. | |
| ParamMap (const std::string &fname) | |
| Construct and load() from fname. | |
| ~ParamMap () | |
| Destructor. | |
| key_iterator | keys_begin () const |
| Get an iterator to the beginning of the keys sequence. | |
| key_iterator | keys_end () const |
| Get an iterator to one-past-the-end of the keys sequence. | |
| void | load (std::istream &istrm) |
| Load in a parameter map from the given input stream. | |
| void | load (const std::string &fname) |
| Convenience overload of the other load(). | |
| void | format (std::ostream &ostrm, int indentlev=0) const |
| Write a formatted parameter map to the given output stream. | |
| void | format (const std::string &fname) const |
| Convenience overload of the other format(). | |
| bool | hasParam (const std::string ¶mname) const |
| Query whether the parameter map has a particular named parameter. | |
| bool | isLeaf (const std::string ¶mname) const |
| Query whether the parameter map is a leaf or not. | |
| void | print (const std::string &name) const |
| For testing/debugging only. | |
Functions to extract named values from the ParamMap | |
There are several kinds of functions that differ in how they handle named parameters that are not found in the ParamMap. The first kind look for a named parameter, and trigger and error if that parameter is not found. The second kind take a default value as an additional argument, and return that value if the named parameter is not found. The third kind take a destination by reference, and leave that destination unchanged if the parameter is not found, and additional return a ReturnCode specifying with the parameter was missing, found-and-changed, or found-and-unchanged. | |
| rutz::shared_ptr< ParamMap > | getSubpmap (const std::string ¶mname) const |
| Get a named parameter as a nested parameter map. | |
| std::string | getStringParam (const std::string ¶mname) const |
| Get a named parameter as a string value. | |
| double | getDoubleParam (const std::string ¶mname) const |
| Get a named parameter as a 'double' value. | |
| int | getIntParam (const std::string ¶mname) const |
| Get a named parameter as an 'int' value. | |
| std::string | getStringParam (const std::string ¶mname, const std::string &defval) const |
| Get a named parameter as a string value, or return the default value. | |
| double | getDoubleParam (const std::string ¶mname, const double defval) const |
| Get a named parameter as a 'double' value, or return the default value. | |
| int | getIntParam (const std::string ¶mname, const int defval) const |
| Get a named parameter as an 'int' value, or return the default value. | |
| rutz::shared_ptr< ParamMap > | lookupSubpmap (const std::string ¶mname) |
| Returns the submap for the given name. | |
| ReturnCode | queryStringParam (const std::string ¶mname, std::string &result) const |
| Get the named parameter, or do nothing if the parameter is missing. | |
| ReturnCode | queryDoubleParam (const std::string ¶mname, double &result) const |
| Get the named parameter, or do nothing if the parameter is missing. | |
| ReturnCode | queryIntParam (const std::string ¶mname, int &result) const |
| Get the named parameter, or do nothing if the parameter is missing. | |
Functions to place named values into the ParamMap | |
| void | putSubpmap (const std::string ¶mname, const rutz::shared_ptr< ParamMap > &val) |
| Add a nested parameter map with a given name. | |
| void | putStringParam (const std::string ¶mname, const std::string &val) |
| Add a string value with a given name. | |
| void | putDoubleParam (const std::string ¶mname, double val) |
| Add a double-precision floating point value with a given name. | |
| void | putIntParam (const std::string ¶mname, int val) |
| Add an integral value with a given name. | |
| void | replaceSubpmap (const std::string ¶mname, const rutz::shared_ptr< ParamMap > &val) |
| Replace a submap. | |
| void | replaceStringParam (const std::string ¶mname, const std::string &val) |
| Replace string-param. | |
| void | replaceDoubleParam (const std::string ¶mname, double val) |
| Replace double-param. | |
| void | replaceIntParam (const std::string ¶mname, int val) |
| Replace int-param. | |
| void | clear () |
| Remove all params from the ParamMap. | |
Static Public Member Functions | |
| static rutz::shared_ptr< ParamMap > | loadPmapFile (const std::string &fname) |
| Convenience function to create a new ParamMap from a .pmap file. | |
| static rutz::shared_ptr< ParamMap > | loadConfFile (const std::string &fname) |
| Compatibility function to create a new ParamMap from a .conf file. | |
Classes | |
| class | key_iterator |
| struct | Impl |
|
|
Return codes when getting params from the map.
Definition at line 66 of file ParamMap.H. |
|
|
Default construct with an empty map.
Definition at line 321 of file ParamMap.C. |
|
|
Construct and load() from fname.
Definition at line 326 of file ParamMap.C. References load(). |
|
|
Destructor.
Definition at line 333 of file ParamMap.C. |
|
|
Remove all params from the ParamMap.
Definition at line 697 of file ParamMap.C. References ParamMap::Impl::itsParams. Referenced by ModelManagerDialog::handleItemEdit(), and ModelManagerDialog::init(). |
|
|
Convenience overload of the other format(). In this case we just build an ostream internally from the given filename, and then format() from that. Definition at line 460 of file ParamMap.C. |
|
||||||||||||
|
Write a formatted parameter map to the given output stream. The indentlev parameter is only used internally by ParamMap, and can be safely ignored by external callers. Definition at line 444 of file ParamMap.C. References dummy_namespace_to_avoid_gcc411_bug_ParamMap_C::escapeWrite(), i, ParamMap::Impl::itsParams, and lobot::stop(). Referenced by Channels_xx_facets_xx_1(), format(), SingleChannelBeo::handleInput(), and ModelManager::saveConfig(). |
|
||||||||||||
|
Get a named parameter as a 'double' value, or return the default value. The default value will be returned if the named parameter is not found. Definition at line 545 of file ParamMap.C. References queryDoubleParam(). |
|
|
Get a named parameter as a 'double' value. Triggers an error if there is no parameter with the given name. Definition at line 514 of file ParamMap.C. References ParamMap::Impl::itsParams, and LFATAL. Referenced by modelparam_xx_writeto_xx_1(), ChannelFacetScalarComplex::readFrom(), and ChannelFacetScalarSingle::readFrom(). |
|
||||||||||||
|
Get a named parameter as an 'int' value, or return the default value. The default value will be returned if the named parameter is not found. Definition at line 554 of file ParamMap.C. References queryIntParam(). |
|
|
Get a named parameter as an 'int' value. Triggers an error if there is no parameter with the given name. Definition at line 525 of file ParamMap.C. References ParamMap::Impl::itsParams, and LFATAL. |
|
||||||||||||
|
Get a named parameter as a string value, or return the default value. The default value will be returned if the named parameter is not found. Definition at line 536 of file ParamMap.C. References queryStringParam(). |
|
|
Get a named parameter as a string value. Triggers an error if there is no parameter with the given name. Definition at line 503 of file ParamMap.C. References ParamMap::Impl::itsParams, and LFATAL. Referenced by ChannelBase::readFrom(). |
|
|
Get a named parameter as a nested parameter map. Triggers an error if there is no parameter with the given name. Definition at line 492 of file ParamMap.C. References ParamMap::Impl::itsParams, and LFATAL. Referenced by ModelManagerDialog::handleItemEdit(), ModelManagerDialog::init(), lookupSubpmap(), ChannelFacetMap::readFacetsFrom(), IntegerComplexChannel::readFrom(), ComplexChannel::readFrom(), and ModelComponent::readParamsFrom(). |
|
|
Query whether the parameter map has a particular named parameter.
Definition at line 475 of file ParamMap.C. References ParamMap::Impl::itsParams. Referenced by lookupSubpmap(), ChannelFacetMap::readFacetsFrom(), IntegerComplexChannel::readFrom(), ComplexChannel::readFrom(), ChannelFacetScalarComplex::readFrom(), ChannelFacetScalarSingle::readFrom(), ChannelBase::readFrom(), and ModelComponent::readParamsFrom(). |
|
|
Query whether the parameter map is a leaf or not.
Definition at line 482 of file ParamMap.C. References ParamMap::Impl::itsParams. |
|
|
Get an iterator to the beginning of the keys sequence.
Definition at line 340 of file ParamMap.C. References ParamMap::Impl::itsParams, and ParamMap::key_iterator::rep. |
|
|
Get an iterator to one-past-the-end of the keys sequence.
Definition at line 349 of file ParamMap.C. References ParamMap::Impl::itsParams, and ParamMap::key_iterator::rep. |
|
|
Convenience overload of the other load(). In this case we just build an istream internally from the given filename, and then load() from that. Definition at line 429 of file ParamMap.C. |
|
|
Load in a parameter map from the given input stream.
Definition at line 357 of file ParamMap.C. References c, dummy_namespace_to_avoid_gcc411_bug_ParamMap_C::escapeRead(), ParamMap::Impl::itsParams, LFATAL, and rutz::max(). Referenced by Channels_xx_facets_xx_1(), SingleChannelBeoServer::check(), load(), ModelManager::loadConfig(), ParamMap(), and ModelManager::parseCommandLine(). |
|
|
Compatibility function to create a new ParamMap from a .conf file. See readConfig for details on the format of a .conf file. Basically, it is similar to the .pmap format, except that comments must be bracketed by whitespace-separated '#' characters on both sides, and that there is no nesting of data structures. Definition at line 282 of file ParamMap.C. |
|
|
Convenience function to create a new ParamMap from a .pmap file.
Definition at line 274 of file ParamMap.C. Referenced by main(). |
|
|
Returns the submap for the given name. If a submap for the given name exists, a rutz::shared_ptr to it is returned. If no submap for the given name has yet been created, one is created, and a rutz::shared_ptr to it is returned. This function differs from getSubpmap(), which only returns existing submaps. Definition at line 563 of file ParamMap.C. References getSubpmap(), hasParam(), and putSubpmap(). |
|
|
For testing/debugging only. Prints the raw contents of this parameter map to standard output. Definition at line 703 of file ParamMap.C. References ParamMap::Impl::itsParams, and lobot::stop(). |
|
||||||||||||
|
Add a double-precision floating point value with a given name.
Definition at line 656 of file ParamMap.C. References ParamMap::Impl::itsParams. Referenced by GaborChannel::writeTo(), ChannelFacetScalarComplex::writeTo(), and ChannelFacetScalarSingle::writeTo(). |
|
||||||||||||
|
Add an integral value with a given name.
Definition at line 662 of file ParamMap.C. References ParamMap::Impl::itsParams. Referenced by modelparam_xx_readfrom_xx_1(), and GaborChannel::writeTo(). |
|
||||||||||||
|
Add a string value with a given name.
Definition at line 650 of file ParamMap.C. References ParamMap::Impl::itsParams. Referenced by ModelParamAuxImpl::writeTo(), and ChannelBase::writeTo(). |
|
||||||||||||
|
Add a nested parameter map with a given name.
Definition at line 644 of file ParamMap.C. References ParamMap::Impl::itsParams. Referenced by lookupSubpmap(), ChannelFacetMap::writeFacetsTo(), ModelComponent::writeParamsTo(), IntegerComplexChannel::writeTo(), and ComplexChannel::writeTo(). |
|
||||||||||||
|
Get the named parameter, or do nothing if the parameter is missing. The ReturnCode describes what happened when looking up the param. Definition at line 599 of file ParamMap.C. References CHANGED, ParamMap::Impl::itsParams, LINFO, MISSING, and UNCHANGED. Referenced by getDoubleParam(), and GaborChannel::readFrom(). |
|
||||||||||||
|
Get the named parameter, or do nothing if the parameter is missing. The ReturnCode describes what happened when looking up the param. Definition at line 622 of file ParamMap.C. References CHANGED, ParamMap::Impl::itsParams, LINFO, MISSING, and UNCHANGED. Referenced by getIntParam(), and GaborChannel::readFrom(). |
|
||||||||||||
|
Get the named parameter, or do nothing if the parameter is missing. The ReturnCode describes what happened when looking up the param. Definition at line 576 of file ParamMap.C. References CHANGED, ParamMap::Impl::itsParams, LINFO, MISSING, and UNCHANGED. Referenced by getStringParam(), and ModelParamAuxImpl::readFrom(). |
|
||||||||||||
|
Replace double-param.
Definition at line 683 of file ParamMap.C. References ParamMap::Impl::itsParams. |
|
||||||||||||
|
Replace int-param.
Definition at line 690 of file ParamMap.C. References ParamMap::Impl::itsParams. |
|
||||||||||||
|
Replace string-param.
Definition at line 676 of file ParamMap.C. References ParamMap::Impl::itsParams. |
|
||||||||||||
|
Replace a submap.
Definition at line 668 of file ParamMap.C. References ParamMap::Impl::itsParams. |
1.4.4