|
DP3
|
Implements a map of Key-Value pairs. Description of class. The ParameterSetImpl class is a key-value implementation of the type map<string, string, KeyCompare>. This means that values are stored as a string which allows easy merging and splitting of ParameterSetImpls because no conversions have to be done. A couple of getXxx routines are provided to convert the strings to the desired type. More...
#include <ParameterSetImpl.h>
Public Types | |
| typedef KVMap::const_iterator | const_iterator |
| typedef KVMap::iterator | iterator |
Public Member Functions | |
| std::vector< std::string > | unusedKeys () const |
| Get all unused parameter names. More... | |
Construction and Destruction | |
A ParameterSetImpl can be constructed as empty collection, can be read from a file or copied from another collection. | |
| ParameterSetImpl (KeyCompare::Mode mode) | |
| ~ParameterSetImpl () | |
| Destroy the contents. More... | |
| ParameterSetImpl (const std::string &theFilename, KeyCompare::Mode mode) | |
| const ParameterValue & | get (const std::string &aKey) const |
| KeyCompare::Mode | keyCompareMode () const |
| Return the key comparison mode. More... | |
Merging or appending collections | |
An existing collection can be extended/merged with another collection. | |
| void | adoptFile (const std::string &theFilename, const std::string &thePrefix="") |
| void | adoptBuffer (const std::string &theBuffer, const std::string &thePrefix="") |
| void | adoptCollection (const ParameterSetImpl &theCollection, const std::string &thePrefix="") |
| void | adoptArguments (const std::vector< std::string > &arguments) |
Saving the collection | |
The map of key-value pair can be saved in a file or a string. | |
| void | writeFile (const std::string &theFilename, bool append=false) const |
| Writes the Key-Values pair from the current ParCollection to the file. More... | |
| void | writeBuffer (std::string &theBuffer) const |
| void | writeStream (std::ostream &os) const |
Handle subsets | |
A subset from the current collection can be made based on the prefix of the keys in the collection. | |
| std::shared_ptr< ParameterSetImpl > | makeSubset (const std::string &baseKey, const std::string &prefix="") const |
| void | subtractSubset (const std::string &fullPrefix) |
Handling single key-value pairs | |
Single key-value pairs can ofcourse be added, replaced or removed from a collection. | |
| void | add (const std::string &aKey, const ParameterValue &aValue) |
| void | replace (const std::string &aKey, const ParameterValue &aValue) |
| void | remove (const std::string &aKey) |
| Removes the pair with the given key. Removing a non-existing key is ok. More... | |
Searching and retrieving | |
The following functions support searching the collection for existance of given keys an the retrieval of the corresponding value. In the getXxx retrieve functions the stored string-value is converted to the wanted type. | |
| bool | isDefined (const std::string &searchKey) const |
| Checks if the given Key is defined in the ParameterSetImpl. More... | |
| std::string | locateModule (const std::string &shortName) const |
| std::string | fullModuleName (const std::string &shortName) const |
| bool | getBool (const std::string &aKey) const |
| bool | getBool (const std::string &aKey, bool aValue) const |
| int | getInt (const std::string &aKey) const |
| int | getInt (const std::string &aKey, int aValue) const |
| unsigned int | getUint (const std::string &aKey) const |
| unsigned int | getUint (const std::string &aKey, unsigned int aValue) const |
| int16_t | getInt16 (const std::string &aKey) const |
| int16_t | getInt16 (const std::string &aKey, int16_t aValue) const |
| uint16_t | getUint16 (const std::string &aKey) const |
| uint16_t | getUint16 (const std::string &aKey, uint16_t aValue) const |
| int32_t | getInt32 (const std::string &aKey) const |
| int32_t | getInt32 (const std::string &aKey, int32_t aValue) const |
| uint32_t | getUint32 (const std::string &aKey) const |
| uint32_t | getUint32 (const std::string &aKey, uint32_t aValue) const |
| int64_t | getInt64 (const std::string &aKey) const |
| int64_t | getInt64 (const std::string &aKey, int64_t aValue) const |
| uint64_t | getUint64 (const std::string &aKey) const |
| uint64_t | getUint64 (const std::string &aKey, uint64_t aValue) const |
| float | getFloat (const std::string &aKey) const |
| float | getFloat (const std::string &aKey, float aValue) const |
| double | getDouble (const std::string &aKey) const |
| double | getDouble (const std::string &aKey, double aValue) const |
| std::string | getString (const std::string &aKey) const |
| std::string | getString (const std::string &aKey, const std::string &aValue) const |
| time_t | getTime (const std::string &aKey) const |
| time_t | getTime (const std::string &aKey, const time_t &aValue) const |
| std::vector< bool > | getBoolVector (const std::string &aKey, bool expandable) const |
| std::vector< bool > | getBoolVector (const std::string &aKey, const std::vector< bool > &aValue, bool expandable) const |
| std::vector< int > | getIntVector (const std::string &aKey, bool expandable) const |
| std::vector< int > | getIntVector (const std::string &aKey, const std::vector< int > &aValue, bool expandable) const |
| std::vector< unsigned int > | getUintVector (const std::string &aKey, bool expandable) const |
| std::vector< unsigned int > | getUintVector (const std::string &aKey, const std::vector< unsigned int > &aValue, bool expandable) const |
| std::vector< int16_t > | getInt16Vector (const std::string &aKey, bool expandable) const |
| std::vector< int16_t > | getInt16Vector (const std::string &aKey, const std::vector< int16_t > &aValue, bool expandable) const |
| std::vector< uint16_t > | getUint16Vector (const std::string &aKey, bool expandable) const |
| std::vector< uint16_t > | getUint16Vector (const std::string &aKey, const std::vector< uint16_t > &aValue, bool expandable) const |
| std::vector< int32_t > | getInt32Vector (const std::string &aKey, bool expandable) const |
| std::vector< int32_t > | getInt32Vector (const std::string &aKey, const std::vector< int32_t > &aValue, bool expandable) const |
| std::vector< uint32_t > | getUint32Vector (const std::string &aKey, bool expandable) const |
| std::vector< uint32_t > | getUint32Vector (const std::string &aKey, const std::vector< uint32_t > &aValue, bool expandable) const |
| std::vector< int64_t > | getInt64Vector (const std::string &aKey, bool expandable) const |
| std::vector< int64_t > | getInt64Vector (const std::string &aKey, const std::vector< int64_t > &aValue, bool expandable) const |
| std::vector< uint64_t > | getUint64Vector (const std::string &aKey, bool expandable) const |
| std::vector< uint64_t > | getUint64Vector (const std::string &aKey, const std::vector< uint64_t > &aValue, bool expandable) const |
| std::vector< float > | getFloatVector (const std::string &aKey, bool expandable) const |
| std::vector< float > | getFloatVector (const std::string &aKey, const std::vector< float > &aValue, bool expandable) const |
| std::vector< double > | getDoubleVector (const std::string &aKey, bool expandable) const |
| std::vector< double > | getDoubleVector (const std::string &aKey, const std::vector< double > &aValue, bool expandable) const |
| std::vector< std::string > | getStringVector (const std::string &aKey, bool expandable) const |
| std::vector< std::string > | getStringVector (const std::string &aKey, const std::vector< std::string > &aValue, bool expandable) const |
| std::vector< time_t > | getTimeVector (const std::string &aKey, bool expandable) const |
| std::vector< time_t > | getTimeVector (const std::string &aKey, const std::vector< time_t > &aValue, bool expandable) const |
Friends | |
Printing | |
Mostly for debug purposes the collection can be printed. | |
| std::ostream & | operator<< (std::ostream &os, const ParameterSetImpl &thePS) |
Implements a map of Key-Value pairs. Description of class. The ParameterSetImpl class is a key-value implementation of the type map<string, string, KeyCompare>. This means that values are stored as a string which allows easy merging and splitting of ParameterSetImpls because no conversions have to be done. A couple of getXxx routines are provided to convert the strings to the desired type.
It keeps track of the keys being asked for. Unused keys might mean that their names were misspelled. The class is fully thread-safe.
| typedef KVMap::const_iterator dp3::common::ParameterSetImpl::const_iterator |
| typedef KVMap::iterator dp3::common::ParameterSetImpl::iterator |
|
explicit |
Create an empty collection. The argument mode determines how keys should be compared.
| dp3::common::ParameterSetImpl::~ParameterSetImpl | ( | ) |
Destroy the contents.
|
explicit |
Construct a ParameterSet from the contents of theFilename. The argument mode determines how keys should be compared.
| void dp3::common::ParameterSetImpl::add | ( | const std::string & | aKey, |
| const ParameterValue & | aValue | ||
| ) |
Add the given pair to the collection. When the aKey already exist in the collection an exception is thrown.
| void dp3::common::ParameterSetImpl::adoptArguments | ( | const std::vector< std::string > & | arguments | ) |
Adds the Key-Values pairs in the argument list. It ignores arguments not having the Key=Value syntax.
| void dp3::common::ParameterSetImpl::adoptBuffer | ( | const std::string & | theBuffer, |
| const std::string & | thePrefix = "" |
||
| ) |
Adds the Key-Values pair in the given buffer to the current collection. Each key will be prefixed with the optional argument thePrefix.
| void dp3::common::ParameterSetImpl::adoptCollection | ( | const ParameterSetImpl & | theCollection, |
| const std::string & | thePrefix = "" |
||
| ) |
Adds the Key-Values pair in the given collection to the current collection. Each key will be prefixed with the optional argument thePrefix.
| void dp3::common::ParameterSetImpl::adoptFile | ( | const std::string & | theFilename, |
| const std::string & | thePrefix = "" |
||
| ) |
Adds the Key-Values pair in the given file to the current collection. Each key will be prefixed with the optional argument thePrefix.
| std::string dp3::common::ParameterSetImpl::fullModuleName | ( | const std::string & | shortName | ) | const |
Searches the module name or module hierarchy and returns its fullposition. e.g: a.b.c.d.param=xxxx --> fullModuleName(d)-->a.b.c.d e.g: a.b.c.d.param=xxxx --> fullModuleName(b.c)-->a.b.c
|
inline |
Get the ParameterValue.
|
inline |
Return scalar value.
|
inline |
| std::vector<bool> dp3::common::ParameterSetImpl::getBoolVector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
Return vector of values.
| std::vector<bool> dp3::common::ParameterSetImpl::getBoolVector | ( | const std::string & | aKey, |
| const std::vector< bool > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
| std::vector<double> dp3::common::ParameterSetImpl::getDoubleVector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<double> dp3::common::ParameterSetImpl::getDoubleVector | ( | const std::string & | aKey, |
| const std::vector< double > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
| std::vector<float> dp3::common::ParameterSetImpl::getFloatVector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<float> dp3::common::ParameterSetImpl::getFloatVector | ( | const std::string & | aKey, |
| const std::vector< float > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
| std::vector<int16_t> dp3::common::ParameterSetImpl::getInt16Vector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<int16_t> dp3::common::ParameterSetImpl::getInt16Vector | ( | const std::string & | aKey, |
| const std::vector< int16_t > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
| std::vector<int32_t> dp3::common::ParameterSetImpl::getInt32Vector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<int32_t> dp3::common::ParameterSetImpl::getInt32Vector | ( | const std::string & | aKey, |
| const std::vector< int32_t > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
| std::vector<int64_t> dp3::common::ParameterSetImpl::getInt64Vector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<int64_t> dp3::common::ParameterSetImpl::getInt64Vector | ( | const std::string & | aKey, |
| const std::vector< int64_t > & | aValue, | ||
| bool | expandable | ||
| ) | const |
| std::vector<int> dp3::common::ParameterSetImpl::getIntVector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<int> dp3::common::ParameterSetImpl::getIntVector | ( | const std::string & | aKey, |
| const std::vector< int > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
| std::vector<std::string> dp3::common::ParameterSetImpl::getStringVector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<std::string> dp3::common::ParameterSetImpl::getStringVector | ( | const std::string & | aKey, |
| const std::vector< std::string > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
Returns the value as a time value (seconds since 1970).
|
inline |
| std::vector<time_t> dp3::common::ParameterSetImpl::getTimeVector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<time_t> dp3::common::ParameterSetImpl::getTimeVector | ( | const std::string & | aKey, |
| const std::vector< time_t > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
| std::vector<uint16_t> dp3::common::ParameterSetImpl::getUint16Vector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<uint16_t> dp3::common::ParameterSetImpl::getUint16Vector | ( | const std::string & | aKey, |
| const std::vector< uint16_t > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
| std::vector<uint32_t> dp3::common::ParameterSetImpl::getUint32Vector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<uint32_t> dp3::common::ParameterSetImpl::getUint32Vector | ( | const std::string & | aKey, |
| const std::vector< uint32_t > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
|
inline |
| std::vector<uint64_t> dp3::common::ParameterSetImpl::getUint64Vector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<uint64_t> dp3::common::ParameterSetImpl::getUint64Vector | ( | const std::string & | aKey, |
| const std::vector< uint64_t > & | aValue, | ||
| bool | expandable | ||
| ) | const |
| std::vector<unsigned int> dp3::common::ParameterSetImpl::getUintVector | ( | const std::string & | aKey, |
| bool | expandable | ||
| ) | const |
| std::vector<unsigned int> dp3::common::ParameterSetImpl::getUintVector | ( | const std::string & | aKey, |
| const std::vector< unsigned int > & | aValue, | ||
| bool | expandable | ||
| ) | const |
|
inline |
Checks if the given Key is defined in the ParameterSetImpl.
|
inline |
Return the key comparison mode.
| std::string dp3::common::ParameterSetImpl::locateModule | ( | const std::string & | shortName | ) | const |
Searches for a module whose name end in the given modulename. e.g: a.b.c.d.param=xxx ; locateModule('d') --> 'a.b.c.'
| std::shared_ptr<ParameterSetImpl> dp3::common::ParameterSetImpl::makeSubset | ( | const std::string & | baseKey, |
| const std::string & | prefix = "" |
||
| ) | const |
Creates a subset from the current ParameterSetImpl containing all parameters starting with the given baseKey. The baseKey is cut off from the Keynames in the created subset, the optional prefix is put before all keys in the subset.
| void dp3::common::ParameterSetImpl::remove | ( | const std::string & | aKey | ) |
Removes the pair with the given key. Removing a non-existing key is ok.
| void dp3::common::ParameterSetImpl::replace | ( | const std::string & | aKey, |
| const ParameterValue & | aValue | ||
| ) |
Replaces the given pair in the collection. If aKey does not exist in the collection the pair is just added to the collection.
| void dp3::common::ParameterSetImpl::subtractSubset | ( | const std::string & | fullPrefix | ) |
Subtract a subset from the current ParameterSet. Every parameter whose key starts with the given name will be removed from the ParameterSet.
| std::vector<std::string> dp3::common::ParameterSetImpl::unusedKeys | ( | ) | const |
Get all unused parameter names.
| void dp3::common::ParameterSetImpl::writeBuffer | ( | std::string & | theBuffer | ) | const |
Writes the Key-Values pair from the current ParCollection to the string buffer.
| void dp3::common::ParameterSetImpl::writeFile | ( | const std::string & | theFilename, |
| bool | append = false |
||
| ) | const |
Writes the Key-Values pair from the current ParCollection to the file.
| void dp3::common::ParameterSetImpl::writeStream | ( | std::ostream & | os | ) | const |
Write the Key-Value pairs from the current ParCollection to the output stream.
|
friend |