Slicer
5.3
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 } |
typedef std::set< vtkObservation *> | ObservationVector |
typedef vtkObject | Superclass |
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 const char * | GetClassName () |
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 () |
Accessors for Observations More... | |
int | GetNumberOfQueuedObservations () |
bool | GetObservationExist (vtkObject *subject, unsigned long event=0, vtkObject *observer=nullptr, vtkCallbackCommand *notify=nullptr) |
Returns true if such an observation exists (arguments are same as for GetObservations) More... | |
ObservationVector | GetObservations (vtkObject *subject, unsigned long event=0, vtkObject *observer=nullptr, vtkCallbackCommand *notify=nullptr, unsigned int maxReturnedObservations=0) |
vtkCollection * | GetObservationsForCallback (vtkCallbackCommand *callback) |
vtkCollection * | GetObservationsForObserver (vtkObject *observer) |
vtkCollection * | GetObservationsForSubject (vtkObject *subject) |
ObservationVector | GetObservationsForSubjectByTag (vtkObject *subject, unsigned long tag) |
virtual vtkCallbackCommand * | GetRequestModifiedCallback () |
ObservationVector | GetSubjectObservations (vtkObject *subject) |
Fast retrieve of all observations of a given subject. More... | |
virtual vtkTimerLog * | GetTimerLog () |
void | InvokeObservation (vtkObservation *observation, unsigned long eid, void *callData) |
virtual int | IsA (const char *type) |
void | LogEvent (vtkObservation *observation) |
void | OpenLogFile () |
Open and close the log file More... | |
void | PrintSelf (ostream &os, vtkIndent indent) override |
void | ProcessEvent (vtkObservation *observation, vtkObject *caller, unsigned long eid, void *callData) |
Process any event that comes from either subject or observer More... | |
void | ProcessEventQueue () |
void | QueueObservation (vtkObservation *observation, unsigned long eid, void *callData) |
Event queue processing. More... | |
void | RemoveObservation (vtkObservation *observation) |
Remove observation from the broker and event queue More... | |
void | RemoveObservations (ObservationVector observations) |
void | RemoveObservations (vtkObject *observer) |
void | RemoveObservations (vtkObject *subject, vtkObject *observer) |
void | RemoveObservations (vtkObject *subject, unsigned long event, vtkObject *observer) |
void | RemoveObservations (vtkObject *subject, unsigned long event, vtkObject *observer, vtkCallbackCommand *notify) |
void | RemoveObservationsForSubjectByTag (vtkObject *subject, unsigned long tag) |
virtual bool | RequestModified (vtkObject *object) |
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 *) |
File to write event logs to when EventLoging is turned on More... | |
virtual void | SetRequestModifiedCallback (vtkCallbackCommand *callback) |
void | SetScriptHandler (void(*scriptHandler)(const char *script, void *clientData), void *clientData) |
Sets the method pointer to be used for processing script observations More... | |
virtual void | SetTimerLog (vtkTimerLog *timerLog) |
Timer log class for calculating elapsed time for event invocations More... | |
Static Public Member Functions | |
static void | Callback (vtkObject *caller, unsigned long eid, void *clientData, void *callData) |
static vtkEventBroker * | GetInstance () |
Return the singleton instance with no reference counting. More... | |
static int | IsTypeOf (const char *type) |
static vtkEventBroker * | New () |
static vtkEventBroker * | SafeDownCast (vtkObject *o) |
Protected Types | |
typedef std::map< vtkObject *, ObservationVector > | ObjectToObservationVectorMap |
typedef vtkEventBroker | Self |
Protected Member Functions | |
void | AttachObservation (vtkObservation *observation) |
void | DetachObservation (vtkObservation *observation) |
void | operator= (const vtkEventBroker &) |
vtkEventBroker () | |
vtkEventBroker (const vtkEventBroker &) | |
~vtkEventBroker () override | |
Static Protected Member Functions | |
static void | classFinalize () |
static void | classInitialize () |
Singleton management functions. More... | |
Protected Attributes | |
int | CompressCallData |
int | EventLogging |
int | EventMode |
int | EventNestingLevel |
std::deque< vtkObservation *> | EventQueue |
The event queue of triggered but not-yet-invoked observations. More... | |
std::ofstream | LogFile |
char * | LogFileName |
ObjectToObservationVectorMap | ObserverMap |
vtkCallbackCommand * | RequestModifiedCallback |
void(* | ScriptHandler )(const char *script, void *clientData) |
void * | ScriptHandlerClientData |
ObjectToObservationVectorMap | SubjectMap |
maps to manage quick lookup by object More... | |
vtkTimerLog * | TimerLog |
Friends | |
class | vtkEventBrokerInitialize |
class | vtkObservation |
vtkObservation can call these methods More... | |
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: https://wiki.na-mic.org/Wiki/index.php/Slicer3:EventBroker https://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.
|
protected |
Definition at line 280 of file vtkEventBroker.h.
typedef std::set< vtkObservation * > vtkEventBroker::ObservationVector |
Definition at line 55 of file vtkEventBroker.h.
|
protected |
Definition at line 276 of file vtkEventBroker.h.
typedef vtkObject vtkEventBroker::Superclass |
Definition at line 52 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.
Enumerator | |
---|---|
Synchronous | |
Asynchronous |
Definition at line 182 of file vtkEventBroker.h.
|
protected |
|
overrideprotected |
|
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
|
protected |
Attach adds the observers to the object. Detach removes the observers These routines manage the internal datastructures 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 |
the static function used by the command callback (used by vtkObservation)
|
staticprotected |
|
staticprotected |
Singleton management functions.
void vtkEventBroker::CloseLogFile | ( | ) |
|
virtual |
|
virtual |
two modes -
vtkObservation* vtkEventBroker::DequeueObservation | ( | ) |
|
protected |
|
virtual |
|
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 |
|
virtual |
|
virtual |
|
virtual |
|
inline |
Definition at line 199 of file vtkEventBroker.h.
|
virtual |
|
static |
Return the singleton instance with no reference counting.
|
virtual |
vtkObservation* vtkEventBroker::GetNthObservation | ( | int | n | ) |
vtkObservation* vtkEventBroker::GetNthQueuedObservation | ( | int | n | ) |
int vtkEventBroker::GetNumberOfObservations | ( | ) |
Accessors for Observations
int vtkEventBroker::GetNumberOfQueuedObservations | ( | ) |
bool vtkEventBroker::GetObservationExist | ( | vtkObject * | subject, |
unsigned long | event = 0 , |
||
vtkObject * | observer = nullptr , |
||
vtkCallbackCommand * | notify = nullptr |
||
) |
Returns true if such an observation exists (arguments are same as for GetObservations)
ObservationVector vtkEventBroker::GetObservations | ( | vtkObject * | subject, |
unsigned long | event = 0 , |
||
vtkObject * | observer = nullptr , |
||
vtkCallbackCommand * | notify = nullptr , |
||
unsigned int | maxReturnedObservations = 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 returned If maxReturnedObservations is != 0, only up to this number of observations 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
ObservationVector vtkEventBroker::GetObservationsForSubjectByTag | ( | vtkObject * | subject, |
unsigned long | tag | ||
) |
|
virtual |
ObservationVector vtkEventBroker::GetSubjectObservations | ( | vtkObject * | subject | ) |
Fast retrieve of all observations of a given subject.
|
virtual |
void vtkEventBroker::InvokeObservation | ( | vtkObservation * | observation, |
unsigned long | eid, | ||
void * | callData | ||
) |
|
virtual |
|
static |
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 |
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
|
protected |
|
override |
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 | ( | ObservationVector | 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 |
Request invoking modified event. Modified event is called later (e.g., when the application becomes idle) on the main thread (therefore it is safe to call this method from any thread). Returns true if the request was successfully submitted.
|
static |
|
virtual |
|
virtual |
|
inline |
Definition at line 187 of file vtkEventBroker.h.
|
inline |
Definition at line 198 of file vtkEventBroker.h.
|
inline |
Definition at line 197 of file vtkEventBroker.h.
|
virtual |
Current level of indent (event nesting) shows what is called by what when in synchronous mode
|
virtual |
File to write event logs to when EventLoging is turned on
|
virtual |
Set callback command for RequestModified. This command must be implemented so that it is safe to be called from any thread.
|
inline |
Sets the method pointer to be used for processing script observations
Definition at line 238 of file vtkEventBroker.h.
|
virtual |
Timer log class for calculating elapsed time for event invocations
|
friend |
Definition at line 275 of file vtkEventBroker.h.
|
friend |
vtkObservation can call these methods
Definition at line 310 of file vtkEventBroker.h.
|
protected |
Definition at line 298 of file vtkEventBroker.h.
|
protected |
Definition at line 292 of file vtkEventBroker.h.
|
protected |
Definition at line 297 of file vtkEventBroker.h.
|
protected |
Definition at line 293 of file vtkEventBroker.h.
|
protected |
The event queue of triggered but not-yet-invoked observations.
Definition at line 287 of file vtkEventBroker.h.
|
protected |
Definition at line 300 of file vtkEventBroker.h.
|
protected |
Definition at line 294 of file vtkEventBroker.h.
|
protected |
Definition at line 284 of file vtkEventBroker.h.
|
protected |
Definition at line 302 of file vtkEventBroker.h.
|
protected |
Definition at line 289 of file vtkEventBroker.h.
|
protected |
Definition at line 290 of file vtkEventBroker.h.
|
protected |
maps to manage quick lookup by object
Definition at line 283 of file vtkEventBroker.h.
|
protected |
Definition at line 295 of file vtkEventBroker.h.