SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
BasicParameter.h
Go to the documentation of this file.
1
22
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
30namespace ModelFitting {
31
44
45public:
46
47 /*
48 * Observers are functions
49 */
50 using ParameterObserver = std::function<void(double)>;
51
52 virtual ~BasicParameter();
53
58
59 /*
60 * @brief Getter to access the private parameter value
61 */
62 virtual double getValue() const {
63 return m_value;
64 }
65
73
75
76 bool isObserved() const;
77
78protected:
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
93protected:
94 double m_value;
95
96private:
99};
100
101}
102
103#endif /* MODELFITTING_BASICPARAMETER_H */
BasicParameter(const BasicParameter &)=delete
bool removeObserver(std::size_t id)
virtual void setValue(const double new_value)
BasicParameter & operator=(BasicParameter &&)=delete
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.