15 #ifndef BORNAGAIN_CORE_FITTING_FITOBSERVER_H
16 #define BORNAGAIN_CORE_FITTING_FITOBSERVER_H
66 m_observers.push_back(
ObserverData(every_nth, observer));
71 for (
const auto& observer : m_observers) {
72 if (need_notify(observer.m_every_nth))
73 observer.m_observer(data);
81 for (
const auto& observer : m_observers)
82 observer.m_observer(data);
89 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.
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 notify_all(const T &data)
void addObserver(int every_nth, observer_t observer)
Adds observer to the list.
bool need_notify(int every_nth)