diff --git a/common/ParameterRecord.cc b/common/ParameterRecord.cc index a14e30f64b4ec8fe6e73015378e9698746c3412f..a108e03a6236bf7b17483c4e35db8fe6b149add7 100644 --- a/common/ParameterRecord.cc +++ b/common/ParameterRecord.cc @@ -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 diff --git a/common/ParameterRecord.h b/common/ParameterRecord.h index fd9b75c1558f1ac9a9e126ed8ac94eae9d18ab9e..89bd3e85a60c42ee7c8e25664c5014891cda82ca 100644 --- a/common/ParameterRecord.h +++ b/common/ParameterRecord.h @@ -1,29 +1,20 @@ // 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&); };