16 #error no need to expose this header to Swig
20 #ifndef BORNAGAIN_SIM_FITTING_FITOBSERVER_H
21 #define BORNAGAIN_SIM_FITTING_FITOBSERVER_H
78 m_observers.emplace_back(
ObserverData(every_nth, observer));
84 for (
const auto& observer : m_observers) {
85 if (need_notify(observer.m_every_nth))
86 observer.m_observer(data);
95 for (
const auto& observer : m_observers)
96 observer.m_observer(data);
104 return m_notify_count == 0 || m_notify_count % every_nth == 0;
Defines common types for fitting library.
ObserverData(int every_nth, observer_t observer)
Contains collection of observers and call them at specified intervals. Each observer will be called a...
std::vector< ObserverData > m_observers
std::function< void(const T &)> observer_t
void notify(const T &data)
Notifies all observers at their personally specified intervals.
void addObserver(int every_nth, observer_t &&observer)
Adds observer to the list.
void notify_all(const T &data)
bool need_notify(int every_nth)