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 {
164 static void holdObservers();
176 static void unholdObservers();
185 return _oHoldCounter;
218 void addObserver(
Observable *
const observer)
const;
227 void addListener(
Observable *
const listener)
const;
235 void removeObserver(
Observable *
const observerver)
const;
243 void removeListener(
Observable *
const listener)
const;
249 unsigned int getSent()
const;
255 unsigned int getReceived()
const;
261 unsigned int countObservers()
const;
267 unsigned int countListeners()
const;
294 static unsigned int getScheduled(
tlp::node n);
309 static const tlp::VectorGraph &getObservableGraph();
333 void sendEvent(
const Event &message);
344 virtual void treatEvents(
const std::vector<Event> &events);
353 virtual void treatEvent(
const Event &message);
371 void observableDeleted();
385 bool hasOnlookers()
const;
388 enum OBSERVABLEEDGETYPE { OBSERVABLE = 0x01, OBSERVER = 0x02, LISTENER = 0x04 };
398 mutable bool queuedEvent;
413 unsigned int received;
448 void addOnlooker(
const Observable &obs, OBSERVABLEEDGETYPE type)
const;
464 void removeOnlooker(
const Observable &obs, OBSERVABLEEDGETYPE type)
const;
476 static tlp::VectorGraph _oGraph;
481 static tlp::NodeProperty<Observable *> _oPointer;
486 static tlp::NodeProperty<bool> _oAlive;
493 static tlp::NodeProperty<unsigned int> _oEventsToTreat;
498 static tlp::EdgeProperty<unsigned char> _oType;
503 static std::vector<tlp::node> _oDelayedDelNode;
505 static std::set<std::pair<tlp::node, tlp::node>> _oDelayedEvents;
510 static unsigned int _oNotifying;
515 static unsigned int _oUnholding;
520 static unsigned int _oHoldCounter;
525 static bool _oInitialized;
530 static bool _oDisabled;
536 static void updateObserverGraph();
544 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.
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...
bool isValid() const
isValid checks if the node is valid. An invalid node is a node whose id is UINT_MAX.
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...