25 #include <tulip/tulipconf.h> 26 #include <tulip/Iterator.h> 27 #include <tulip/Node.h> 58 enum EventType { TLP_DELETE = 0, TLP_MODIFICATION, TLP_INFORMATION, TLP_INVALID };
62 EventType type()
const {
150 static void holdObservers();
162 static void unholdObservers();
171 return _oHoldCounter;
204 void addObserver(
Observable *
const observer)
const;
213 addObserver(&observer);
223 void addListener(
Observable *
const listener)
const;
233 addListener(&listener);
242 void removeObserver(
Observable *
const observer)
const;
251 removeObserver(&observer);
260 void removeListener(
Observable *
const listener)
const;
269 removeListener(&listener);
276 unsigned int getSent()
const;
282 unsigned int getReceived()
const;
288 unsigned int countObservers()
const;
294 unsigned int countListeners()
const;
321 static unsigned int getScheduled(
tlp::node n);
336 static const tlp::VectorGraph &getObservableGraph();
360 void sendEvent(
const Event &message);
371 virtual void treatEvents(
const std::vector<Event> &events);
380 virtual void treatEvent(
const Event &message);
398 void observableDeleted();
412 bool hasOnlookers()
const;
415 enum OBSERVABLEEDGETYPE { OBSERVABLE = 0x01, OBSERVER = 0x02, LISTENER = 0x04 };
425 mutable bool queuedEvent;
440 unsigned int received;
475 void addOnlooker(
const Observable &obs, OBSERVABLEEDGETYPE type)
const;
491 void removeOnlooker(
const Observable &obs, OBSERVABLEEDGETYPE type)
const;
503 static unsigned int _oHoldCounter;
508 static bool _oDisabled;
514 static void updateObserverGraph();
522 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::holdObservers() at its creation and a call to Observable::unholdObservers() 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::unholdObservers() 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.
void removeObserver(Observable &observer) const
Removes an observer from this object.
Event is the base class for all events used in the Observation mechanism.
void removeListener(Observable &listener) const
Removes a listener from this object.
void addObserver(Observable &observer) const
Adds an Observer to this object.
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...
void addListener(Observable &listener) const
Adds a Listener to this object.