Skip to content
Snippets Groups Projects
Commit ae0066a7 authored by Maik Nijhuis's avatar Maik Nijhuis
Browse files

Merge branch 'remove-parameterrecord-getrecursive' into 'master'

Remove unused and untested ParameterRecord::getRecursive

See merge request !802
parents 7d3b2163 186043e6
Branches
Tags
1 merge request!802Remove unused and untested ParameterRecord::getRecursive
Pipeline #38676 passed
...@@ -5,53 +5,25 @@ ...@@ -5,53 +5,25 @@
#include "ParameterRecord.h" #include "ParameterRecord.h"
#include <cstdio>
#include <ostream> #include <ostream>
#include <string>
namespace dp3 { namespace dp3 {
namespace common { namespace common {
std::ostream& operator<<(std::ostream& os, const ParameterRecord& prec) { std::ostream& operator<<(std::ostream& os, const ParameterRecord& record) {
bool first = true; bool first = true;
os << '{'; os << '{';
for (ParameterRecord::const_iterator iter = prec.begin(); iter != prec.end(); for (const std::pair<std::string, ParameterValue>& entry : record) {
++iter) {
if (first) { if (first) {
first = false; first = false;
} else { } else {
os << ", "; os << ", ";
} }
os << '\'' << iter->first << "': " << iter->second; os << '\'' << entry.first << "': " << entry.second;
} }
os << '}'; os << '}';
return os; return os;
} }
bool ParameterRecord::getRecursive(const std::string& key,
ParameterValue& value) const {
const_iterator iter = find(key);
if (iter != end()) {
value = iter->second;
return true;
}
// Try to find the key in possible ParmRecords.
// Strip the last part from the key.
std::string::size_type pos = key.rfind('.');
while (pos != std::string::npos) {
const_iterator iter = find(key.substr(0, pos));
if (iter != end()) {
ParameterValue pv(iter->second);
if (pv.isRecord() &&
pv.getRecord().getRecursive(key.substr(pos + 1), value)) {
return true;
}
}
if (pos == 0) return false;
pos = key.rfind('.', pos - 1);
}
return false;
}
} // namespace common } // namespace common
} // namespace dp3 } // namespace dp3
// ParameterRecord.h: A record of parameter values // ParameterRecord.h: A record of parameter values
// //
// Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy) // Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy)
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#ifndef LOFAR_COMMON_PARAMETERRECORD_H #ifndef DP3_COMMON_PARAMETERRECORD_H_
#define LOFAR_COMMON_PARAMETERRECORD_H #define DP3_COMMON_PARAMETERRECORD_H_
#include "ParameterSet.h" #include "ParameterSet.h"
namespace dp3 { namespace dp3 {
namespace common { namespace common {
/// \brief A record of parameter values /// \brief A record of parameter values.
/// The only difference with a ParameterSet is the output operator.
class ParameterRecord : public ParameterSet { class ParameterRecord : public ParameterSet {
public: public:
/// Define the iterators for this class.
typedef ParameterSet::iterator iterator;
typedef ParameterSet::const_iterator const_iterator;
/// Default constructor creates empty record.
ParameterRecord() {}
/// Try to get a value from the record or from a nested record.
bool getRecursive(const std::string& key, ParameterValue& value) const;
/// Put to ostream. /// Put to ostream.
friend std::ostream& operator<<(std::ostream& os, const ParameterRecord&); friend std::ostream& operator<<(std::ostream& os, const ParameterRecord&);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment