Rosetta
|
forward declaration for TokenHub More...
#include <TokenHub.hh>
Public Types | |
typedef Super::Size | Size |
![]() | |
typedef Super::Size | Size |
typedef std::vector< Signal > | Buffer |
![]() | |
typedef platform::Size | Size |
Public Member Functions | |
TokenHub () | |
default constructor More... | |
virtual | ~TokenHub () |
default destructor More... | |
Size | receive_tokens_from (TokenHub const &src) |
receive tokenized connections from source and remove them from source More... | |
Size | n_tokens () const |
number of tokenized connections More... | |
void | clear_tokens () |
clear only tokenized connections, will invalidate all tokens More... | |
template<typename MemFn , typename Ptr > | |
Link | connect_tokenize (MemFn fn, Ptr ptr) |
connect and tokenize an observer's member function More... | |
template<typename MemFn , typename Ptr > | |
bool | disconnect (MemFn fn, Ptr ptr) |
disconnect an observer's member function More... | |
template<typename MemFn , typename Ptr > | |
bool | disconnect_tokenize (MemFn fn, Ptr ptr) |
disconnect an observer's tokenized member function More... | |
![]() | |
BufferedSignalHub () | |
default constructor More... | |
~BufferedSignalHub () override=default | |
default destructor More... | |
void | buffer () |
block signals and buffer them for release upon unblocking More... | |
void | unblock () override |
allow signals to be sent and release any signals that were buffered More... | |
bool | buffering () const |
are signals being buffered? More... | |
void | clear_buffer () |
clear the buffer More... | |
Size | buffer_size () const |
number of signals left in the buffer More... | |
![]() | |
SignalHub () | |
default constructor More... | |
virtual | ~SignalHub () |
default destructor More... | |
void | operator() (Signal s) |
send signal to all observers connected to the hub More... | |
Size | size () const |
number of connections to the hub More... | |
void | block () |
block signals from being sent More... | |
bool | blocked () const |
are signals blocked? More... | |
void | clear () |
clear all connections More... | |
template<typename MemFn , typename Ptr > | |
Link | connect (MemFn fn, Ptr ptr) |
connect an observer's member function to this hub More... | |
template<typename MemFn , typename Ptr > | |
bool | disconnect (MemFn fn, Ptr ptr) |
disconnect an observer's member function from this hub More... | |
Size | receive_linkunits_from (SignalHub const &src) |
transfer linkunits from source to this SignalHub More... | |
Links | current_links () const |
return a copy of the list of links currently being managed by this SignalHub More... | |
Protected Member Functions | |
virtual void | send_signal (Signal s) |
send signal to both regular and tokenized connections More... | |
![]() | |
void | release_buffer () |
release the signals in the buffer More... | |
bool | signal_allowed (Signal const s) override |
is signal allowed to be passed? More... | |
![]() | |
virtual void | after_send () |
initiate an action after send (no-op in SignalHub) More... | |
template<typename MemFn , typename Ptr > | |
Link | connect (MemFn fn, Ptr ptr, LinkUnits &links) const |
connect an observer's member function to the given LinkUnits More... | |
template<typename MemFn , typename Ptr > | |
bool | disconnect (MemFn fn, Ptr ptr, LinkUnits &links) const |
disconnect an observer's member function from the given LinkUnits More... | |
template<typename Functor > | |
LinkUnits::iterator | find_connection (Functor f, LinkUnits &links) const |
find a specific connection to this hub More... | |
void | send (Signal s, LinkUnits &links) const |
send signal to all links taking into account validity and local blocking More... | |
void | invalidate_all (LinkUnits &links) const |
invalidate and destroy internals of all links More... | |
void | remove_invalid (LinkUnits &links) const |
remove and destroy internals of invalid links More... | |
void | deallocate (LinkUnit &lu) const |
deallocate function stored in a LinkUnit More... | |
LinkUnits & | linkunits () |
returns the list of LinkUnits More... | |
Private Types | |
typedef BufferedSignalHub< ReturnType, Signal > | Super |
typedef Super::LinkUnits | LinkUnits |
Private Member Functions | |
TokenHub (TokenHub const &rval) | |
disallow copy constructor More... | |
TokenHub & | operator= (TokenHub const &rval) |
disallow copy assignment More... | |
Private Attributes | |
LinkUnits | tokens_ |
tokenized observer function objects More... | |
Additional Inherited Members | |
![]() | |
typedef boost::function1< ReturnType, Signal > | Function |
typedef std::vector< LinkUnitOP > | LinkUnits |
typedef std::vector< Link > | Links |
forward declaration for TokenHub
BufferedSignalHub capable of passing observers.
If an observer's member function is connected with the 'tokenize' flag, then this function is allowed to permanently pass from a source TokenHub to a destination TokenHub via a call to receive_tokens_from()
, which will erase the observer function from the source hub. The observer member function, in effect, becomes a single token which is intended to be passed from Subject to Subject upon copy (see remarks in receive_tokens_from()
for different behavior in copy construct vs copy assign). Invalidating the Link will stop the token from being passed from Subject to Subject. Use the token ability with care, as it depends on the programmer to consistently do the right thing and make sure Observer and Subject(s) do not loose sync with each other. Observers that communicate via a tokenized member function are recommended to follow the following guidelines:
|
private |
typedef Super::Size utility::signals::TokenHub< ReturnType, Signal >::Size |
|
private |
|
inline |
default constructor
|
inlinevirtual |
default destructor
References utility::signals::SignalHub< ReturnType, Signal >::invalidate_all(), and utility::signals::TokenHub< ReturnType, Signal >::tokens_.
|
private |
disallow copy constructor
|
inline |
clear only tokenized connections, will invalidate all tokens
References utility::signals::SignalHub< ReturnType, Signal >::invalidate_all(), and utility::signals::TokenHub< ReturnType, Signal >::tokens_.
|
inline |
connect and tokenize an observer's member function
MemFn | unary member function |
fn | pointer to observer's member function |
ptr | pointer to observer object |
References utility::signals::SignalHub< ReturnType, Signal >::connect(), ptr(), and utility::signals::TokenHub< ReturnType, Signal >::tokens_.
|
inline |
disconnect an observer's member function
will search both regular and tokenized functions
MemFn | unary member function |
fn | pointer to observer's member function |
ptr | pointer to observer object |
References utility::signals::SignalHub< ReturnType, Signal >::disconnect(), kmeans_adaptive_kernel_density_bb_dependent_rotlib::fn, ptr(), and utility::signals::TokenHub< ReturnType, Signal >::tokens_.
Referenced by utility::signals::TokenHub< ReturnType, Signal >::disconnect_tokenize().
|
inline |
disconnect an observer's tokenized member function
fn | pointer to observer's member function |
ptr | pointer to observer object |
References utility::signals::TokenHub< ReturnType, Signal >::disconnect(), kmeans_adaptive_kernel_density_bb_dependent_rotlib::fn, ptr(), and utility::signals::TokenHub< ReturnType, Signal >::tokens_.
|
inline |
number of tokenized connections
References utility::signals::SignalHub< ReturnType, Signal >::remove_invalid(), and utility::signals::TokenHub< ReturnType, Signal >::tokens_.
|
private |
disallow copy assignment
|
inline |
receive tokenized connections from source and remove them from source
References utility::signals::SignalHub< ReturnType, Signal >::remove_invalid(), and utility::signals::TokenHub< ReturnType, Signal >::tokens_.
|
inlineprotectedvirtual |
send signal to both regular and tokenized connections
Reimplemented from utility::signals::SignalHub< ReturnType, Signal >.
References utility::signals::SignalHub< ReturnType, Signal >::linkunits(), utility::signals::SignalHub< ReturnType, Signal >::send(), and utility::signals::TokenHub< ReturnType, Signal >::tokens_.
|
mutableprivate |
tokenized observer function objects
Referenced by utility::signals::TokenHub< ReturnType, Signal >::clear_tokens(), utility::signals::TokenHub< ReturnType, Signal >::connect_tokenize(), utility::signals::TokenHub< ReturnType, Signal >::disconnect(), utility::signals::TokenHub< ReturnType, Signal >::disconnect_tokenize(), utility::signals::TokenHub< ReturnType, Signal >::n_tokens(), utility::signals::TokenHub< ReturnType, Signal >::receive_tokens_from(), utility::signals::TokenHub< ReturnType, Signal >::send_signal(), and utility::signals::TokenHub< ReturnType, Signal >::~TokenHub().