Rosetta 3.3
Public Types | Public Member Functions | Protected Member Functions
utility::signals::BufferedSignalHub< ReturnType, Signal > Class Template Reference

SignalHub capable of buffering while blocking. More...

#include <BufferedSignalHub.hh>

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

List of all members.

Public Types

typedef Super::Size Size
typedef std::vector< Signal > Buffer

Public Member Functions

 BufferedSignalHub ()
 default constructor
virtual ~BufferedSignalHub ()
 default destructor
void buffer ()
 block signals and buffer them for release upon unblocking
virtual void unblock ()
 allow signals to be sent and release any signals that were buffered
bool buffering () const
 are signals being buffered?
void clear_buffer ()
 clear the buffer
Size buffer_size () const
 number of signals left in the buffer

Protected Member Functions

void release_buffer ()
 release the signals in the buffer
virtual bool signal_allowed (Signal const s)
 is signal allowed to be passed?

Detailed Description

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

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 ReturnType , typename Signal >
typedef std::vector< Signal > utility::signals::BufferedSignalHub< ReturnType, Signal >::Buffer
template<typename ReturnType , typename Signal >
typedef Super::Size utility::signals::BufferedSignalHub< ReturnType, Signal >::Size

Constructor & Destructor Documentation

template<typename ReturnType , typename Signal >
utility::signals::BufferedSignalHub< ReturnType, Signal >::BufferedSignalHub ( ) [inline]

default constructor

template<typename ReturnType , typename Signal >
virtual utility::signals::BufferedSignalHub< ReturnType, Signal >::~BufferedSignalHub ( ) [inline, virtual]

default destructor


Member Function Documentation

template<typename ReturnType , typename Signal >
void utility::signals::BufferedSignalHub< ReturnType, Signal >::buffer ( ) [inline]

block signals and buffer them for release upon unblocking

References utility::signals::SignalHub< ReturnType, Signal >::block().

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

number of signals left in the buffer

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

are signals being buffered?

template<typename ReturnType , typename Signal >
void utility::signals::BufferedSignalHub< ReturnType, Signal >::clear_buffer ( ) [inline]
template<typename ReturnType , typename Signal >
void utility::signals::BufferedSignalHub< ReturnType, Signal >::release_buffer ( ) [inline, protected]
template<typename ReturnType , typename Signal >
virtual bool utility::signals::BufferedSignalHub< ReturnType, Signal >::signal_allowed ( Signal const  s) [inline, protected, virtual]

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 >.

References utility::signals::SignalHub< ReturnType, Signal >::blocked().

template<typename ReturnType , typename Signal >
virtual void utility::signals::BufferedSignalHub< ReturnType, Signal >::unblock ( ) [inline, virtual]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines