23 #include <tulip/TulipException.h> 24 #include <tulip/vectorgraph.h> 57 enum EventType { TLP_DELETE = 0, TLP_MODIFICATION, TLP_INFORMATION, TLP_INVALID };
61 EventType type()
const {
163 static void holdObservers();
175 static void unholdObservers();
184 return _oHoldCounter;
217 void addObserver(
Observable *
const observer)
const;
226 void addListener(
Observable *
const listener)
const;
234 void removeObserver(
Observable *
const observerver)
const;
242 void removeListener(
Observable *
const listener)
const;
248 unsigned int getSent()
const;
254 unsigned int getReceived()
const;
260 unsigned int countObservers()
const;
266 unsigned int countListeners()
const;
293 static unsigned int getScheduled(
tlp::node n);
308 static const tlp::VectorGraph &getObservableGraph();
332 void sendEvent(
const Event &message);
343 virtual void treatEvents(
const std::vector<Event> &events);
352 virtual void treatEvent(
const Event &message);
370 void observableDeleted();
384 bool hasOnlookers()
const;
387 enum OBSERVABLEEDGETYPE { OBSERVABLE = 0x01, OBSERVER = 0x02, LISTENER = 0x04 };
397 mutable bool queuedEvent;
412 unsigned int received;
447 void addOnlooker(
const Observable &obs, OBSERVABLEEDGETYPE type)
const;
463 void removeOnlooker(
const Observable &obs, OBSERVABLEEDGETYPE type)
const;
475 static tlp::VectorGraph _oGraph;
480 static tlp::NodeProperty<Observable *> _oPointer;
485 static tlp::NodeProperty<bool> _oAlive;
492 static tlp::NodeProperty<unsigned int> _oEventsToTreat;
497 static tlp::EdgeProperty<unsigned char> _oType;
502 static std::vector<tlp::node> _oDelayedDelNode;
504 static std::set<std::pair<tlp::node, tlp::node>> _oDelayedEvents;
509 static unsigned int _oNotifying;
514 static unsigned int _oUnholding;
519 static unsigned int _oHoldCounter;
524 static bool _oInitialized;
529 static bool _oDisabled;
535 static void updateObserverGraph();
543 bool isBound()
const {
static void disableEventNotification()
disable the whole event notification mechanism Until a call to enableEventNotification(), all sent events will be lost, except TLP_DELETE events which are synchronously processed, in order to void dangling pointers.
The ObserverHolder class is a convenience class to automatically hold and unhold observers. It performs a call to Observable::holdObserver() at its creation and a call to Observable::unholdObserver() at its destruction. You can use it if you have to hold observers in a function with multiple return points to avoid to call Observable::unholdObserver() for each of them.
Interface for Tulip iterators. Allows basic iteration operations only.
PropertyInterface describes the interface of a graph property.
bool isValid() const
isValid checks if the node is valid. An invalid node is a node whose id is UINT_MAX.
static unsigned int observersHoldCounter()
observersHoldCounter gives the number of times holdObservers() has been called without a matching unh...
static void holdObservers()
Holds back all events until Observable::unholdObservers() is called.
The node struct represents a node in a Graph object.
Event is the base class for all events used in the Observation mechanism.
ObservableException is the base class of all exceptions sent by the Observable/Listener/Observer syst...
static void unholdObservers()
Sends all held events to the Observers.
The Observable class is the base of Tulip's observation system.
static void enableEventNotification()
re-enable the whole event notification mechanism All events sent since a previous call to enableEvent...