SourceXtractorPlusPlus  0.16
Please provide a description of the project.
BasicParameter.h
Go to the documentation of this file.
1 
23 #ifndef MODELFITTING_BASICPARAMETER_H
24 #define MODELFITTING_BASICPARAMETER_H
25 
26 #include <functional> // for std::function of the parameter observer
27 #include <map> // for std::map
28 #include <memory>
29 
30 namespace ModelFitting {
31 
44 
45 public:
46 
47  /*
48  * Observers are functions
49  */
50  using ParameterObserver = std::function<void(double)>;
51 
52  virtual ~BasicParameter();
53 
54  BasicParameter(const BasicParameter&) = delete;
58 
59  /*
60  * @brief Getter to access the private parameter value
61  */
62  virtual double getValue() const {
63  return m_value;
64  }
65 
73 
74  bool removeObserver(std::size_t id);
75 
76  bool isObserved() const;
77 
78 protected:
79  typedef std::function<void(void)> GetValueHook;
80 
82 
83  explicit BasicParameter(const double value) :
84  m_value(value) {
85  }
86 
87  /*
88  * @brief Setter for the new value, which also notify the
89  * observers, by calling them with the new value.
90  */
91  virtual void setValue(const double new_value);
92 
93 protected:
94  double m_value;
95 
96 private:
99 };
100 
101 }
102 
103 #endif /* MODELFITTING_BASICPARAMETER_H */
The parameter base class.
BasicParameter(const BasicParameter &)=delete
bool removeObserver(std::size_t id)
virtual void setValue(const double new_value)
BasicParameter(const double value)
std::function< void(double)> ParameterObserver
virtual double getValue() const
std::function< void(void)> GetValueHook
BasicParameter & operator=(const BasicParameter &)=delete
std::map< std::size_t, ParameterObserver > m_observer_map
BasicParameter(BasicParameter &&)=delete
std::size_t addObserver(ParameterObserver observer)
The addObserver method adding observer to the member list.
BasicParameter & operator=(BasicParameter &&)=delete