template class utils::Notifier
Overview
A notifier is a mechanism to allow inter-object notifications. More…
#include <Notifier.h> template <typename... Args> class Notifier { public: // typedefs typedef std::function<void(Args...)> CallbackType; // methods void AddCallback(CallbackType callback); virtual void Notify(Args... args); bool HasCallback() const; protected: // fields std::vector<CallbackType> callbacks_; std::mutex notifier_access_; };
Detailed Documentation
A notifier is a mechanism to allow inter-object notifications.
Typedefs
typedef std::function<void(Args...)> CallbackType
The callback is a void function taking the variadic templated arguments of the Notifier class.
Fields
std::vector<CallbackType> callbacks_
The callbacks.
std::mutex notifier_access_
mutex to ensure thread safety.
Methods
void AddCallback(CallbackType callback)
Add a single callback function.
virtual void Notify(Args... args)
Send all notifications at this moment.
bool HasCallback() const
Returns whether it has any callback registered.