Base class for dispatcher in observer pattern. More...
#include <Dispatcher.hxx>
Public Member Functions | |
virtual void | dispatch (Node *object, const std::string &event) |
virtual void | dispatch2 (Node *object, const std::string &event, void *something) |
virtual void | addObserver (Observer *observer, Node *object, const std::string &event) |
virtual void | removeObserver (Observer *observer, Node *object, const std::string &event) |
virtual void | printObservers () |
virtual | ~Dispatcher () |
Static Public Member Functions | |
static Dispatcher * | getDispatcher () |
static void | setDispatcher (Dispatcher *dispatcher) |
Protected Attributes | |
std::map< std::pair< Node *, std::string >, std::set < Observer * > > | _observers |
Static Protected Attributes | |
static Dispatcher * | _singleton = 0 |
Base class for dispatcher in observer pattern.
Dispatcher and Observer objects can be used to be notified about events that occurs in editing or executing a calculation schema.
When an object wants to notify an event, it calls the dispatch method of the dispatcher with 2 arguments : the object reference and an event type. The dispatcher which is a singleton is obtained by calling the class method getDispatcher. The dispatcher notifies all the registered observers by calling their notifyObserver method.
Observers can be registered by calling the addObserver method with two arguments : an object reference and an event type. This observer will be notify with events coming only from this object.
Limitation : emitting objects can be only Node
Definition at line 72 of file Dispatcher.hxx.
|
virtual |
Definition at line 45 of file Dispatcher.cxx.
References _singleton.
|
virtual |
Definition at line 107 of file Dispatcher.cxx.
References _observers.
Referenced by DefineCustomObservers(), and YACS::HMI::SubjectNode::SubjectNode().
|
virtual |
Reimplemented in MyDispatcher, and YACS::ENGINE::SALOMEDispatcher.
Definition at line 80 of file Dispatcher.cxx.
References _observers, and DEBTRACE.
Referenced by YACS::ENGINE::Executor::sendEvent(), and YACS::ENGINE::Node::sendEvent().
|
virtual |
Definition at line 94 of file Dispatcher.cxx.
References _observers.
Referenced by YACS::ENGINE::Node::sendEvent2().
|
static |
Definition at line 50 of file Dispatcher.cxx.
References _singleton.
Referenced by Yacs_i::addObserver(), LoadObserversPluginIfAny(), main(), YACS::ENGINE::Executor::sendEvent(), YACS::ENGINE::Node::sendEvent(), and YACS::ENGINE::Node::sendEvent2().
|
virtual |
|
virtual |
|
static |
Definition at line 59 of file Dispatcher.cxx.
References _singleton, and gui.CItems::dispatcher.
Referenced by main(), and YACS::ENGINE::SALOMEDispatcher::setSALOMEDispatcher().
|
protected |
Definition at line 84 of file Dispatcher.hxx.
Referenced by addObserver(), dispatch(), dispatch2(), printObservers(), and removeObserver().
|
staticprotected |
Definition at line 85 of file Dispatcher.hxx.
Referenced by getDispatcher(), setDispatcher(), and ~Dispatcher().