CMS 3D CMS Logo

FWGenericParameter.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWGenericParameter_h
2 #define Fireworks_Core_FWGenericParameter_h
3 // -*- C++ -*-
4 //
5 // Package: Core
6 // Class : FWBoolParameter
7 //
15 //
16 // Original Author: Chris Jones
17 // Created: Fri Mar 7 14:36:34 EST 2008
18 //
19 
20 // system include files
21 #include <sigc++/signal.h>
22 #include <sstream>
23 
24 // user include files
27 
28 // forward declarations
29 
30 template <class T>
32 public:
33  typedef T value_type;
34 
35  FWGenericParameter() : FWParameterBase(nullptr, "invalid") {}
36 
37  FWGenericParameter(FWParameterizable* iParent, const std::string& iName, const T& iDefault = T())
38  : FWParameterBase(iParent, iName), m_value(iDefault) {}
39 
40  template <class K>
41  FWGenericParameter(FWParameterizable* iParent, const std::string& iName, K iCallback, const T& iDefault = T())
42  : FWParameterBase(iParent, iName), m_value(iDefault) {
43  changed_.connect(iCallback);
44  }
45 
46  //virtual ~FWBoolParameter();
47 
48  // ---------- const member functions ---------------------
49 
50  T value() const { return m_value; }
51 
52  void addTo(FWConfiguration& iTo) const override {
53  std::ostringstream s;
54  s << m_value;
55  iTo.addKeyValue(name(), FWConfiguration(s.str()));
56  }
57 
58  // ---------- static member functions --------------------
59 
60  // ---------- member functions ---------------------------
61 
62  void setFrom(const FWConfiguration& iFrom) override {
63  if (const FWConfiguration* config = iFrom.valueForKey(name())) {
64  std::istringstream s(config->value());
65  s >> m_value;
66  }
68  }
69 
70  void set(T iValue) {
71  m_value = iValue;
72  changed_(iValue);
73  }
74 
75  sigc::signal<void, T> changed_;
76 
77 private:
78  FWGenericParameter(const FWGenericParameter&) = delete; // stop default
79  const FWGenericParameter& operator=(const FWGenericParameter&) = delete; // stop default
80 
81  // ---------- member data --------------------------------
82 
84 };
85 
86 #endif
FWGenericParameter::value_type
T value_type
Definition: FWGenericParameter.h:33
FWGenericParameter::m_value
T m_value
Definition: FWGenericParameter.h:83
FWParameterBase
Definition: FWParameterBase.h:31
FWGenericParameter::addTo
void addTo(FWConfiguration &iTo) const override
Definition: FWGenericParameter.h:52
FWGenericParameter::set
void set(T iValue)
Definition: FWGenericParameter.h:70
FWGenericParameter::FWGenericParameter
FWGenericParameter(FWParameterizable *iParent, const std::string &iName, K iCallback, const T &iDefault=T())
Definition: FWGenericParameter.h:41
FWGenericParameter
Definition: FWGenericParameter.h:31
config
Definition: config.py:1
FWParameterBase.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
FWGenericParameter::changed_
sigc::signal< void, T > changed_
Definition: FWGenericParameter.h:75
FWConfiguration::valueForKey
const FWConfiguration * valueForKey(const std::string &iKey) const
Definition: FWConfiguration.cc:122
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWGenericParameter::setFrom
void setFrom(const FWConfiguration &iFrom) override
Definition: FWGenericParameter.h:62
FWParameterizable
Definition: FWParameterizable.h:29
FWParameterBase::name
const std::string & name() const
Definition: FWParameterBase.h:39
FWGenericParameter::operator=
const FWGenericParameter & operator=(const FWGenericParameter &)=delete
FWGenericParameter::value
T value() const
Definition: FWGenericParameter.h:50
FWConfiguration::addKeyValue
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
Definition: FWConfiguration.cc:58
T
long double T
Definition: Basic3DVectorLD.h:48
FWGenericParameter::FWGenericParameter
FWGenericParameter()
Definition: FWGenericParameter.h:35
FWGenericParameter::FWGenericParameter
FWGenericParameter(FWParameterizable *iParent, const std::string &iName, const T &iDefault=T())
Definition: FWGenericParameter.h:37
FWConfiguration
Definition: FWConfiguration.h:31
FWConfiguration.h