1 #ifndef _ots_DataStructs_h
2 #define _ots_DataStructs_h
4 #include "otsdaq/Macros/CoutMacros.h"
11 template<
typename N,
typename V>
15 Parameter(N name, V value) : name_(name), value_(value) { ; }
18 const N& getName(
void)
const {
return name_; }
19 const V& getValue(
void)
const {
return value_; }
20 const std::pair<N, V> getParameterPair(
void) {
return std::pair<N, V>(name_, value_); }
23 void setName(
const N name) { name_ = name; }
24 void setValue(
const V value) { value_ = value; }
25 void set(
const N name,
const V& value)
30 void set(std::pair<N, V> parameter)
32 name_ = parameter.first;
33 value_ = parameter.second;
41 template<
typename N,
typename V>
45 typedef std::map<N, V> ParameterMap;
46 typedef typename ParameterMap::iterator iterator;
47 typedef typename ParameterMap::const_iterator const_iterator;
50 Parameters(N name, V value) { addParameter(name, value); }
54 std::set<N> getNames(
void)
const
57 for(const_iterator it = theParameters_.begin(); it != theParameters_.end(); it++)
58 names.insert(it->first);
61 const V& getValue(
const N name)
const
63 auto it = theParameters_.find(name);
64 if(it == theParameters_.end())
66 __SS__ <<
"Parameter '" << name <<
"' not found!" << __E__;
74 void addParameter(
const N name,
const V value) { theParameters_[name] = value; }
75 void addParameter(
const Parameter<N, V> parameter) { theParameters_[parameter.getName()] = parameter.getValue(); }
76 void addParameter(
const std::pair<N, V> parameterPair) { theParameters_[parameterPair.first] = parameterPair.second; }
79 iterator begin(
void) {
return theParameters_.begin(); }
80 iterator end(
void) {
return theParameters_.end(); }
81 const_iterator begin(
void)
const {
return theParameters_.begin(); }
82 const_iterator end(
void)
const {
return theParameters_.end(); }
83 iterator find(N name) {
return theParameters_.find(name); }
84 const_iterator find(N name)
const {
return theParameters_.find(name); }
87 unsigned int size(
void)
const {
return theParameters_.size(); }
88 void clear(
void) { theParameters_.clear(); }
91 ParameterMap theParameters_;