File indexing completed on 2024-04-06 12:01:58
0001 #ifndef ConfObject_h
0002 #define ConfObject_h
0003
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005
0006 #include <iostream>
0007 #include <vector>
0008 #include <map>
0009 #include <algorithm>
0010 #include <iterator>
0011 #include <sstream>
0012
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 class ConfObject {
0030 public:
0031 ConfObject() {}
0032
0033 template <class valueType>
0034 bool put(const std::string& name, const valueType& inputValue) {
0035 std::stringstream ss;
0036 ss << inputValue;
0037 if (parameters.insert(std::make_pair(name, ss.str())).second)
0038 return true;
0039 return false;
0040 }
0041
0042 template <class valueType>
0043 valueType get(const std::string& name) const {
0044 valueType returnValue;
0045 parMap::const_iterator it = parameters.find(name);
0046 std::stringstream ss;
0047 if (it != parameters.end()) {
0048 ss << it->second;
0049 ss >> returnValue;
0050 } else {
0051 std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
0052 }
0053 return returnValue;
0054 }
0055
0056 bool isParameter(const std::string& name) const { return (parameters.find(name) != parameters.end()); }
0057
0058
0059 void printSummary(std::stringstream& ss) const;
0060
0061 void printDebug(std::stringstream& ss) const;
0062
0063 typedef std::map<std::string, std::string> parMap;
0064
0065 parMap parameters;
0066
0067 COND_SERIALIZABLE;
0068 };
0069
0070 #endif