38#include "vtkCommonCoreModule.h"
44VTK_ABI_NAMESPACE_BEGIN
45class vtkSubjectHelper;
61 void*
operator new(
size_t tSize);
62 void operator delete(
void* p);
179 template <
class U,
class T>
181 unsigned long event, U observer,
void (T::*callback)(), float priority = 0.0f)
183 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
186 return this->AddTemplatedObserver(event, callable, priority);
188 template <
class U,
class T>
190 void (T::*callback)(
vtkObject*, unsigned long, void*), float priority = 0.0f)
192 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
195 return this->AddTemplatedObserver(event, callable, priority);
204 template <
class U,
class T>
206 bool (T::*callback)(
vtkObject*, unsigned long, void*), float priority = 0.0f)
208 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
211 return this->AddTemplatedObserver(event, callable, priority);
282 class vtkClassMemberCallbackBase
289 virtual bool operator()(
vtkObject*,
unsigned long,
void*) = 0;
290 virtual ~vtkClassMemberCallbackBase() =
default;
300 class vtkClassMemberHandlerPointer
307 if ((this->VoidPointer =
dynamic_cast<T*
>(o)) ==
nullptr)
310 this->VoidPointer = o;
312 this->WeakPointer = o;
313 this->UseWeakPointer =
true;
315 void operator=(
void* o)
317 this->VoidPointer = o;
318 this->WeakPointer =
nullptr;
319 this->UseWeakPointer =
false;
323 if (this->UseWeakPointer && !this->WeakPointer.GetPointer())
327 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*);
350 vtkClassMemberCallback(T* handler,
void (T::*method)())
352 this->Handler = handler;
353 this->Method1 = method;
354 this->Method2 =
nullptr;
355 this->Method3 =
nullptr;
358 vtkClassMemberCallback(T* handler,
void (T::*method)(
vtkObject*, unsigned long, void*))
360 this->Handler = handler;
361 this->Method1 =
nullptr;
362 this->Method2 = method;
363 this->Method3 =
nullptr;
366 vtkClassMemberCallback(T* handler,
bool (T::*method)(
vtkObject*, unsigned long, void*))
368 this->Handler = handler;
369 this->Method1 =
nullptr;
370 this->Method2 =
nullptr;
371 this->Method3 = method;
373 ~vtkClassMemberCallback()
override =
default;
376 bool operator()(
vtkObject* caller,
unsigned long event,
void* calldata)
override
378 T* handler = this->Handler.GetPointer();
383 (handler->*this->Method1)();
385 else if (this->Method2)
387 (handler->*this->Method2)(caller, event, calldata);
389 else if (this->Method3)
391 return (handler->*this->Method3)(caller, event, calldata);
411 unsigned long AddTemplatedObserver(
412 unsigned long event, vtkClassMemberCallbackBase* callable,
float priority);
414 friend class vtkObjectCommandInternal;
superclass for callback/observer methods
a simple class to control print indentation
abstract base class for most VTK objects
virtual void ObjectFinalize()
void operator=(const vtkObjectBase &)
abstract base class for most VTK objects
vtkBaseTypeMacro(vtkObject, vtkObjectBase)
void InternalReleaseFocus()
These methods allow a command to exclusively grab all events.
virtual void DebugOn()
Turn debugging output on.
vtkTypeBool HasObserver(unsigned long event)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RemoveObservers(const char *event)
vtkSubjectHelper * SubjectHelper
std::string GetObjectDescription() const override
The object description printed in messages and PrintSelf output.
static void SetGlobalWarningDisplay(vtkTypeBool val)
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.
vtkTypeBool HasObserver(const char *event, vtkCommand *)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
virtual void DebugOff()
Turn debugging output off.
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.
vtkTypeBool InvokeEvent(unsigned long event)
void InternalGrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
These methods allow a command to exclusively grab all events.
void RemoveObserver(vtkCommand *)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
void RemoveObservers(unsigned long event, vtkCommand *)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
virtual std::string GetObjectName() const
Set/get the name of this object for reporting purposes.
void UnRegisterInternal(vtkObjectBase *, vtkTypeBool check) override
void RemoveAllObservers()
void RegisterInternal(vtkObjectBase *, vtkTypeBool check) override
vtkTypeBool InvokeEvent(const char *event)
static void GlobalWarningDisplayOff()
This is a global flag that controls whether any debug, warning or error messages are displayed.
virtual void Modified()
Update the modification time for this object.
vtkTypeBool HasObserver(unsigned long event, vtkCommand *)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
vtkTypeBool InvokeEvent(unsigned long event, void *callData)
This method invokes an event and return whether the event was aborted or not.
unsigned long AddObserver(unsigned long event, vtkCommand *, float priority=0.0f)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
void RemoveObservers(const char *event, vtkCommand *)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
unsigned long AddObserver(const char *event, vtkCommand *, float priority=0.0f)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
void SetDebug(bool debugFlag)
Set the value of the debug flag.
vtkTypeBool HasObserver(const char *event)
static void BreakOnError()
This method is called when vtkErrorMacro executes.
static void GlobalWarningDisplayOn()
This is a global flag that controls whether any debug, warning or error messages are displayed.
bool GetDebug()
Get the value of the debug flag.
virtual vtkMTimeType GetMTime()
Return this object's modified time.
void RemoveObservers(unsigned long event)
virtual void SetObjectName(const std::string &objectName)
Set/get the name of this object for reporting purposes.
void RemoveObserver(unsigned long tag)
static vtkTypeBool GetGlobalWarningDisplay()
This is a global flag that controls whether any debug, warning or error messages are displayed.
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.
vtkCommand * GetCommand(unsigned long tag)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
vtkTypeBool InvokeEvent(const char *event, void *callData)
This method invokes an event and return whether the event was aborted or not.
record modification and/or execution time
Non-templated superclass for vtkWeakPointer.
vtkTypeUInt32 vtkMTimeType