/usr/include/vtk-6.3/vtkObject.h is in libvtk6-dev 6.3.0+dfsg1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkObject.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkObject - abstract base class for most VTK objects
// .SECTION Description
// vtkObject is the base class for most objects in the visualization
// toolkit. vtkObject provides methods for tracking modification time,
// debugging, printing, and event callbacks. Most objects created
// within the VTK framework should be a subclass of vtkObject or one
// of its children. The few exceptions tend to be very small helper
// classes that usually never get instantiated or situations where
// multiple inheritance gets in the way. vtkObject also performs
// reference counting: objects that are reference counted exist as
// long as another object uses them. Once the last reference to a
// reference counted object is removed, the object will spontaneously
// destruct.
// .SECTION Caveats
// Note: in VTK objects should always be created with the New() method
// and deleted with the Delete() method. VTK objects cannot be
// allocated off the stack (i.e., automatic objects) because the
// constructor is a protected method.
// .SECTION See also
// vtkCommand vtkTimeStamp
#ifndef vtkObject_h
#define vtkObject_h
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkObjectBase.h"
#include "vtkSetGet.h"
#include "vtkTimeStamp.h"
#include "vtkWeakPointerBase.h" // needed for vtkWeakPointer
class vtkSubjectHelper;
class vtkCommand;
class VTKCOMMONCORE_EXPORT vtkObject : public vtkObjectBase
{
public:
vtkTypeMacro(vtkObject,vtkObjectBase);
// Description:
// Create an object with Debug turned off, modified time initialized
// to zero, and reference counting on.
static vtkObject *New();
#ifdef _WIN32
// avoid dll boundary problems
void* operator new( size_t tSize );
void operator delete( void* p );
#endif
// Description:
// Turn debugging output on.
virtual void DebugOn();
// Description:
// Turn debugging output off.
virtual void DebugOff();
// Description:
// Get the value of the debug flag.
bool GetDebug();
// Description:
// Set the value of the debug flag. A true value turns debugging on.
void SetDebug(bool debugFlag);
// Description:
// This method is called when vtkErrorMacro executes. It allows
// the debugger to break on error.
static void BreakOnError();
// Description:
// Update the modification time for this object. Many filters rely on
// the modification time to determine if they need to recompute their
// data. The modification time is a unique monotonically increasing
// unsigned long integer.
virtual void Modified();
// Description:
// Return this object's modified time.
virtual unsigned long GetMTime();
// Description:
// Methods invoked by print to print information about the object
// including superclasses. Typically not called by the user (use
// Print() instead) but used in the hierarchical print process to
// combine the output of several classes.
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// This is a global flag that controls whether any debug, warning
// or error messages are displayed.
static void SetGlobalWarningDisplay(int val);
static void GlobalWarningDisplayOn(){vtkObject::SetGlobalWarningDisplay(1);};
static void GlobalWarningDisplayOff()
{vtkObject::SetGlobalWarningDisplay(0);};
static int GetGlobalWarningDisplay();
//BTX
// Description:
// Allow people to add/remove/invoke observers (callbacks) to any VTK
// object. This is an implementation of the subject/observer design
// pattern. An observer is added by specifying an event to respond to
// and a vtkCommand to execute. It returns an unsigned long tag which
// can be used later to remove the event or retrieve the command.
// When events are invoked, the observers are called in the order they
// were added. If a priority value is specified, then the higher
// priority commands are called first. A command may set an abort
// flag to stop processing of the event. (See vtkCommand.h for more
// information.)
unsigned long AddObserver(unsigned long event, vtkCommand *,
float priority=0.0f);
unsigned long AddObserver(const char *event, vtkCommand *,
float priority=0.0f);
vtkCommand *GetCommand(unsigned long tag);
void RemoveObserver(vtkCommand*);
void RemoveObservers(unsigned long event, vtkCommand *);
void RemoveObservers(const char *event, vtkCommand *);
int HasObserver(unsigned long event, vtkCommand *);
int HasObserver(const char *event, vtkCommand *);
//ETX
void RemoveObserver(unsigned long tag);
void RemoveObservers(unsigned long event);
void RemoveObservers(const char *event);
void RemoveAllObservers(); //remove every last one of them
int HasObserver(unsigned long event);
int HasObserver(const char *event);
//BTX
// Description:
// Overloads to AddObserver that allow developers to add class member
// functions as callbacks for events. The callback function can
// be one of these two types:
// \code
// void foo(void);\n
// void foo(vtkObject*, unsigned long, void*);
// \endcode
// If the callback is a member of a vtkObjectBase-derived object,
// then the callback will automatically be disabled if the object
// destructs (but the observer will not automatically be removed).
// If the callback is a member of any other type of object, then
// the observer must be removed before the object destructs or else
// its dead pointer will be used the next time the event occurs.
// Typical usage of these functions is as follows:
// \code
// SomeClassOfMine* observer = SomeClassOfMine::New();\n
// to_observe->AddObserver(event, observer, \&SomeClassOfMine::SomeMethod);
// \endcode
// Note that this does not affect the reference count of a
// vtkObjectBase-derived \c observer, which can be safely deleted
// with the observer still in place. For non-vtkObjectBase observers,
// the observer should never be deleted before it is removed.
// Return value is a tag that can be used to remove the observer.
template <class U, class T>
unsigned long AddObserver(unsigned long event,
U observer, void (T::*callback)(), float priority=0.0f)
{
vtkClassMemberCallback<T> *callable =
new vtkClassMemberCallback<T>(observer, callback);
// callable is deleted when the observer is cleaned up (look at
// vtkObjectCommandInternal)
return this->AddTemplatedObserver(event, callable, priority);
}
template <class U, class T>
unsigned long AddObserver(unsigned long event,
U observer, void (T::*callback)(vtkObject*, unsigned long, void*),
float priority=0.0f)
{
vtkClassMemberCallback<T> *callable =
new vtkClassMemberCallback<T>(observer, callback);
// callable is deleted when the observer is cleaned up (look at
// vtkObjectCommandInternal)
return this->AddTemplatedObserver(event, callable, priority);
}
// Description:
// Allow user to set the AbortFlagOn() with the return value of the callback
// method.
template <class U, class T>
unsigned long AddObserver(unsigned long event,
U observer, bool (T::*callback)(vtkObject*, unsigned long, void*),
float priority=0.0f)
{
vtkClassMemberCallback<T> *callable =
new vtkClassMemberCallback<T>(observer, callback);
// callable is deleted when the observer is cleaned up (look at
// vtkObjectCommandInternal)
return this->AddTemplatedObserver(event, callable, priority);
}
//ETX
//BTX
// Description:
// This method invokes an event and return whether the event was
// aborted or not. If the event was aborted, the return value is 1,
// otherwise it is 0.
int InvokeEvent(unsigned long event, void *callData);
int InvokeEvent(const char *event, void *callData);
//ETX
int InvokeEvent(unsigned long event) { return this->InvokeEvent(event, NULL); };
int InvokeEvent(const char *event) { return this->InvokeEvent(event, NULL); };
protected:
vtkObject();
virtual ~vtkObject();
// See vtkObjectBase.h.
virtual void RegisterInternal(vtkObjectBase*, int check);
virtual void UnRegisterInternal(vtkObjectBase*, int check);
bool Debug; // Enable debug messages
vtkTimeStamp MTime; // Keep track of modification time
vtkSubjectHelper *SubjectHelper; // List of observers on this object
//BTX
// Description:
// These methods allow a command to exclusively grab all events. (This
// method is typically used by widgets to grab events once an event
// sequence begins.) These methods are provided in support of the
// public methods found in the class vtkInteractorObserver. Note that
// these methods are designed to support vtkInteractorObservers since
// they use two separate vtkCommands to watch for mouse and keypress events.
void InternalGrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL);
void InternalReleaseFocus();
//ETX
//BTX
private:
vtkObject(const vtkObject&); // Not implemented.
void operator=(const vtkObject&); // Not implemented.
// Description:
// Following classes (vtkClassMemberCallbackBase,
// vtkClassMemberCallback, and vtkClassMemberHanderPointer)
// along with vtkObjectCommandInternal are for supporting
// templated AddObserver() overloads that allow developers
// to add event callbacks that are class member functions.
class vtkClassMemberCallbackBase
{
public:
// Description:
// Called when the event is invoked
virtual bool operator()(vtkObject*, unsigned long, void*) = 0;
virtual ~vtkClassMemberCallbackBase(){}
};
// Description:
// This is a weak pointer for vtkObjectBase and a regular
// void pointer for everything else
template<class T>
class vtkClassMemberHandlerPointer
{
public:
void operator=(vtkObjectBase *o)
{
// The cast is needed in case "o" has multi-inheritance,
// to offset the pointer to get the vtkObjectBase.
if ((this->VoidPointer = dynamic_cast<T*>(o)) == 0)
{
// fallback to just using its vtkObjectBase as-is.
this->VoidPointer = o;
}
this->WeakPointer = o;
this->UseWeakPointer = true;
}
void operator=(void *o)
{
this->VoidPointer = o;
this->WeakPointer = 0;
this->UseWeakPointer = false;
}
T *GetPointer()
{
if (this->UseWeakPointer && !this->WeakPointer.GetPointer())
{
return 0;
}
return static_cast<T*>(this->VoidPointer);
}
private:
vtkWeakPointerBase WeakPointer;
void *VoidPointer;
bool UseWeakPointer;
};
// Description:
// Templated member callback.
template <class T>
class vtkClassMemberCallback : public vtkClassMemberCallbackBase
{
vtkClassMemberHandlerPointer<T> Handler;
void (T::*Method1)();
void (T::*Method2)(vtkObject*, unsigned long, void*);
bool (T::*Method3)(vtkObject*, unsigned long, void*);
public:
vtkClassMemberCallback(T* handler, void (T::*method)())
{
this->Handler = handler;
this->Method1 = method;
this->Method2 = NULL;
this->Method3 = NULL;
}
vtkClassMemberCallback(
T* handler, void (T::*method)(vtkObject*, unsigned long, void*))
{
this->Handler = handler;
this->Method1 = NULL;
this->Method2 = method;
this->Method3 = NULL;
}
vtkClassMemberCallback(
T* handler, bool (T::*method)(vtkObject*, unsigned long, void*))
{
this->Handler = handler;
this->Method1 = NULL;
this->Method2 = NULL;
this->Method3 = method;
}
virtual ~vtkClassMemberCallback() { }
// Called when the event is invoked
virtual bool operator()(
vtkObject* caller, unsigned long event, void* calldata)
{
T *handler = this->Handler.GetPointer();
if (handler)
{
if (this->Method1)
{
(handler->*this->Method1)();
}
else if (this->Method2)
{
(handler->*this->Method2)(caller, event, calldata);
}
else if (this->Method3)
{
return (handler->*this->Method3)(caller, event, calldata);
}
}
return false;
}
};
// Description:
// Called by templated variants of AddObserver.
unsigned long AddTemplatedObserver(
unsigned long event, vtkClassMemberCallbackBase* callable, float priority);
// Friend to access AddTemplatedObserver().
friend class vtkObjectCommandInternal;
//ETX
};
#endif
// VTK-HeaderTest-Exclude: vtkObject.h
|