diff --git a/LCS/Common/include/Common/ParameterSet.h b/LCS/Common/include/Common/ParameterSet.h index 807320ccfbbd7fdf6478598a16cdbdb6f942fbf9..24bedbfbcb6fb28c3cb74e73c0812d70fe186621 100644 --- a/LCS/Common/include/Common/ParameterSet.h +++ b/LCS/Common/include/Common/ParameterSet.h @@ -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 { diff --git a/LCS/Common/src/ParameterSet.cc b/LCS/Common/src/ParameterSet.cc index 9af35b5936f5e395a3726b757750023966ed993e..23378b640d5e29e971bd15613e1374fb41d1b453 100644 --- a/LCS/Common/src/ParameterSet.cc +++ b/LCS/Common/src/ParameterSet.cc @@ -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 diff --git a/LCS/Common/test/tParameterRecord.cc b/LCS/Common/test/tParameterRecord.cc index 2631ee0df4f6eb54d9be26e2da9252afbee46f63..6e1384301dc3aaed2d28e3dfc7eb02ccae1beac6 100644 --- a/LCS/Common/test/tParameterRecord.cc +++ b/LCS/Common/test/tParameterRecord.cc @@ -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()); diff --git a/LCS/Common/test/tParameterSet.cc b/LCS/Common/test/tParameterSet.cc index 0c8010e10a13a99499a230942730081980aa12f3..d473531adabaa049e40cf1a7464274c739b4c38e 100644 --- a/LCS/Common/test/tParameterSet.cc +++ b/LCS/Common/test/tParameterSet.cc @@ -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); {