![]() |
Rosetta
2021.07
|
forward declaration for SignalHub More...
#include <SignalHub.hh>
Public Types | |
typedef platform::Size | Size |
Public Member Functions | |
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... | |
virtual void | unblock () |
allow signals to be 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 Types | |
typedef boost::function1 < ReturnType, Signal > | Function |
typedef std::vector< LinkUnitOP > | LinkUnits |
typedef std::vector< Link > | Links |
Protected Member Functions | |
virtual bool | signal_allowed (Signal const ) |
is signal allowed to be passed? More... | |
virtual void | send_signal (Signal s) |
send signal to all observers 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 Member Functions | |
SignalHub (SignalHub const &rval) | |
disallow copy constructor More... | |
SignalHub & | operator= (SignalHub const &rval) |
disallow copy assignment More... | |
Private Attributes | |
LinkUnits | links_ |
links specifying connections to observers More... | |
bool | blocked_ |
flag blocking signals from being sent More... | |
bool | currently_sending_ |
flag indicating SignalHub is currently in the process of sending signals; e.g. true will prevent remove_invalid() from causing any reallocation of the links_ list by erasing elements More... | |
forward declaration for SignalHub
primary class for function based implementation of observer pattern
This class is meant for use in implementations of the observer pattern that pass a single Signal object from the subject to its observers. An observer connects by binding one of its member functions to the SignalHub. The member function must be a unary function taking the desired Signal as its argument. Binding functions that pass references and const Signals will be interpreted correctly even if only 'Signal' is given as the template type. For example, when using a SignalHub< void, Signal >
it's possible to bind the following:
void f( Signal )
void f( Signal const )
void f( Signal const & )
However, using something like Signal &
or Signal const
as the template type will enforce references and/or const-ness.
|
protected |
|
protected |
|
protected |
typedef platform::Size utility::signals::SignalHub< ResultType, Signal >::Size |
|
inline |
default constructor
|
inlinevirtual |
default destructor
|
private |
disallow copy constructor
|
inlineprotectedvirtual |
initiate an action after send (no-op in SignalHub)
Reimplemented in utility::signals::PausableSignalHub< ResultType, Signal >.
Referenced by utility::signals::SignalHub< ReturnType, Signal >::operator()().
|
inline |
block signals from being sent
|
inline |
are signals blocked?
|
inline |
clear all connections
|
inline |
connect an observer's member function to this hub
MemFn | unary member function |
fn | pointer to observer's member function |
ptr | pointer to observer object |
Referenced by utility::signals::SignalHub< ReturnType, Signal >::connect().
|
inlineprotected |
connect an observer's member function to the given LinkUnits
MemFn | unary member function |
fn | pointer to observer's member function |
ptr | pointer to observer object |
links | function object gets added to this set of LinkUnits |
|
inline |
return a copy of the list of links currently being managed by this SignalHub
|
inlineprotected |
deallocate function stored in a LinkUnit
Referenced by utility::signals::SignalHub< ReturnType, Signal >::disconnect(), and utility::signals::SignalHub< ReturnType, Signal >::invalidate_all().
|
inline |
disconnect an observer's member function from this hub
MemFn | unary member function |
fn | pointer to observer's member function |
ptr | pointer to observer object |
Referenced by utility::signals::SignalHub< ReturnType, Signal >::disconnect().
|
inlineprotected |
disconnect an observer's member function from the given LinkUnits
MemFn | unary member function |
fn | pointer to observer's member function |
ptr | pointer to observer object |
links | function object gets removed from this set of LinkUnits |
|
inlineprotected |
find a specific connection to this hub
Functor | unary functor storable in Function wrapper and equality comparable with Function wrapper, typically result of boost::bind() |
Referenced by utility::signals::SignalHub< ReturnType, Signal >::connect(), and utility::signals::SignalHub< ReturnType, Signal >::disconnect().
|
inlineprotected |
invalidate and destroy internals of all links
Referenced by utility::signals::SignalHub< ReturnType, Signal >::clear(), and utility::signals::SignalHub< ReturnType, Signal >::~SignalHub().
|
inlineprotected |
returns the list of LinkUnits
|
inline |
send signal to all observers connected to the hub
|
private |
disallow copy assignment
|
inline |
|
inlineprotected |
remove and destroy internals of invalid links
Referenced by utility::signals::SignalHub< ReturnType, Signal >::connect(), utility::signals::SignalHub< ReturnType, Signal >::disconnect(), utility::signals::SignalHub< ReturnType, Signal >::receive_linkunits_from(), utility::signals::SignalHub< ReturnType, Signal >::send(), and utility::signals::SignalHub< ReturnType, Signal >::size().
|
inlineprotected |
send signal to all links taking into account validity and local blocking
Referenced by utility::signals::SignalHub< ReturnType, Signal >::send_signal().
|
inlineprotectedvirtual |
send signal to all observers
Reimplemented in utility::signals::TokenHub< ResultType, Signal >.
Referenced by utility::signals::SignalHub< ReturnType, Signal >::operator()().
|
inlineprotectedvirtual |
is signal allowed to be passed?
Reimplemented in utility::signals::BufferedSignalHub< ResultType, Signal >, and utility::signals::BufferedSignalHub< ReturnType, Signal >.
Referenced by utility::signals::SignalHub< ReturnType, Signal >::operator()().
|
inline |
number of connections to the hub
|
inlinevirtual |
allow signals to be sent
Reimplemented in utility::signals::BufferedSignalHub< ResultType, Signal >, and utility::signals::BufferedSignalHub< ReturnType, Signal >.
|
private |
flag blocking signals from being sent
Referenced by utility::signals::SignalHub< ReturnType, Signal >::block(), utility::signals::SignalHub< ReturnType, Signal >::blocked(), utility::signals::SignalHub< ReturnType, Signal >::signal_allowed(), and utility::signals::SignalHub< ReturnType, Signal >::unblock().
|
mutableprivate |
flag indicating SignalHub is currently in the process of sending signals; e.g. true will prevent remove_invalid() from causing any reallocation of the links_ list by erasing elements
Referenced by utility::signals::SignalHub< ReturnType, Signal >::remove_invalid(), and utility::signals::SignalHub< ReturnType, Signal >::send().
|
mutableprivate |
links specifying connections to observers
Referenced by utility::signals::SignalHub< ReturnType, Signal >::clear(), utility::signals::SignalHub< ReturnType, Signal >::connect(), utility::signals::SignalHub< ReturnType, Signal >::current_links(), utility::signals::SignalHub< ReturnType, Signal >::disconnect(), utility::signals::SignalHub< ReturnType, Signal >::linkunits(), utility::signals::SignalHub< ReturnType, Signal >::receive_linkunits_from(), utility::signals::SignalHub< ReturnType, Signal >::send_signal(), utility::signals::SignalHub< ReturnType, Signal >::size(), and utility::signals::SignalHub< ReturnType, Signal >::~SignalHub().