Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
utility::signals::BufferedSignalHub< ResultType, Signal > Class Template Reference

forward declaration for SignalHub More...

#include <BufferedSignalHub.hh>

Inheritance diagram for utility::signals::BufferedSignalHub< ResultType, Signal >:
Inheritance graph
[legend]

Public Types

typedef Super::Size Size
 
typedef std::vector< SignalBuffer
 
- Public Types inherited from utility::signals::SignalHub< ReturnType, Signal >
typedef platform::Size Size
 

Public Member Functions

 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...
 
- Public Member Functions inherited from utility::signals::SignalHub< ReturnType, Signal >
 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...
 
Link connect (MemFn fn, Ptr ptr)
 connect an observer's member function to this hub More...
 
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

void release_buffer ()
 release the signals in the buffer More...
 
bool signal_allowed (Signal const s) override
 is signal allowed to be passed? More...
 
- Protected Member Functions inherited from utility::signals::SignalHub< ReturnType, Signal >
Link connect (MemFn fn, Ptr ptr, LinkUnits &links) const
 connect an observer's member function to the given LinkUnits More...
 
bool disconnect (MemFn fn, Ptr ptr, LinkUnits &links) const
 disconnect an observer's member function from the given LinkUnits 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...
 
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...
 
LinkUnitslinkunits ()
 returns the list of LinkUnits More...
 

Private Types

typedef SignalHub< ReturnType,
Signal
Super
 

Private Member Functions

 BufferedSignalHub (BufferedSignalHub const &rval)
 disallow copy constructor More...
 
BufferedSignalHuboperator= (BufferedSignalHub const &rval)
 disallow copy assignment More...
 

Private Attributes

Buffer buffer_
 signal buffer, only used when hub is blocked and buffering More...
 
bool buffering_
 flag indicating blocked signals should be buffered More...
 

Additional Inherited Members

- Protected Types inherited from utility::signals::SignalHub< ReturnType, Signal >
typedef boost::function1
< ReturnType, Signal
Function
 
typedef std::vector< LinkUnitOPLinkUnits
 
typedef std::vector< LinkLinks
 

Detailed Description

template<typename ResultType, typename Signal>
class utility::signals::BufferedSignalHub< ResultType, Signal >

forward declaration for SignalHub

SignalHub capable of buffering while blocking.

This class is meant for use in implementations of the observer pattern that pass a single Signal object from the subject to its observers. Signals must be copyable to allow for buffering capability. An observer connects by binding one of its member functions to the BufferedSignalHub. 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 BufferedSignalHub< void, Signal > it's possible to bind the following:

However, using something like Signal & or Signal const as the template type will enforce references and/or const-ness.

Warning
BufferedSignalHub objects are not copyable.

Member Typedef Documentation

template<typename ResultType, typename Signal>
typedef std::vector< Signal > utility::signals::BufferedSignalHub< ResultType, Signal >::Buffer
template<typename ResultType, typename Signal>
typedef Super::Size utility::signals::BufferedSignalHub< ResultType, Signal >::Size
template<typename ResultType, typename Signal>
typedef SignalHub< ReturnType, Signal > utility::signals::BufferedSignalHub< ResultType, Signal >::Super
private

Constructor & Destructor Documentation

template<typename ResultType, typename Signal>
utility::signals::BufferedSignalHub< ResultType, Signal >::BufferedSignalHub ( )
inline

default constructor

template<typename ResultType, typename Signal>
utility::signals::BufferedSignalHub< ResultType, Signal >::~BufferedSignalHub ( )
inlineoverridedefault

default destructor

template<typename ResultType, typename Signal>
utility::signals::BufferedSignalHub< ResultType, Signal >::BufferedSignalHub ( BufferedSignalHub< ResultType, Signal > const &  rval)
private

disallow copy constructor

Member Function Documentation

template<typename ResultType, typename Signal>
void utility::signals::BufferedSignalHub< ResultType, Signal >::buffer ( )
inline

block signals and buffer them for release upon unblocking

template<typename ResultType, typename Signal>
Size utility::signals::BufferedSignalHub< ResultType, Signal >::buffer_size ( ) const
inline

number of signals left in the buffer

template<typename ResultType, typename Signal>
bool utility::signals::BufferedSignalHub< ResultType, Signal >::buffering ( ) const
inline

are signals being buffered?

template<typename ResultType, typename Signal>
void utility::signals::BufferedSignalHub< ResultType, Signal >::clear_buffer ( )
inline
template<typename ResultType, typename Signal>
BufferedSignalHub& utility::signals::BufferedSignalHub< ResultType, Signal >::operator= ( BufferedSignalHub< ResultType, Signal > const &  rval)
private

disallow copy assignment

template<typename ResultType, typename Signal>
void utility::signals::BufferedSignalHub< ResultType, Signal >::release_buffer ( )
inlineprotected

release the signals in the buffer

Referenced by utility::signals::BufferedSignalHub< ReturnType, Signal >::unblock().

template<typename ResultType, typename Signal>
bool utility::signals::BufferedSignalHub< ResultType, Signal >::signal_allowed ( Signal const  s)
inlineoverrideprotectedvirtual

is signal allowed to be passed?

If buffering is enabled, signal will be stored in buffer.

Returns
true if hub is not blocked, otherwise false

Reimplemented from utility::signals::SignalHub< ReturnType, Signal >.

template<typename ResultType, typename Signal>
void utility::signals::BufferedSignalHub< ResultType, Signal >::unblock ( )
inlineoverridevirtual

allow signals to be sent and release any signals that were buffered

Reimplemented from utility::signals::SignalHub< ReturnType, Signal >.

Member Data Documentation

template<typename ResultType, typename Signal>
Buffer utility::signals::BufferedSignalHub< ResultType, Signal >::buffer_
private
template<typename ResultType, typename Signal>
bool utility::signals::BufferedSignalHub< ResultType, Signal >::buffering_
private

The documentation for this class was generated from the following files: