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

Remove unused and untested ParameterRecord::getRecursive

parent 7d3b2163
No related branches found
No related tags found
1 merge request!802Remove unused and untested ParameterRecord::getRecursive
Pipeline #38674 passed
......@@ -5,53 +5,25 @@
#include "ParameterRecord.h"
#include <cstdio>
#include <ostream>
#include <string>
namespace dp3 {
namespace common {
std::ostream& operator<<(std::ostream& os, const ParameterRecord& prec) {
std::ostream& operator<<(std::ostream& os, const ParameterRecord& record) {
bool first = true;
os << '{';
for (ParameterRecord::const_iterator iter = prec.begin(); iter != prec.end();
++iter) {
for (const std::pair<std::string, ParameterValue>& entry : record) {
if (first) {
first = false;
} else {
os << ", ";
}
os << '\'' << iter->first << "': " << iter->second;
os << '\'' << entry.first << "': " << entry.second;
}
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 dp3
// 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
#ifndef LOFAR_COMMON_PARAMETERRECORD_H
#define LOFAR_COMMON_PARAMETERRECORD_H
#ifndef DP3_COMMON_PARAMETERRECORD_H_
#define DP3_COMMON_PARAMETERRECORD_H_
#include "ParameterSet.h"
namespace dp3 {
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 {
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.
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