COOLFluiD
Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
|
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... | |
Connection * | connection (const std::string &name) |
Connection * | manage_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_t > | SignalPtr_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_t > | EventSigsStorage_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_t > | m_sig_begin_flush |
Signal used to raise events when flush() method is called. More... | |
EventSigsStorage_t | m_event_signals |
Event signals. More... | |
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:
SignalArgs
as parameters. The string is the name of event and the SignalArgs
is the signal to send when flushing the queue. Definition at line 45 of file NotificationQueue.hpp.
|
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.
|
private |
Boost shared pointer for a signal.
Definition at line 94 of file NotificationQueue.hpp.
|
private |
Typedef for event signals.
Definition at line 91 of file NotificationQueue.hpp.
|
private |
Typedef for flushing signal.
Definition at line 97 of file NotificationQueue.hpp.
Constructor.
root | The root component this class has to listen to. Cannot be null. |
Definition at line 19 of file NotificationQueue.cpp.
~NotificationQueue | ( | ) |
Desctructor.
Definition at line 30 of file NotificationQueue.cpp.
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.
name | Event name |
sender_path | Path 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.
name | The name of the event |
fcnt | Pointer to a method of NOTIFIER class. This method returns nothing and take a string and SignalArgs as parameters. |
receiver | The 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.
name | The event name. If empty, the number of all notifications if counted. |
name
is empty. Definition at line 48 of file NotificationQueue.cpp.
|
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.
|
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.
|
private |
Signal used to raise events when flush() method is called.
Definition at line 114 of file NotificationQueue.hpp.
Send comments to: COOLFluiD Web Admin |