6 #ifndef LOFAR_COMMON_PARAMETERSETIMPL_H
7 #define LOFAR_COMMON_PARAMETERSETIMPL_H
37 typedef std::map<std::string, ParameterValue, KeyCompare>
KVMap;
89 const std::string& thePrefix =
"");
95 const std::string& thePrefix =
"");
101 const std::string& thePrefix =
"");
113 void writeFile(
const std::string& theFilename,
bool append =
false)
const;
134 const std::string& baseKey,
const std::string& prefix =
"")
const;
168 return (find(searchKey) != end());
182 bool getBool(
const std::string& aKey)
const;
183 bool getBool(
const std::string& aKey,
bool aValue)
const;
184 int getInt(
const std::string& aKey)
const;
185 int getInt(
const std::string& aKey,
int aValue)
const;
186 unsigned int getUint(
const std::string& aKey)
const;
187 unsigned int getUint(
const std::string& aKey,
unsigned int aValue)
const;
188 int16_t
getInt16(
const std::string& aKey)
const;
189 int16_t
getInt16(
const std::string& aKey, int16_t aValue)
const;
190 uint16_t
getUint16(
const std::string& aKey)
const;
191 uint16_t
getUint16(
const std::string& aKey, uint16_t aValue)
const;
192 int32_t
getInt32(
const std::string& aKey)
const;
193 int32_t
getInt32(
const std::string& aKey, int32_t aValue)
const;
194 uint32_t
getUint32(
const std::string& aKey)
const;
195 uint32_t
getUint32(
const std::string& aKey, uint32_t aValue)
const;
196 int64_t
getInt64(
const std::string& aKey)
const;
197 int64_t
getInt64(
const std::string& aKey, int64_t aValue)
const;
198 uint64_t
getUint64(
const std::string& aKey)
const;
199 uint64_t
getUint64(
const std::string& aKey, uint64_t aValue)
const;
200 float getFloat(
const std::string& aKey)
const;
201 float getFloat(
const std::string& aKey,
float aValue)
const;
202 double getDouble(
const std::string& aKey)
const;
203 double getDouble(
const std::string& aKey,
double aValue)
const;
204 std::string
getString(
const std::string& aKey)
const;
205 std::string
getString(
const std::string& aKey,
206 const std::string& aValue)
const;
209 time_t
getTime(
const std::string& aKey)
const;
210 time_t
getTime(
const std::string& aKey,
const time_t& aValue)
const;
217 bool expandable)
const;
219 const std::vector<bool>& aValue,
220 bool expandable)
const;
221 std::vector<int>
getIntVector(
const std::string& aKey,
bool expandable)
const;
223 const std::vector<int>& aValue,
224 bool expandable)
const;
226 bool expandable)
const;
228 const std::string& aKey,
const std::vector<unsigned int>& aValue,
229 bool expandable)
const;
231 bool expandable)
const;
233 const std::vector<int16_t>& aValue,
234 bool expandable)
const;
236 bool expandable)
const;
238 const std::vector<uint16_t>& aValue,
239 bool expandable)
const;
241 bool expandable)
const;
243 const std::vector<int32_t>& aValue,
244 bool expandable)
const;
246 bool expandable)
const;
248 const std::vector<uint32_t>& aValue,
249 bool expandable)
const;
251 bool expandable)
const;
253 const std::vector<int64_t>& aValue,
254 bool expandable)
const;
256 bool expandable)
const;
258 const std::vector<uint64_t>& aValue,
259 bool expandable)
const;
261 bool expandable)
const;
263 const std::vector<float>& aValue,
264 bool expandable)
const;
266 bool expandable)
const;
268 const std::vector<double>& aValue,
269 bool expandable)
const;
271 bool expandable)
const;
273 const std::string& aKey,
const std::vector<std::string>& aValue,
274 bool expandable)
const;
276 bool expandable)
const;
278 const std::vector<time_t>& aValue,
279 bool expandable)
const;
308 void readFile(
const std::string& theFile,
const std::string& prefix,
310 void readBuffer(
const std::string& theFile,
const std::string& prefix,
312 void readStream(std::istream& inputStream,
const std::string& prefix,
319 const_iterator findKV(
const std::string& aKey,
bool doThrow =
true)
const;
323 void addMerge(
const std::string& key,
const std::string& value,
bool merge);
326 void addUnlocked(
const std::string& aKey,
const ParameterValue& aValue);
329 void replaceUnlocked(
const std::string& aKey,
const ParameterValue& aValue);
334 mutable std::set<std::string> itsAskedParms;
336 mutable std::mutex itsMutex;
359 std::string
keyName(
const std::string& fullKeyName);
373 std::string
keyPart(
const std::string& parameterLine);
379 std::string
valuePart(
const std::string& parameterLine);
389 int32_t
indexValue(
const std::string& label,
const char indexMarker[2]);
394 const std::string& aKey)
const {
395 return findKV(aKey)->second;
399 return findKV(aKey)->second.getBool();
405 if (it == end())
return aValue;
406 return it->second.getBool();
410 return findKV(aKey)->second.getInt();
415 if (it == end())
return aValue;
416 return it->second.getInt();
420 return findKV(aKey)->second.getUint();
424 unsigned int aValue)
const {
426 if (it == end())
return aValue;
427 return it->second.getUint();
431 return findKV(aKey)->second.getInt16();
435 int16_t aValue)
const {
437 if (it == end())
return aValue;
438 return it->second.getInt16();
442 return findKV(aKey)->second.getUint16();
446 uint16_t aValue)
const {
448 if (it == end())
return aValue;
449 return it->second.getUint16();
453 return findKV(aKey)->second.getInt32();
457 int32_t aValue)
const {
459 if (it == end())
return aValue;
460 return it->second.getInt32();
464 return findKV(aKey)->second.getUint32();
468 uint32_t aValue)
const {
470 if (it == end())
return aValue;
471 return it->second.getUint32();
475 return findKV(aKey)->second.getInt64();
479 int64_t aValue)
const {
481 if (it == end())
return aValue;
482 return it->second.getInt64();
486 return findKV(aKey)->second.getUint64();
490 uint64_t aValue)
const {
492 if (it == end())
return aValue;
493 return it->second.getUint64();
497 return findKV(aKey)->second.getFloat();
501 float aValue)
const {
503 if (it == end())
return aValue;
504 return it->second.getFloat();
508 return findKV(aKey)->second.getDouble();
512 double aValue)
const {
514 if (it == end())
return aValue;
515 return it->second.getDouble();
519 return findKV(aKey)->second.getString();
523 const std::string& aKey,
const std::string& aValue)
const {
525 if (it == end())
return aValue;
526 return it->second.getString();
530 return findKV(aKey)->second.getTime();
534 const time_t& aValue)
const {
536 if (it == end())
return aValue;
537 return it->second.getTime();
Implements a map of Key-Value pairs. Description of class. The ParameterSetImpl class is a key-value ...
Definition: ParameterSetImpl.h:51
std::vector< int > getIntVector(const std::string &aKey, bool expandable) const
std::shared_ptr< ParameterSetImpl > makeSubset(const std::string &baseKey, const std::string &prefix="") const
std::vector< time_t > getTimeVector(const std::string &aKey, bool expandable) const
int32_t getInt32(const std::string &aKey) const
Definition: ParameterSetImpl.h:452
unsigned int getUint(const std::string &aKey) const
Definition: ParameterSetImpl.h:419
void add(const std::string &aKey, const ParameterValue &aValue)
bool isDefined(const std::string &searchKey) const
Checks if the given Key is defined in the ParameterSetImpl.
Definition: ParameterSetImpl.h:167
std::vector< float > getFloatVector(const std::string &aKey, const std::vector< float > &aValue, bool expandable) const
const ParameterValue & get(const std::string &aKey) const
Definition: ParameterSetImpl.h:393
void adoptCollection(const ParameterSetImpl &theCollection, const std::string &thePrefix="")
std::vector< uint32_t > getUint32Vector(const std::string &aKey, const std::vector< uint32_t > &aValue, bool expandable) const
~ParameterSetImpl()
Destroy the contents.
std::vector< uint32_t > getUint32Vector(const std::string &aKey, bool expandable) const
std::vector< int32_t > getInt32Vector(const std::string &aKey, bool expandable) const
std::vector< bool > getBoolVector(const std::string &aKey, bool expandable) const
std::vector< int16_t > getInt16Vector(const std::string &aKey, bool expandable) const
std::string fullModuleName(const std::string &shortName) const
std::vector< double > getDoubleVector(const std::string &aKey, const std::vector< double > &aValue, bool expandable) const
void writeBuffer(std::string &theBuffer) const
int16_t getInt16(const std::string &aKey) const
Definition: ParameterSetImpl.h:430
std::vector< std::string > unusedKeys() const
Get all unused parameter names.
uint16_t getUint16(const std::string &aKey) const
Definition: ParameterSetImpl.h:441
std::vector< time_t > getTimeVector(const std::string &aKey, const std::vector< time_t > &aValue, bool expandable) const
std::vector< int > getIntVector(const std::string &aKey, const std::vector< int > &aValue, bool expandable) const
std::vector< uint16_t > getUint16Vector(const std::string &aKey, const std::vector< uint16_t > &aValue, bool expandable) const
time_t getTime(const std::string &aKey) const
Definition: ParameterSetImpl.h:529
void replace(const std::string &aKey, const ParameterValue &aValue)
void writeStream(std::ostream &os) const
std::vector< uint16_t > getUint16Vector(const std::string &aKey, bool expandable) const
std::string getString(const std::string &aKey) const
Definition: ParameterSetImpl.h:518
std::vector< std::string > getStringVector(const std::string &aKey, bool expandable) const
void remove(const std::string &aKey)
Removes the pair with the given key. Removing a non-existing key is ok.
std::vector< unsigned int > getUintVector(const std::string &aKey, const std::vector< unsigned int > &aValue, bool expandable) const
std::vector< int64_t > getInt64Vector(const std::string &aKey, const std::vector< int64_t > &aValue, bool expandable) const
std::vector< bool > getBoolVector(const std::string &aKey, const std::vector< bool > &aValue, bool expandable) const
ParameterSetImpl(KeyCompare::Mode mode)
int getInt(const std::string &aKey) const
Definition: ParameterSetImpl.h:409
uint32_t getUint32(const std::string &aKey) const
Definition: ParameterSetImpl.h:463
void adoptBuffer(const std::string &theBuffer, const std::string &thePrefix="")
uint64_t getUint64(const std::string &aKey) const
Definition: ParameterSetImpl.h:485
void adoptArguments(const std::vector< std::string > &arguments)
int64_t getInt64(const std::string &aKey) const
Definition: ParameterSetImpl.h:474
void subtractSubset(const std::string &fullPrefix)
ParameterSetImpl(const std::string &theFilename, KeyCompare::Mode mode)
float getFloat(const std::string &aKey) const
Definition: ParameterSetImpl.h:496
std::vector< std::string > getStringVector(const std::string &aKey, const std::vector< std::string > &aValue, bool expandable) const
KVMap::iterator iterator
Definition: ParameterSetImpl.h:53
std::vector< double > getDoubleVector(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< unsigned int > getUintVector(const std::string &aKey, bool expandable) const
std::vector< float > getFloatVector(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
void adoptFile(const std::string &theFilename, const std::string &thePrefix="")
std::vector< int64_t > getInt64Vector(const std::string &aKey, bool expandable) const
KeyCompare::Mode keyCompareMode() const
Return the key comparison mode.
Definition: ParameterSetImpl.h:79
KVMap::const_iterator const_iterator
Definition: ParameterSetImpl.h:54
friend std::ostream & operator<<(std::ostream &os, const ParameterSetImpl &thePS)
void writeFile(const std::string &theFilename, bool append=false) const
Writes the Key-Values pair from the current ParCollection to the file.
std::vector< uint64_t > getUint64Vector(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
bool getBool(const std::string &aKey) const
Definition: ParameterSetImpl.h:398
std::string locateModule(const std::string &shortName) const
double getDouble(const std::string &aKey) const
Definition: ParameterSetImpl.h:507
The value of a parameter.
Definition: ParameterValue.h:24
std::string keyName(const std::string &fullKeyName)
common::stringtools::Compare KeyCompare
Definition: ParameterSetImpl.h:32
const char PC_QUAL_DEVELOP[]
Definition: ParameterSetImpl.h:28
std::string moduleName(const std::string &fullKeyName)
const char PC_KEY_VERSIONNR[]
Definition: ParameterSetImpl.h:29
std::map< std::string, ParameterValue, KeyCompare > KVMap
Definition: ParameterSetImpl.h:37
bool isValidVersionNr(const std::string &versionNr)
Checks if the given string is a valid versionnumber (x.y.z)
bool isValidVersionNrRef(const std::string &versionNr)
const char PC_QUAL_TEST[]
Definition: ParameterSetImpl.h:27
const char PC_KEY_QUAL[]
Definition: ParameterSetImpl.h:30
std::string keyPart(const std::string ¶meterLine)
const char PC_QUAL_STABLE[]
Implements a map of Key-Value pairs.
Definition: ParameterSetImpl.h:26
int32_t indexValue(const std::string &label, const char indexMarker[2])
std::string valuePart(const std::string ¶meterLine)
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53