38#include "vtkCommonCoreModule.h"
45VTK_ABI_NAMESPACE_BEGIN
46class vtkSubjectHelper;
62 void*
operator new(
size_t tSize);
63 void operator delete(
void* p);
183 template <
class U,
class T>
185 unsigned long event, U observer,
void (T::*callback)(),
float priority = 0.0f)
187 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
190 return this->AddTemplatedObserver(event, callable, priority);
192 template <
class U,
class T>
194 void (T::*callback)(
vtkObject*,
unsigned long,
void*),
float priority = 0.0f)
196 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
199 return this->AddTemplatedObserver(event, callable, priority);
208 template <
class U,
class T>
210 bool (T::*callback)(
vtkObject*,
unsigned long,
void*),
float priority = 0.0f)
212 vtkClassMemberCallback<T>* callable =
new vtkClassMemberCallback<T>(observer, callback);
215 return this->AddTemplatedObserver(event, callable, priority);
286 class vtkClassMemberCallbackBase
293 virtual bool operator()(
vtkObject*,
unsigned long,
void*) = 0;
294 virtual ~vtkClassMemberCallbackBase() =
default;
304 class vtkClassMemberHandlerPointer
311 if ((this->VoidPointer =
dynamic_cast<T*
>(o)) ==
nullptr)
314 this->VoidPointer = o;
316 this->WeakPointer = o;
317 this->UseWeakPointer =
true;
319 void operator=(
void* o)
321 this->VoidPointer = o;
322 this->WeakPointer =
nullptr;
323 this->UseWeakPointer =
false;
327 if (this->UseWeakPointer && !this->WeakPointer.GetPointer())
331 return static_cast<T*
>(this->VoidPointer);
335 vtkWeakPointerBase WeakPointer;
346 class vtkClassMemberCallback :
public vtkClassMemberCallbackBase
348 vtkClassMemberHandlerPointer<T> Handler;
349 void (T::*Method1)();
350 void (T::*Method2)(vtkObject*,
unsigned long,
void*);
351 bool (T::*Method3)(vtkObject*,
unsigned long,
void*);
354 vtkClassMemberCallback(T* handler,
void (T::*method)())
356 this->Handler = handler;
357 this->Method1 = method;
358 this->Method2 =
nullptr;
359 this->Method3 =
nullptr;
362 vtkClassMemberCallback(T* handler,
void (T::*method)(vtkObject*,
unsigned long,
void*))
364 this->Handler = handler;
365 this->Method1 =
nullptr;
366 this->Method2 = method;
367 this->Method3 =
nullptr;
370 vtkClassMemberCallback(T* handler,
bool (T::*method)(vtkObject*,
unsigned long,
void*))
372 this->Handler = handler;
373 this->Method1 =
nullptr;
374 this->Method2 =
nullptr;
375 this->Method3 = method;
377 ~vtkClassMemberCallback()
override =
default;
380 bool operator()(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);
415 unsigned long AddTemplatedObserver(
416 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)