Simpatico
v1.10
|
Notifier (or subject) in the Observer design pattern.
A Signal manages a list of registered functor objects, and provides a void Signal<T>::notify(const T&) method that calls them all with the same argument.
The explicit specialization Signal<void>, or Signal<>, has a notify method void Signal<>::notify() that takes no parameters, which calls a method of each observer that takes no parameters.
#include <Signal.h>
Public Member Functions | |
Signal () | |
Default constructor. More... | |
~Signal () | |
Destructor. More... | |
template<class Observer > | |
void | addObserver (Observer &observer, void(Observer::*methodPtr)(const T &)) |
Register an observer. More... | |
void | clear () |
Clear all observerse from list. More... | |
int | nObserver () const |
Get number of registered observers. More... | |
void | notify (const T &t) |
Notify all observers. More... | |
|
inline |
Default constructor.
Definition at line 48 of file Signal.h.
References Util::Signal< T >::addObserver(), Util::Signal< T >::clear(), Util::Signal< T >::nObserver(), Util::Signal< T >::notify(), and Util::Signal< T >::~Signal().
Referenced by Util::Signal< void >::Signal().
Util::Signal< T >::~Signal | ( | ) |
Destructor.
Definition at line 16 of file Signal.cpp.
Referenced by Util::Signal< T >::Signal(), and Util::Signal< void >::Signal().
void Util::Signal< T >::addObserver | ( | Observer & | observer, |
void(Observer::*)(const T &) | methodPtr | ||
) |
Register an observer.
observer | observer object (invokes method) |
methodPtr | pointer to relevant method |
Definition at line 111 of file Signal.h.
References Util::Signal< T >::clear(), Util::Signal< T >::nObserver(), and Util::Signal< T >::notify().
Referenced by McMd::McSystem::McSystem(), McMd::MdSystem::MdSystem(), Util::Signal< T >::Signal(), and Util::Signal< void >::Signal().
void Util::Signal< T >::clear | ( | ) |
Clear all observerse from list.
Definition at line 36 of file Signal.cpp.
Referenced by Util::Signal< T >::addObserver(), Util::Signal< T >::Signal(), and Util::Signal< void >::Signal().
int Util::Signal< T >::nObserver | ( | ) | const |
Get number of registered observers.
Definition at line 51 of file Signal.cpp.
Referenced by Util::Signal< T >::addObserver(), Util::Signal< T >::Signal(), and Util::Signal< void >::Signal().
void Util::Signal< T >::notify | ( | const T & | t | ) |
Notify all observers.
This method notifies all registered observers by calling the appropriate method of each observer, passing each the parameter t as argument. The explicit specialization Signal<>, with T=void, is used for notification methods that take
t | Argument passed to notification methods of all observers. |
Definition at line 22 of file Signal.cpp.
Referenced by Util::Signal< T >::addObserver(), DdMd::NvtIntegrator::integrateStep2(), DdMd::NphIntegrator::integrateStep2(), DdMd::NveIntegrator::integrateStep2(), DdMd::NptIntegrator::integrateStep2(), DdMd::NvtLangevinIntegrator::integrateStep2(), DdMd::TwoStepIntegrator::run(), McMd::NveVvIntegrator::setup(), McMd::NvtLangevinIntegrator::setup(), McMd::NvtDpdVvIntegrator::setup(), McMd::NvtNhIntegrator::setup(), McMd::NphIntegrator::setup(), Util::Signal< T >::Signal(), Util::Signal< void >::Signal(), McMd::McSimulation::simulate(), McMd::NveVvIntegrator::step(), McMd::NvtLangevinIntegrator::step(), McMd::NvtDpdVvIntegrator::step(), McMd::NvtNhIntegrator::step(), and McMd::NphIntegrator::step().