COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Member Functions | Private Types | Private Attributes | List of all members
NotificationQueue Class Reference

Manages a notification queue. More...

#include <NotificationQueue.hpp>

Inherits ConnectionManager.

Public Member Functions

 NotificationQueue ()
 Constructor. More...
 
 ~NotificationQueue ()
 Desctructor. More...
 
void add_notification (SignalArgs &args)
 Adds a notification for the event if which name is specified. More...
 
cf3::Uint nb_notifications (const std::string &name=std::string()) const
 Counts the notifications for a speficied event. More...
 
void flush ()
 Flushes the notification buffer. More...
 
template<class NOTIFIER >
void add_notifier (const std::string &name, void(NOTIFIER::*fcnt)(const std::string &, SignalArgs &args), NOTIFIER *receiver)
 Adds a notifier. More...
 
template<class NOTIFIER >
void add_notifier (const std::string &name, void(NOTIFIER::*fcnt)(const std::string &, SignalArgs &), NOTIFIER *receiver)
 
- Public Member Functions inherited from ConnectionManager
 ~ConnectionManager ()
 destructor closes all connections More...
 
Connectionconnection (const std::string &name)
 
Connectionmanage_connection (const std::string &name)
 manages a connection (creates if necessary) More...
 

Private Types

typedef boost::signals2::signal< void(const std::string &, SignalArgs &) > SignalType_t
 Typedef for event signals. More...
 
typedef boost::shared_ptr< SignalType_tSignalPtr_t
 Boost shared pointer for a signal. More...
 
typedef boost::signals2::signal< void() > SignalTypeFlush_t
 Typedef for flushing signal. More...
 
typedef std::map< std::string, SignalPtr_tEventSigsStorage_t
 Typedef for the map that stores signals assigned to events. More...
 

Private Attributes

std::vector< std::pair< std::string, SignalArgs > > m_notifications
 Notification buffer. More...
 
boost::shared_ptr< SignalTypeFlush_tm_sig_begin_flush
 Signal used to raise events when flush() method is called. More...
 
EventSigsStorage_t m_event_signals
 Event signals. More...
 

Detailed Description

Manages a notification queue.

This class listens to a root component and records every emitted event. The flush method allows to emit all events to attached notifiers. Once flushed, all event are removed from the internal buffer.
Notifiers are external classes that register one or more of their methods to the queue. The notifier classes have to meet some constraints:

Definition at line 45 of file NotificationQueue.hpp.

Member Typedef Documentation

typedef std::map<std::string, SignalPtr_t> EventSigsStorage_t
private

Typedef for the map that stores signals assigned to events.

The key is the event name. The value is the corresponding signal, to which are connected notifiers.

Definition at line 103 of file NotificationQueue.hpp.

typedef boost::shared_ptr<SignalType_t> SignalPtr_t
private

Boost shared pointer for a signal.

Definition at line 94 of file NotificationQueue.hpp.

typedef boost::signals2::signal< void (const std::string&, SignalArgs&) > SignalType_t
private

Typedef for event signals.

Definition at line 91 of file NotificationQueue.hpp.

typedef boost::signals2::signal< void () > SignalTypeFlush_t
private

Typedef for flushing signal.

Definition at line 97 of file NotificationQueue.hpp.

Constructor & Destructor Documentation

Constructor.

Parameters
rootThe root component this class has to listen to. Cannot be null.

Definition at line 19 of file NotificationQueue.cpp.

Desctructor.

Definition at line 30 of file NotificationQueue.cpp.

Member Function Documentation

void add_notification ( SignalArgs args)

Adds a notification for the event if which name is specified.

If the event does not exist (i.e. it has never been emitted), it is created.

Parameters
nameEvent name
sender_pathPath of the component that emitted the event

Definition at line 37 of file NotificationQueue.cpp.

void add_notifier ( const std::string &  name,
void(NOTIFIER::*)(const std::string &, SignalArgs &args)  fcnt,
NOTIFIER *  receiver 
)

Adds a notifier.

Parameters
nameThe name of the event
fcntPointer to a method of NOTIFIER class. This method returns nothing and take a string and SignalArgs as parameters.
receiverThe object that will receive the event.
void add_notifier ( const std::string &  name,
void(NOTIFIER::*)(const std::string &, SignalArgs &)  fcnt,
NOTIFIER *  receiver 
)

Definition at line 127 of file NotificationQueue.hpp.

void flush ( )

Flushes the notification buffer.

Attached notifiers receive events they are registered for.

Definition at line 70 of file NotificationQueue.cpp.

cf3::Uint nb_notifications ( const std::string &  name = std::string()) const

Counts the notifications for a speficied event.

Parameters
nameThe event name. If empty, the number of all notifications if counted.
Returns
Returns the notifications count for the event, or the number of all notification if name is empty.

Definition at line 48 of file NotificationQueue.cpp.

Member Data Documentation

EventSigsStorage_t m_event_signals
private

Event signals.

The map stores all event names that are listened to by at least one notifier.

Definition at line 120 of file NotificationQueue.hpp.

std::vector< std::pair<std::string, SignalArgs> > m_notifications
private

Notification buffer.

For each pair, the first if the event name, and the second is the signal arguments.

Definition at line 111 of file NotificationQueue.hpp.

boost::shared_ptr< SignalTypeFlush_t > m_sig_begin_flush
private

Signal used to raise events when flush() method is called.

Definition at line 114 of file NotificationQueue.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin