44 #include "vtkCommonCoreModule.h"
45 #include "vtkObjectBase.h"
46 #include "vtkSetGet.h"
47 #include "vtkTimeStamp.h"
48 #include "vtkWeakPointerBase.h"
50 class vtkSubjectHelper;
66 void*
operator new(
size_t tSize );
67 void operator delete(
void* p );
115 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
124 static void GlobalWarningDisplayOff()
126 static int GetGlobalWarningDisplay();
143 float priority=0.0f);
144 unsigned long AddObserver(
const char *event, vtkCommand *,
145 float priority=0.0f);
146 vtkCommand *GetCommand(
unsigned long tag);
147 void RemoveObserver(vtkCommand*);
148 void RemoveObservers(
unsigned long event, vtkCommand *);
149 void RemoveObservers(
const char *event, vtkCommand *);
150 int HasObserver(
unsigned long event, vtkCommand *);
151 int HasObserver(
const char *event, vtkCommand *);
154 void RemoveObserver(
unsigned long tag);
155 void RemoveObservers(
unsigned long event);
156 void RemoveObservers(
const char *event);
157 void RemoveAllObservers();
158 int HasObserver(
unsigned long event);
159 int HasObserver(
const char *event);
187 template <
class U,
class T>
189 U observer,
void (T::*callback)(),
float priority=0.0f)
191 vtkClassMemberCallback<T> *callable =
192 new vtkClassMemberCallback<T>(observer, callback);
195 return this->AddTemplatedObserver(event, callable, priority);
197 template <
class U,
class T>
198 unsigned long AddObserver(
unsigned long event,
199 U observer,
void (T::*callback)(
vtkObject*,
unsigned long,
void*),
202 vtkClassMemberCallback<T> *callable =
203 new vtkClassMemberCallback<T>(observer, callback);
206 return this->AddTemplatedObserver(event, callable, priority);
215 template <
class U,
class T>
217 U observer,
bool (T::*callback)(
vtkObject*,
unsigned long,
void*),
220 vtkClassMemberCallback<T> *callable =
221 new vtkClassMemberCallback<T>(observer, callback);
224 return this->AddTemplatedObserver(event, callable, priority);
235 int InvokeEvent(
const char *event,
void *callData);
238 int InvokeEvent(
unsigned long event) {
return this->InvokeEvent(event, NULL); };
239 int InvokeEvent(
const char *event) {
return this->InvokeEvent(event, NULL); };
246 void RegisterInternal(
vtkObjectBase*, vtkTypeBool check) VTK_OVERRIDE;
247 void UnRegisterInternal(
vtkObjectBase*, vtkTypeBool check) VTK_OVERRIDE;
251 vtkSubjectHelper *SubjectHelper;
262 void InternalGrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL);
263 void InternalReleaseFocus();
268 void operator=(const
vtkObject&) VTK_DELETE_FUNCTION;
277 class vtkClassMemberCallbackBase
284 virtual bool operator()(
vtkObject*,
unsigned long,
void*) = 0;
285 virtual ~vtkClassMemberCallbackBase(){}
295 class vtkClassMemberHandlerPointer
302 if ((this->VoidPointer =
dynamic_cast<T*
>(o)) == 0)
305 this->VoidPointer = o;
307 this->WeakPointer = o;
308 this->UseWeakPointer =
true;
310 void operator=(
void *o)
312 this->VoidPointer = o;
313 this->WeakPointer = 0;
314 this->UseWeakPointer =
false;
318 if (this->UseWeakPointer && !this->WeakPointer.GetPointer())
322 return static_cast<T*
>(this->VoidPointer);
325 vtkWeakPointerBase WeakPointer;
336 class vtkClassMemberCallback :
public vtkClassMemberCallbackBase
338 vtkClassMemberHandlerPointer<T> Handler;
339 void (T::*Method1)();
340 void (T::*Method2)(
vtkObject*,
unsigned long,
void*);
341 bool (T::*Method3)(
vtkObject*,
unsigned long,
void*);
345 vtkClassMemberCallback(T* handler,
void (T::*method)())
347 this->Handler = handler;
348 this->Method1 = method;
349 this->Method2 = NULL;
350 this->Method3 = NULL;
353 vtkClassMemberCallback(
354 T* handler,
void (T::*method)(
vtkObject*,
unsigned long,
void*))
356 this->Handler = handler;
357 this->Method1 = NULL;
358 this->Method2 = method;
359 this->Method3 = NULL;
362 vtkClassMemberCallback(
363 T* handler,
bool (T::*method)(
vtkObject*,
unsigned long,
void*))
365 this->Handler = handler;
366 this->Method1 = NULL;
367 this->Method2 = NULL;
368 this->Method3 = method;
370 ~vtkClassMemberCallback() VTK_OVERRIDE { }
374 vtkObject* caller,
unsigned long event,
void* calldata) VTK_OVERRIDE
376 T *handler = this->Handler.GetPointer();
381 (handler->*this->Method1)();
383 else if (this->Method2)
385 (handler->*this->Method2)(caller, event, calldata);
387 else if (this->Method3)
389 return (handler->*this->Method3)(caller, event, calldata);
400 unsigned long AddTemplatedObserver(
401 unsigned long event, vtkClassMemberCallbackBase* callable,
float priority);
403 friend class vtkObjectCommandInternal;
abstract base class for most VTK objects
Definition: vtkObjectBase.h:63
abstract base class for most VTK objects
Definition: vtkObject.h:54
unsigned long AddObserver(unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
Definition: vtkObject.h:216
static void SetGlobalWarningDisplay(int val)
int InvokeEvent(unsigned long event, void *callData)
unsigned long AddObserver(unsigned long event, vtkCommand *, float priority=0.0f)
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
void SetDebug(bool debugFlag)
static void BreakOnError()
virtual vtkMTimeType GetMTime()
unsigned long AddObserver(unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
Definition: vtkObject.h:188