23 #include <tulip/TulipException.h> 24 #include <tulip/ForEach.h> 25 #include <tulip/vectorgraph.h> 52 enum EventType {TLP_DELETE = 0, TLP_MODIFICATION, TLP_INFORMATION, TLP_INVALID};
56 EventType type()
const {
143 static void holdObservers();
154 static void unholdObservers();
161 return _oHoldCounter;
170 void addObserver(
Observable *
const observer)
const;
178 void addListener(
Observable *
const listener)
const;
186 void removeObserver(
Observable *
const observerver)
const;
194 void removeListener(
Observable *
const listener)
const;
200 unsigned int getSent()
const;
206 unsigned int getReceived()
const;
212 unsigned int countObservers()
const;
218 unsigned int countListeners()
const;
245 static unsigned int getScheduled(
tlp::node n);
259 static const tlp::VectorGraph& getObservableGraph();
282 void sendEvent(
const Event &message);
292 virtual void treatEvents(
const std::vector<Event> &events);
301 virtual void treatEvent(
const Event &message);
316 void observableDeleted();
330 bool hasOnlookers()
const;
335 _DEPRECATED tlp::Iterator<tlp::Observable *> * getObservables()
const;
340 _DEPRECATED
void notifyObservers();
343 enum OBSERVABLEEDGETYPE {OBSERVABLE = 0x01, OBSERVER = 0x02, LISTENER = 0x04};
353 mutable bool queuedEvent;
368 unsigned int received;
378 tlp::Iterator<Observable *> *getOnlookers()
const;
384 tlp::Iterator<tlp::node> *getInObjects()
const;
390 tlp::Iterator<tlp::node> *getOutObjects()
const;
402 void addOnlooker(
const Observable &obs, OBSERVABLEEDGETYPE type)
const;
417 void removeOnlooker(
const Observable &obs, OBSERVABLEEDGETYPE type)
const;
429 static tlp::VectorGraph _oGraph;
434 static tlp::NodeProperty<Observable *> _oPointer;
439 static tlp::NodeProperty<bool> _oAlive;
446 static tlp::NodeProperty<unsigned int> _oEventsToTreat;
451 static tlp::EdgeProperty<unsigned char> _oType;
456 static std::vector<tlp::node> _oDelayedDelNode;
458 static std::set<std::pair<tlp::node, tlp::node> > _oDelayedEvents;
463 static unsigned int _oNotifying;
468 static unsigned int _oUnholding;
473 static unsigned int _oHoldCounter;
478 static bool _oInitialized;
483 static void updateObserverGraph();
491 bool isBound()
const {
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.
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.