ndn::util::signal::Signal< Owner, TArgs > Class Template Reference

provides a lightweight signal / event system More...

#include <ndn-cxx/util/signal/signal.hpp>

+ Inheritance diagram for ndn::util::signal::Signal< Owner, TArgs >:
+ Collaboration diagram for ndn::util::signal::Signal< Owner, TArgs >:

Public Types

typedef function< void(const TArgs &...)> Handler
 represents a function that can connect to the signal More...
 

Public Member Functions

 Signal ()
 
 ~Signal ()
 
Connection connect (Handler handler)
 connects a handler to the signal More...
 
Connection connectSingleShot (Handler handler)
 connects a single-shot handler to the signal More...
 

Detailed Description

template<typename Owner, typename... TArgs>
class ndn::util::signal::Signal< Owner, TArgs >

provides a lightweight signal / event system

To declare a signal: public: Signal<Owner, T1, T2> signalName; To connect to a signal: owner->signalName.connect(f); Multiple functions can connect to the same signal. To emit a signal from owner: this->signalName(arg1, arg2);

Template Parameters
Ownerthe signal owner class; only this class can emit the signal
TArgstypes of signal arguments
See also
signal-emit.hpp allows owner's derived classes to emit signals

Definition at line 51 of file signal.hpp.

Member Typedef Documentation

template<typename Owner, typename... TArgs>
typedef function<void(const TArgs&...)> ndn::util::signal::Signal< Owner, TArgs >::Handler

represents a function that can connect to the signal

Definition at line 56 of file signal.hpp.

Constructor & Destructor Documentation

template<typename Owner , typename... TArgs>
ndn::util::signal::Signal< Owner, TArgs >::Signal ( )

Definition at line 152 of file signal.hpp.

template<typename Owner , typename... TArgs>
ndn::util::signal::Signal< Owner, TArgs >::~Signal ( )

Definition at line 158 of file signal.hpp.

Member Function Documentation

template<typename Owner , typename... TArgs>
Connection ndn::util::signal::Signal< Owner, TArgs >::connect ( Handler  handler)

connects a handler to the signal

Note
If invoked from a handler, the new handler won't receive the current emitted signal.
Warning
The handler is permitted to disconnect itself, but it must ensure its validity.

Definition at line 165 of file signal.hpp.

template<typename Owner , typename... TArgs>
Connection ndn::util::signal::Signal< Owner, TArgs >::connectSingleShot ( Handler  handler)

connects a single-shot handler to the signal

After the handler is executed once, it is automatically disconnected.

Definition at line 175 of file signal.hpp.