Skip to content
Snippets Groups Projects
Commit 00807676 authored by Ger van Diepen's avatar Ger van Diepen
Browse files

Task #3116

Added and tested ParameterSet functions getVector and getRecord
parent b6e0d355
No related branches found
No related tags found
No related merge requests found
......@@ -217,6 +217,14 @@ public:
// e.g: a.b.c.d.param=xxxx --> fullModuleName(b.c)-->a.b.c
string fullModuleName(const string& shortName) const;
// Return the value of the key as a vector of values.
// This can only be done if the value is enclosed in square brackets.
vector<ParameterValue> getVector (const string& aKey) const;
// Return the value of the key as a parameter record.
// This can only be done if the value is enclosed in curly braces.
ParameterRecord getRecord (const string& aKey) const;
// Return scalar value.
// @{
bool getBool (const string& aKey) const;
......@@ -484,6 +492,11 @@ inline string ParameterSet::fullModuleName(const string& shortName) const
return (itsSet->fullModuleName(shortName));
}
inline vector<ParameterValue> ParameterSet::getVector (const string& aKey) const
{
return get(aKey).getVector();
}
//# getBool(key)
inline bool ParameterSet::getBool(const string& aKey) const
{
......
......@@ -25,6 +25,7 @@
#include <Common/ParameterSet.h>
#include <Common/ParameterRecord.h>
#include <Common/LofarLogger.h>
#include <Common/lofar_fstream.h>
......@@ -87,11 +88,11 @@ ParameterSet::ParameterSet(const ParameterSet& that)
ParameterSet&
ParameterSet::operator=(const ParameterSet& that)
{
if (this != &that) {
unlink();
itsSet = that.itsSet->incrCount();
}
return (*this);
if (this != &that) {
unlink();
itsSet = that.itsSet->incrCount();
}
return (*this);
}
//
......@@ -109,13 +110,19 @@ void ParameterSet::unlink()
}
}
ParameterRecord ParameterSet::getRecord (const string& aKey) const
{
return get(aKey).getRecord();
}
//
// operator<<
//
std::ostream& operator<< (std::ostream& os, const ParameterSet &thePS)
{
os << *thePS.itsSet;
return os;
os << *thePS.itsSet;
return os;
}
} // namespace LOFAR
......@@ -66,6 +66,12 @@ void testNested()
ASSERT (rec.getString("k2b") == "3");
ParameterValue pvkey (rec.get("key"));
ASSERT (pvkey.isRecord());
{
// Test ParameterSet::getRecord
ParameterRecord prkey (rec.getRecord("key"));
ASSERT (prkey.size() == 1);
ASSERT (prkey.isDefined("k1"));
}
ParameterRecord prkey (pvkey.getRecord());
ParameterValue pvk1 (prkey.get("k1"));
ASSERT (pvk1.isRecord());
......
......@@ -102,6 +102,7 @@ int doIt(KeyCompare::Mode mode)
ASSERT(myPS.getTime("Time", 15) == 15);
ASSERT(myPS.getTime("Time", 18000) == 18000);
ASSERT(myPS["emptyvec"].getVector().size() == 0);
ASSERT(myPS.getVector("emptyvec").size() == 0);
ASSERT(myPS.getUint32Vector("emptyvec").size() == 0);
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment