50 #include "vtkCommonCoreModule.h" 52 #include "vtkSetGet.h" 56 class vtkSubjectHelper;
72 void*
operator new(
size_t tSize );
73 void operator delete(
void* p );
79 virtual void DebugOn();
84 virtual void DebugOff();
94 void SetDebug(
bool debugFlag);
100 static void BreakOnError();
108 virtual void Modified();
128 static void SetGlobalWarningDisplay(
int val);
132 static int GetGlobalWarningDisplay();
148 unsigned long AddObserver(
unsigned long event,
vtkCommand *,
150 unsigned long AddObserver(
const char *event,
vtkCommand *,
154 void RemoveObservers(
unsigned long event,
vtkCommand *);
155 void RemoveObservers(
const char *event,
vtkCommand *);
160 void RemoveObserver(
unsigned long tag);
161 void RemoveObservers(
unsigned long event);
162 void RemoveObservers(
const char *event);
163 void RemoveAllObservers();
193 template <
class U,
class T>
195 U observer,
void (T::*callback)(),
float priority=0.0f)
197 vtkClassMemberCallback<T> *callable =
198 new vtkClassMemberCallback<T>(observer, callback);
201 return this->AddTemplatedObserver(event, callable,
priority);
203 template <
class U,
class T>
205 U observer,
void (T::*callback)(
vtkObject*,
unsigned long,
void*),
208 vtkClassMemberCallback<T> *callable =
209 new vtkClassMemberCallback<T>(observer, callback);
212 return this->AddTemplatedObserver(event, callable,
priority);
221 template <
class U,
class T>
223 U observer,
bool (T::*callback)(
vtkObject*,
unsigned long,
void*),
226 vtkClassMemberCallback<T> *callable =
227 new vtkClassMemberCallback<T>(observer, callback);
230 return this->AddTemplatedObserver(event, callable,
priority);
240 int InvokeEvent(
unsigned long event,
void *callData);
241 int InvokeEvent(
const char *event,
void *callData);
269 void InternalReleaseFocus();
283 class vtkClassMemberCallbackBase
290 virtual bool operator()(
vtkObject*,
unsigned long,
void*) = 0;
291 virtual ~vtkClassMemberCallbackBase(){}
301 class vtkClassMemberHandlerPointer
308 if ((this->VoidPointer = dynamic_cast<T*>(o)) ==
nullptr)
311 this->VoidPointer = o;
313 this->WeakPointer = o;
314 this->UseWeakPointer =
true;
316 void operator=(
void *o)
318 this->VoidPointer = o;
319 this->WeakPointer =
nullptr;
320 this->UseWeakPointer =
false;
324 if (this->UseWeakPointer && !this->WeakPointer.GetPointer())
328 return static_cast<T*
>(this->VoidPointer);
342 class vtkClassMemberCallback :
public vtkClassMemberCallbackBase
344 vtkClassMemberHandlerPointer<T> Handler;
345 void (T::*Method1)();
346 void (T::*Method2)(
vtkObject*,
unsigned long,
void*);
347 bool (T::*Method3)(
vtkObject*,
unsigned long,
void*);
351 vtkClassMemberCallback(T* handler,
void (T::*method)())
353 this->Handler = handler;
354 this->Method1 = method;
355 this->Method2 =
nullptr;
356 this->Method3 =
nullptr;
359 vtkClassMemberCallback(
360 T* handler,
void (T::*method)(
vtkObject*,
unsigned long,
void*))
362 this->Handler = handler;
363 this->Method1 =
nullptr;
364 this->Method2 = method;
365 this->Method3 =
nullptr;
368 vtkClassMemberCallback(
369 T* handler,
bool (T::*method)(
vtkObject*,
unsigned long,
void*))
371 this->Handler = handler;
372 this->Method1 =
nullptr;
373 this->Method2 =
nullptr;
374 this->Method3 = method;
376 ~vtkClassMemberCallback()
override { }
380 vtkObject* caller,
unsigned long event,
void* calldata)
override 382 T *handler = this->Handler.GetPointer();
387 (handler->*this->Method1)();
389 else if (this->Method2)
391 (handler->*this->Method2)(caller, event, calldata);
393 else if (this->Method3)
395 return (handler->*this->Method3)(caller, event, calldata);
406 unsigned long AddTemplatedObserver(
407 unsigned long event, vtkClassMemberCallbackBase* callable,
float priority);
409 friend class vtkObjectCommandInternal;
unsigned long AddObserver(unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
Overloads to AddObserver that allow developers to add class member functions as callbacks for events...
static vtkObjectBase * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
abstract base class for most VTK objects
vtkTypeUInt32 vtkMTimeType
record modification and/or execution time
int InvokeEvent(unsigned long event)
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
static void GlobalWarningDisplayOff()
This is a global flag that controls whether any debug, warning or error messages are displayed...
unsigned long AddObserver(unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
Allow user to set the AbortFlagOn() with the return value of the callback method. ...
superclass for callback/observer methods
static void SetGlobalWarningDisplay(int val)
This is a global flag that controls whether any debug, warning or error messages are displayed...
a simple class to control print indentation
virtual void UnRegisterInternal(vtkObjectBase *, vtkTypeBool check)
Non-templated superclass for vtkWeakPointer.
abstract base class for most VTK objects
virtual void RegisterInternal(vtkObjectBase *, vtkTypeBool check)
int InvokeEvent(const char *event)
unsigned long AddObserver(unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
Overloads to AddObserver that allow developers to add class member functions as callbacks for events...
void operator=(const vtkObjectBase &)
vtkSubjectHelper * SubjectHelper
static void GlobalWarningDisplayOn()
This is a global flag that controls whether any debug, warning or error messages are displayed...