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 {
171 return _oHoldCounter;
213 addObserver(&observer);
233 addListener(&listener);
251 removeObserver(&observer);
269 removeListener(&listener);
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 {
Event is the base class for all events used in the Observation mechanism.
The Observable class is the base of Tulip's observation system.
static Observable * getObject(tlp::node n)
internal function for debugging purpose If called during an update, it is possible the pointed object...
static tlp::node getNode(const tlp::Observable *obs)
internal function for debugging purpose Get the node representing this object in the Observable Graph...
void addObserver(Observable &observer) const
Adds an Observer to this object.
virtual void treatEvent(const Event &message)
This function is called when events are sent to the Listeners, and Listeners only.
static const tlp::VectorGraph & getObservableGraph()
Gets the observation graph.
bool hasOnlookers() const
Checks whether there are Observers/Listeners attached to this object.
void observableDeleted()
Sends the Event::DELETE before the deletion of the subclass and its internal objects.
void addListener(Observable &listener) const
Adds a Listener to this object.
static void unholdObservers()
Sends all held events to the Observers.
static bool isAlive(tlp::node n)
internal function for debugging purpose If there is no hold currently applied, or no update ongoing,...
unsigned int countObservers() const
gets the number of observers attached to this object.
static void disableEventNotification()
disable the whole event notification mechanism Until a call to enableEventNotification(),...
unsigned int getReceived() const
get the number of received events.
static void holdObservers()
Holds back all events until Observable::unholdObservers() is called.
static unsigned int getScheduled(tlp::node n)
internal function for debugging purpose getScheduled get the number of scheduled events for this Obse...
void addListener(Observable *const listener) const
Adds a Listener to this object.
unsigned int getSent() const
gets the number of sent events.
void addObserver(Observable *const observer) const
Adds an Observer to this object.
unsigned int countListeners() const
gets the number of listeners attached to this object.
void removeListener(Observable *const listener) const
Removes a listener from this object.
void removeObserver(Observable &observer) const
Removes an observer from this object.
void sendEvent(const Event &message)
Sends an event to all the Observers/Listeners. It is higly recommended to check if there are observer...
static unsigned int observersHoldCounter()
observersHoldCounter gives the number of times holdObservers() has been called without a matching unh...
static void enableEventNotification()
re-enable the whole event notification mechanism All events sent since a previous call to enableEvent...
void removeObserver(Observable *const observer) const
Removes an observer from this object.
void removeListener(Observable &listener) const
Removes a listener from this object.
virtual void treatEvents(const std::vector< Event > &events)
This function is called when events are sent to Observers, and Observers only.
The ObserverHolder class is a convenience class to automatically hold and unhold observers....
PropertyInterface describes the interface of a graph property.
Interface for Tulip iterators. Allows basic iteration operations only.
The node struct represents a node in a Graph object.
bool isValid() const
isValid checks if the node is valid. An invalid node is a node whose id is UINT_MAX.