Broadcasts events to registered listener functors.
More...
#include <_src_base_event.hh>
List of all members.
Detailed Description
template<typename EVENT = Void>
class base::Event< EVENT >
Broadcasts events to registered listener functors.
///
/// Overview:
/// ---------
/// This class provides a registry for listener functors.
/// Broadcast() calls every listener.
///
/// The purpose is similar to the Chain of Responsibility design pattern,
/// but listeners are not aware of a chain nor each other.
///
/// Usage and examples:
/// -------------------
/// In general, broadcasting should be done at the very beginning
/// or very end of a function to avoid inconsistent state.
/// Event objects are optional and are passed by value to listeners.
///
/// Event<> mEventReady;
/// Event<Message> mEventMessage;
///
/// class ReadyListener : public Event<>::ListenerFunctor
/// {
/// virtual void operator()( Void nothing ); // Void class substitutes for intrinsic void
/// };
///
/// class MessageListener : public Event<Message>::ListenerFunctor
/// {
/// virtual void operator()( Message msg );
/// };
///
/// mEvent.Listen( new ReadyListener ); // construct and pass functor to Listen()
/// mEvent.Listen( new MessageListener );
///
/// mEvent.Broadcast( Void() ); // template restriction: simply "Broadcast()" won't compile
///
///
Member Typedef Documentation
template<typename EVENT = Void>
Constructor & Destructor Documentation
template<typename EVENT = Void>
template<typename EVENT = Void>
Member Function Documentation
template<typename EVENT = Void>
| void base::Event< EVENT >::Broadcast |
( |
EVENT |
event |
) |
[inline] |
Broadcast an object to all listeners. If no arg exists, call as Broadcast( Void() ).
template<typename EVENT = Void>
template<typename EVENT = Void>
Member Data Documentation
template<typename EVENT = Void>
The documentation for this class was generated from the following file: