41#include "vtkCommonCoreModule.h"
48VTK_ABI_NAMESPACE_BEGIN
49class vtkSubjectHelper;
65 void*
operator new(
size_t tSize);
66 void operator delete(
void* p);
186 template <
class U,
class T>
188 unsigned long event, U observer,
void (T::*callback)(),
float priority = 0.0f)
190 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
193 return this->AddTemplatedObserver(event, callable, priority);
195 template <
class U,
class T>
197 void (T::*callback)(
vtkObject*,
unsigned long,
void*),
float priority = 0.0f)
199 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
202 return this->AddTemplatedObserver(event, callable, priority);
211 template <
class U,
class T>
213 bool (T::*callback)(
vtkObject*,
unsigned long,
void*),
float priority = 0.0f)
215 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
218 return this->AddTemplatedObserver(event, callable, priority);
289 class vtkClassMemberCallbackBase
296 virtual bool operator()(
vtkObject*,
unsigned long,
void*) = 0;
297 virtual ~vtkClassMemberCallbackBase() =
default;
307 class vtkClassMemberHandlerPointer
314 if ((this->VoidPointer =
dynamic_cast<T*
>(o)) ==
nullptr)
317 this->VoidPointer = o;
319 this->WeakPointer = o;
320 this->UseWeakPointer =
true;
322 void operator=(
void* o)
324 this->VoidPointer = o;
325 this->WeakPointer =
nullptr;
326 this->UseWeakPointer =
false;
330 if (this->UseWeakPointer && !this->WeakPointer.GetPointer())
334 return static_cast<T*
>(this->VoidPointer);
338 vtkWeakPointerBase WeakPointer;
349 class vtkClassMemberCallback :
public vtkClassMemberCallbackBase
351 vtkClassMemberHandlerPointer<T> Handler;
352 void (T::*Method1)();
353 void (T::*Method2)(vtkObject*,
unsigned long,
void*);
354 bool (T::*Method3)(vtkObject*,
unsigned long,
void*);
357 vtkClassMemberCallback(T* handler,
void (T::*method)())
359 this->Handler = handler;
360 this->Method1 = method;
361 this->Method2 =
nullptr;
362 this->Method3 =
nullptr;
365 vtkClassMemberCallback(T* handler,
void (T::*method)(vtkObject*,
unsigned long,
void*))
367 this->Handler = handler;
368 this->Method1 =
nullptr;
369 this->Method2 = method;
370 this->Method3 =
nullptr;
373 vtkClassMemberCallback(T* handler,
bool (T::*method)(vtkObject*,
unsigned long,
void*))
375 this->Handler = handler;
376 this->Method1 =
nullptr;
377 this->Method2 =
nullptr;
378 this->Method3 = method;
380 ~vtkClassMemberCallback()
override =
default;
383 bool operator()(vtkObject* caller,
unsigned long event,
void* calldata)
override
385 T* handler = this->Handler.GetPointer();
390 (handler->*this->Method1)();
392 else if (this->Method2)
394 (handler->*this->Method2)(caller, event, calldata);
396 else if (this->Method3)
398 return (handler->*this->Method3)(caller, event, calldata);
418 unsigned long AddTemplatedObserver(
419 unsigned long event, vtkClassMemberCallbackBase* callable,
float priority);
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 &)
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)
friend class vtkObjectCommandInternal
Called by templated variants of AddObserver.
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
vtkTypeUInt32 vtkMTimeType
#define VTK_MARSHALGETTER(property)
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALEXCLUDE(reason)