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 52 of file signal.hpp.

Member Typedef Documentation

◆ Handler

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 57 of file signal.hpp.

Constructor & Destructor Documentation

◆ Signal()

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

Definition at line 149 of file signal.hpp.

◆ ~Signal()

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

Definition at line 155 of file signal.hpp.

Member Function Documentation

◆ connect()

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 162 of file signal.hpp.

◆ connectSingleShot()

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 172 of file signal.hpp.