|
Slicer 4.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
|
Class that manages adding and deleting of observers with events. More...
#include <Libs/MRML/Core/vtkEventBroker.h>
Public Types | |
| enum | EventMode { Synchronous, Asynchronous } |
Public Member Functions | |
| vtkObservation * | AddObservation (vtkObject *subject, unsigned long event, vtkObject *observer, vtkCallbackCommand *notify, float priority=0.0f) |
| vtkObservation * | AddObservation (vtkObject *subject, const char *event, const char *script) |
| void | CloseLogFile () |
| virtual void | CompressCallDataOff () |
| virtual void | CompressCallDataOn () |
| vtkObservation * | DequeueObservation () |
| virtual void | EventLoggingOff () |
| virtual void | EventLoggingOn () |
| int | GenerateGraphFile (const char *graphFile) |
| virtual int | GetCompressCallData () |
| virtual int | GetEventLogging () |
| virtual int | GetEventMode () |
| const char * | GetEventModeAsString () |
| virtual int | GetEventNestingLevel () |
| virtual char * | GetLogFileName () |
| vtkObservation * | GetNthObservation (int n) |
| vtkObservation * | GetNthQueuedObservation (int n) |
| int | GetNumberOfObservations () |
| int | GetNumberOfQueuedObservations () |
| std::vector< vtkObservation * > | GetObservations (vtkObject *subject, unsigned long event=0, vtkObject *observer=0, vtkCallbackCommand *notify=0) |
| vtkCollection * | GetObservationsForCallback (vtkCallbackCommand *callback) |
| vtkCollection * | GetObservationsForObserver (vtkObject *observer) |
| vtkCollection * | GetObservationsForSubject (vtkObject *subject) |
| std::vector< vtkObservation * > | GetObservationsForSubjectByTag (vtkObject *subject, unsigned long tag) |
| std::vector< vtkObservation * > | GetSubjectObservations (vtkObject *subject) |
| Fast retrieve of all observations of a given subject. | |
| virtual vtkTimerLog * | GetTimerLog () |
| void | InvokeObservation (vtkObservation *observation, unsigned long eid, void *callData) |
| void | LogEvent (vtkObservation *observation) |
| void | OpenLogFile () |
| void | PrintSelf (ostream &os, vtkIndent indent) |
| void | ProcessEvent (vtkObservation *observation, vtkObject *caller, unsigned long eid, void *callData) |
| void | ProcessEventQueue () |
| void | QueueObservation (vtkObservation *observation, unsigned long eid, void *callData) |
| Event queue processing. | |
| void | RemoveObservation (vtkObservation *observation) |
| void | RemoveObservations (vtkObject *subject, unsigned long event, vtkObject *observer, vtkCallbackCommand *notify) |
| void | RemoveObservations (vtkObject *subject, vtkObject *observer) |
| void | RemoveObservations (vtkObject *subject, unsigned long event, vtkObject *observer) |
| void | RemoveObservations (std::vector< vtkObservation * >observations) |
| void | RemoveObservations (vtkObject *observer) |
| void | RemoveObservationsForSubjectByTag (vtkObject *subject, unsigned long tag) |
| virtual void | SetCompressCallData (int) |
| virtual void | SetEventLogging (int) |
| void | SetEventMode (int eventMode) |
| void | SetEventModeToAsynchronous () |
| void | SetEventModeToSynchronous () |
| virtual void | SetEventNestingLevel (int) |
| virtual void | SetLogFileName (const char *) |
| void | SetScriptHandler (void(*scriptHandler)(const char *script, void *clientData), void *clientData) |
| virtual void | SetTimerLog (vtkTimerLog *timerLog) |
| vtkTypeRevisionMacro (vtkEventBroker, vtkObject) | |
Static Public Member Functions | |
| static void | Callback (vtkObject *caller, unsigned long eid, void *clientData, void *callData) |
| static vtkEventBroker * | GetInstance () |
| static vtkEventBroker * | New () |
Protected Types | |
| typedef char * | KeyType |
| typedef std::map< KeyType, ObservationVector > | ObjectToObservationVectorMap |
| typedef std::vector < vtkObservation * > | ObservationVector |
| typedef vtkEventBroker | Self |
Protected Member Functions | |
| void | AttachObservation (vtkObservation *observation) |
| void | DetachObservation (vtkObservation *observation) |
| void | operator= (const vtkEventBroker &) |
| vtkEventBroker () | |
| vtkEventBroker (const vtkEventBroker &) | |
| virtual | ~vtkEventBroker () |
Static Protected Member Functions | |
| static void | classFinalize () |
| static void | classInitialize () |
Protected Attributes | |
| int | CompressCallData |
| int | EventLogging |
| int | EventMode |
| int | EventNestingLevel |
| std::deque< vtkObservation * > | EventQueue |
| The event queue of triggered but not-yet-invoked observations. | |
| std::ofstream | LogFile |
| char * | LogFileName |
| ObjectToObservationVectorMap | ObserverMap |
| void(* | ScriptHandler )(const char *script, void *clientData) |
| void * | ScriptHandlerClientData |
| ObjectToObservationVectorMap | SubjectMap |
| maps to manage quick lookup by object | |
| vtkTimerLog * | TimerLog |
Friends | |
| class | vtkEventBrokerInitialize |
| class | vtkObservation |
| vtkObservation can call these methods | |
Class that manages adding and deleting of observers with events.
This class keeps track of observers and events added to each vtk object. It caches tags returned by AddObserver method so that observers can be removed properly. See also: http://wiki.na-mic.org/Wiki/index.php/Slicer3:EventBroker http://en.wikipedia.org/wiki/Observer_pattern Other interesting observer implementations: http://xlobject.sourceforge http://sigslot.sourceforge.net/ http://doc.trolltech.com/4.3/signalsandslots.html
Definition at line 49 of file vtkEventBroker.h.
typedef char* vtkEventBroker::KeyType [protected] |
Definition at line 260 of file vtkEventBroker.h.
typedef std::map< KeyType, ObservationVector > vtkEventBroker::ObjectToObservationVectorMap [protected] |
Definition at line 262 of file vtkEventBroker.h.
typedef std::vector< vtkObservation * > vtkEventBroker::ObservationVector [protected] |
Definition at line 261 of file vtkEventBroker.h.
typedef vtkEventBroker vtkEventBroker::Self [protected] |
Definition at line 256 of file vtkEventBroker.h.
Event Queue processing modes
In synchronous mode, observations are invoked immediately when the event takes place. In asynchronous mode, observations are added to the event queue for later invocation.
Definition at line 173 of file vtkEventBroker.h.
| vtkEventBroker::vtkEventBroker | ( | ) | [protected] |
| virtual vtkEventBroker::~vtkEventBroker | ( | ) | [protected, virtual] |
| vtkEventBroker::vtkEventBroker | ( | const vtkEventBroker & | ) | [protected] |
| vtkObservation* vtkEventBroker::AddObservation | ( | vtkObject * | subject, |
| unsigned long | event, | ||
| vtkObject * | observer, | ||
| vtkCallbackCommand * | notify, | ||
| float | priority = 0.0f |
||
| ) |
Adding and Removing Observation objects
Request that an observer be added to the subject (or "observee")
| vtkObservation* vtkEventBroker::AddObservation | ( | vtkObject * | subject, |
| const char * | event, | ||
| const char * | script | ||
| ) |
Scripted version of observation
| void vtkEventBroker::AttachObservation | ( | vtkObservation * | observation | ) | [protected] |
Attach adds the observers to the object. Detach removes the observers These routines manage the internal datastructres and should be the only methods used to modified the internal Observations member Please note that they don't update the SubjectMap nor the ObserverMap.
| static void vtkEventBroker::Callback | ( | vtkObject * | caller, |
| unsigned long | eid, | ||
| void * | clientData, | ||
| void * | callData | ||
| ) | [static] |
the static function used by the command callback (used by vtkObservation)
| static void vtkEventBroker::classFinalize | ( | ) | [static, protected] |
| static void vtkEventBroker::classInitialize | ( | ) | [static, protected] |
Singleton management functions.
| void vtkEventBroker::CloseLogFile | ( | ) |
| virtual void vtkEventBroker::CompressCallDataOff | ( | ) | [virtual] |
| virtual void vtkEventBroker::CompressCallDataOn | ( | ) | [virtual] |
two modes -
| vtkObservation* vtkEventBroker::DequeueObservation | ( | ) |
| void vtkEventBroker::DetachObservation | ( | vtkObservation * | observation | ) | [protected] |
| virtual void vtkEventBroker::EventLoggingOff | ( | ) | [virtual] |
| virtual void vtkEventBroker::EventLoggingOn | ( | ) | [virtual] |
Event Logging
Turn on event tracing (requires TraceFile)
| int vtkEventBroker::GenerateGraphFile | ( | const char * | graphFile | ) |
Graph File
Write out the current list of observations in graphviz format (.dot)
| virtual int vtkEventBroker::GetCompressCallData | ( | ) | [virtual] |
| virtual int vtkEventBroker::GetEventLogging | ( | ) | [virtual] |
| virtual int vtkEventBroker::GetEventMode | ( | ) | [virtual] |
| const char* vtkEventBroker::GetEventModeAsString | ( | ) | [inline] |
Definition at line 190 of file vtkEventBroker.h.
| virtual int vtkEventBroker::GetEventNestingLevel | ( | ) | [virtual] |
| static vtkEventBroker* vtkEventBroker::GetInstance | ( | ) | [static] |
Return the singleton instance with no reference counting.
| virtual char* vtkEventBroker::GetLogFileName | ( | ) | [virtual] |
| vtkObservation* vtkEventBroker::GetNthObservation | ( | int | n | ) |
| vtkObservation* vtkEventBroker::GetNthQueuedObservation | ( | int | n | ) |
| int vtkEventBroker::GetNumberOfObservations | ( | ) |
Accessors for Observations
| int vtkEventBroker::GetNumberOfQueuedObservations | ( | ) |
| std::vector< vtkObservation *> vtkEventBroker::GetObservations | ( | vtkObject * | subject, |
| unsigned long | event = 0, |
||
| vtkObject * | observer = 0, |
||
| vtkCallbackCommand * | notify = 0 |
||
| ) |
If event is != 0 , only observations matching the events are returned If observer is != 0 , only observations matching the observer are returned If notify is != 0, only observations matching the callback are are returned
| vtkCollection* vtkEventBroker::GetObservationsForCallback | ( | vtkCallbackCommand * | callback | ) |
| vtkCollection* vtkEventBroker::GetObservationsForObserver | ( | vtkObject * | observer | ) |
| vtkCollection* vtkEventBroker::GetObservationsForSubject | ( | vtkObject * | subject | ) |
Description Accessors for intropsection Note: vtkCollection object is allocated internally and must be freed by the caller
| std::vector< vtkObservation *> vtkEventBroker::GetObservationsForSubjectByTag | ( | vtkObject * | subject, |
| unsigned long | tag | ||
| ) |
| std::vector< vtkObservation *> vtkEventBroker::GetSubjectObservations | ( | vtkObject * | subject | ) |
Fast retrieve of all observations of a given subject.
| virtual vtkTimerLog* vtkEventBroker::GetTimerLog | ( | ) | [virtual] |
| void vtkEventBroker::InvokeObservation | ( | vtkObservation * | observation, |
| unsigned long | eid, | ||
| void * | callData | ||
| ) |
| void vtkEventBroker::LogEvent | ( | vtkObservation * | observation | ) |
actually write to the log file (also manages state of the LogFile ivar based on the filename and the EventLogging variable)
| static vtkEventBroker* vtkEventBroker::New | ( | ) | [static] |
This is a singleton pattern New. There will only be ONE reference to a vtkEventBroker object per process. Clients that call this must call Delete on the object so that the reference counting will work. The single instance will be unreferenced when the program exits.
| void vtkEventBroker::OpenLogFile | ( | ) |
Open and close the log file
| void vtkEventBroker::operator= | ( | const vtkEventBroker & | ) | [protected] |
| void vtkEventBroker::PrintSelf | ( | ostream & | os, |
| vtkIndent | indent | ||
| ) |
| void vtkEventBroker::ProcessEvent | ( | vtkObservation * | observation, |
| vtkObject * | caller, | ||
| unsigned long | eid, | ||
| void * | callData | ||
| ) |
Process any event that comes from either subject or observer
| void vtkEventBroker::ProcessEventQueue | ( | ) |
| void vtkEventBroker::QueueObservation | ( | vtkObservation * | observation, |
| unsigned long | eid, | ||
| void * | callData | ||
| ) |
Event queue processing.
Event queue handling routines Note:
| void vtkEventBroker::RemoveObservation | ( | vtkObservation * | observation | ) |
Remove observation from the broker and event queue
| void vtkEventBroker::RemoveObservations | ( | std::vector< vtkObservation * > | observations | ) |
Remove all observations that match
| void vtkEventBroker::RemoveObservations | ( | vtkObject * | observer | ) |
| void vtkEventBroker::RemoveObservations | ( | vtkObject * | subject, |
| vtkObject * | observer | ||
| ) |
| void vtkEventBroker::RemoveObservations | ( | vtkObject * | subject, |
| unsigned long | event, | ||
| vtkObject * | observer | ||
| ) |
| void vtkEventBroker::RemoveObservations | ( | vtkObject * | subject, |
| unsigned long | event, | ||
| vtkObject * | observer, | ||
| vtkCallbackCommand * | notify | ||
| ) |
| void vtkEventBroker::RemoveObservationsForSubjectByTag | ( | vtkObject * | subject, |
| unsigned long | tag | ||
| ) |
| virtual void vtkEventBroker::SetCompressCallData | ( | int | ) | [virtual] |
| virtual void vtkEventBroker::SetEventLogging | ( | int | ) | [virtual] |
| void vtkEventBroker::SetEventMode | ( | int | eventMode | ) | [inline] |
Definition at line 178 of file vtkEventBroker.h.
| void vtkEventBroker::SetEventModeToAsynchronous | ( | ) | [inline] |
Definition at line 189 of file vtkEventBroker.h.
| void vtkEventBroker::SetEventModeToSynchronous | ( | ) | [inline] |
Definition at line 188 of file vtkEventBroker.h.
| virtual void vtkEventBroker::SetEventNestingLevel | ( | int | ) | [virtual] |
Current level of indent (event nesting) shows what is called by what when in synchronous mode
| virtual void vtkEventBroker::SetLogFileName | ( | const char * | ) | [virtual] |
File to write event logs to when EventLoging is turned on
| void vtkEventBroker::SetScriptHandler | ( | void(*)(const char *script, void *clientData) | scriptHandler, |
| void * | clientData | ||
| ) | [inline] |
Sets the method pointer to be used for processing script observations
Definition at line 229 of file vtkEventBroker.h.
| virtual void vtkEventBroker::SetTimerLog | ( | vtkTimerLog * | timerLog | ) | [virtual] |
Timer log class for calculating elapsed time for event invocations
| vtkEventBroker::vtkTypeRevisionMacro | ( | vtkEventBroker | , |
| vtkObject | |||
| ) |
friend class vtkEventBrokerInitialize [friend] |
Definition at line 255 of file vtkEventBroker.h.
friend class vtkObservation [friend] |
vtkObservation can call these methods
Definition at line 289 of file vtkEventBroker.h.
int vtkEventBroker::CompressCallData [protected] |
Definition at line 280 of file vtkEventBroker.h.
int vtkEventBroker::EventLogging [protected] |
Definition at line 274 of file vtkEventBroker.h.
int vtkEventBroker::EventMode [protected] |
Definition at line 279 of file vtkEventBroker.h.
int vtkEventBroker::EventNestingLevel [protected] |
Definition at line 275 of file vtkEventBroker.h.
std::deque< vtkObservation * > vtkEventBroker::EventQueue [protected] |
The event queue of triggered but not-yet-invoked observations.
Definition at line 269 of file vtkEventBroker.h.
std::ofstream vtkEventBroker::LogFile [protected] |
Definition at line 282 of file vtkEventBroker.h.
char* vtkEventBroker::LogFileName [protected] |
Definition at line 276 of file vtkEventBroker.h.
Definition at line 266 of file vtkEventBroker.h.
void(* vtkEventBroker::ScriptHandler)(const char *script, void *clientData) [protected] |
Definition at line 271 of file vtkEventBroker.h.
void* vtkEventBroker::ScriptHandlerClientData [protected] |
Definition at line 272 of file vtkEventBroker.h.
maps to manage quick lookup by object
Definition at line 265 of file vtkEventBroker.h.
vtkTimerLog* vtkEventBroker::TimerLog [protected] |
Definition at line 277 of file vtkEventBroker.h.
1.7.4