| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tlp::Observable Class Reference Observable is the base class for the implementation of observable Object by Listener or Observer objects. More...
Inheritance diagram for tlp::Observable:
Collaboration diagram for tlp::Observable:
Public Member Functions
Static Public Member Functions
Protected Member Functions
Friends
Detailed DescriptionObservable is the base class for the implementation of observable Object by Listener or Observer objects. Observable the base class of all objects that need to be Observed or listened. To notify its Onlooker an Observable have to call the notify function whenever it wants. The event will be send directly to all Listener and Observer (if not holded) The Event send by the Observable is a const reference, thus the observer is responsible of the creation and destruction of Event. Usually the Event is created on the stack in the block of code that call the notify function, thus there is no need to take care of it. Observable provides a mechanism (hold/unhold) to delay the sending of events to Observer, the mechanism is global. Calling the hold function will stop the transmission of Event::MODIFICATION to all the Observer, there is no way to delay the sending of events only for one Observable. Nested call to hold/unhold are permitted. The Event::DELETE event cannot be created by user, it is automatically send to all Observer/Listener at the destruction of an Observable. However, using the ObservableDeleted function it is possible to send the Event from the destructor of a specific Observable implementation. The update function of observer/Listener can the be called before the destruction of your internal objects. It enables the Observer/Listener, to to access to the internal data of your Observable before it disappear. Constructor & Destructor Documentation
Member Function Documentation
return the number of Listeners of that Object
return the number of Observers of that Object
return a pointer on the object represented by that node
Return a reference on the Observable/Listener/Observer graph.
use for old observer tulip compatibility
return the number of received nofication
return the number of sent nofication
Enable to know if there is at least one Observer/Listener connected. it enables to prevent creation and sending of Event for nothing. Usually a notify code block in an Observable should look like that: if (hasOnlookers()) { notify(MyEvent(*this, param1, param2, ...)); } °
start delay of events to all Observer After a call to holdObservers, no more events are sent to Observer(execpt DELETE events), events are still transmit to listeners. It is possible to call several time the holdObservers function, in that case the observers are holded until all holdObservers calls are closed by unholdOBservers calls.
Enables to test if the object represented by a node has been deleted. Outside a unhold/hold block or an update that function always return true.
use for old observer tulip compatibility
Enable to send Event::DELETE before the deletion of subclass internal objects. The Observable mecahnism automatically send DELETE event to Listener/Observer when an Obseravble is deleted. However when that Event is send the subclass of Observable are already deleted, thus it is no more possible to access to their members. In case you want to allow to access to your Observable member variables/functions when Listner/Observer receive a DELETE events, you should call that function in your destructor.
use for old observer tulip compatibility
Enable to send an event to all Observer/Listener. According to the type of the event that function has got different behaviour. event::DELETE : are sent directly to all Observers/Listeners, it is not possible to delay their processing.
To prevent building of too many objects(Event) a notify code block in an Observable should look like that: if (hasOnlookers()) { notify(MyEvent(*this, param1, param2, ...)); } °
that function should be virtual pure the current implementation is only here to insure compatibility with tulip 3.x x<6.
Send queued event to all Observer. If the stack of Observable lock is empty (ie. number of calls to unhold equal to the number of calls to hold), send all queued events to observers.
use for old observer tulip compatibility Friends And Related Function Documentation
|
Tulip Software by LaBRI Visualization Team 2001 - 2012 |