/usr/include/vtk-7.1/vtkObjectFactory.h is in libvtk7-dev 7.1.1+dfsg1-2.
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 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkObjectFactory.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.
=========================================================================*/
/**
* @class vtkObjectFactory
* @brief abstract base class for vtkObjectFactories
*
* vtkObjectFactory is used to create vtk objects. The base class
* vtkObjectFactory contains a static method CreateInstance which is used
* to create vtk objects from the list of registered vtkObjectFactory
* sub-classes. The first time CreateInstance is called, all dll's or shared
* libraries in the environment variable VTK_AUTOLOAD_PATH are loaded into
* the current process. The C functions vtkLoad, vtkGetFactoryCompilerUsed,
* and vtkGetFactoryVersion are called on each dll. To implement these
* functions in a shared library or dll, use the macro:
* VTK_FACTORY_INTERFACE_IMPLEMENT.
* VTK_AUTOLOAD_PATH is an environment variable
* containing a colon separated (semi-colon on win32) list of paths.
*
* The vtkObjectFactory can be use to override the creation of any object
* in VTK with a sub-class of that object. The factories can be registered
* either at run time with the VTK_AUTOLOAD_PATH, or at compile time
* with the vtkObjectFactory::RegisterFactory method.
*
*/
#ifndef vtkObjectFactory_h
#define vtkObjectFactory_h
#include "vtkDebugLeaksManager.h" // Must be included before singletons
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkObject.h"
class vtkObjectFactoryCollection;
class vtkOverrideInformationCollection;
class vtkCollection;
class VTKCOMMONCORE_EXPORT vtkObjectFactory : public vtkObject
{
public:
// Class Methods used to interface with the registered factories
/**
* Create and return an instance of the named vtk object.
* Each loaded vtkObjectFactory will be asked in the order
* the factory was in the VTK_AUTOLOAD_PATH. After the
* first factory returns the object no other factories are asked.
* isAbstract is no longer used. This method calls
* vtkObjectBase::InitializeObjectBase() on the instance when the
* return value is non-NULL.
*/
VTK_NEWINSTANCE
static vtkObject* CreateInstance(const char* vtkclassname,
bool isAbstract = false);
/**
* No longer used. Call vtkObjectBase::InitializeObjectBase() from the
* New() implementation instead.
* @deprecated because this method relies on taking an arbitrary string,
* which may not match the GetClassName() string (especially for templates).
*/
VTK_LEGACY(static void ConstructInstance(const char* vtkclassname));
/**
* Create all possible instances of the named vtk object.
* Each registered vtkObjectFactory will be asked, and the
* result will be stored in the user allocated vtkCollection
* passed in to the function.
*/
static void CreateAllInstance(const char* vtkclassname,
vtkCollection* retList);
/**
* Re-check the VTK_AUTOLOAD_PATH for new factory libraries.
* This calls UnRegisterAll before re-loading
*/
static void ReHash();
/**
* Register a factory so it can be used to create vtk objects
*/
static void RegisterFactory(vtkObjectFactory* );
/**
* Remove a factory from the list of registered factories
*/
static void UnRegisterFactory(vtkObjectFactory*);
/**
* Unregister all factories
*/
static void UnRegisterAllFactories();
/**
* Return the list of all registered factories. This is NOT a copy,
* do not remove items from this list!
*/
static vtkObjectFactoryCollection* GetRegisteredFactories();
/**
* return 1 if one of the registered factories
* overrides the given class name
*/
static int HasOverrideAny(const char* className);
/**
* Fill the given collection with all the overrides for
* the class with the given name.
*/
static void GetOverrideInformation(const char* name,
vtkOverrideInformationCollection*);
/**
* Set the enable flag for a given named class for all registered
* factories.
*/
static void SetAllEnableFlags(vtkTypeBool flag,
const char* className);
/**
* Set the enable flag for a given named class subclass pair
* for all registered factories.
*/
static void SetAllEnableFlags(vtkTypeBool flag,
const char* className,
const char* subclassName);
// Instance methods to be used on individual instances of vtkObjectFactory
// Methods from vtkObject
vtkTypeMacro(vtkObjectFactory,vtkObject);
/**
* Print ObjectFactory to stream.
*/
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
/**
* All sub-classes of vtkObjectFactory should must return the version of
* VTK they were built with. This should be implemented with the macro
* VTK_SOURCE_VERSION and NOT a call to vtkVersion::GetVTKSourceVersion.
* As the version needs to be compiled into the file as a string constant.
* This is critical to determine possible incompatible dynamic factory loads.
*/
virtual const char* GetVTKSourceVersion() = 0;
/**
* Return a descriptive string describing the factory.
*/
virtual const char* GetDescription() = 0;
/**
* Return number of overrides this factory can create.
*/
virtual int GetNumberOfOverrides();
/**
* Return the name of a class override at the given index.
*/
virtual const char* GetClassOverrideName(int index);
/**
* Return the name of the class that will override the class
* at the given index
*/
virtual const char* GetClassOverrideWithName(int index);
/**
* Return the enable flag for the class at the given index.
*/
virtual vtkTypeBool GetEnableFlag(int index);
/**
* Return the description for a the class override at the given
* index.
*/
virtual const char* GetOverrideDescription(int index);
//@{
/**
* Set and Get the Enable flag for the specific override of className.
* if subclassName is null, then it is ignored.
*/
virtual void SetEnableFlag(vtkTypeBool flag,
const char* className,
const char* subclassName);
virtual vtkTypeBool GetEnableFlag(const char* className,
const char* subclassName);
//@}
/**
* Return 1 if this factory overrides the given class name, 0 otherwise.
*/
virtual int HasOverride(const char* className);
/**
* Return 1 if this factory overrides the given class name, 0 otherwise.
*/
virtual int HasOverride(const char* className, const char* subclassName);
/**
* Set all enable flags for the given class to 0. This will
* mean that the factory will stop producing class with the given
* name.
*/
virtual void Disable(const char* className);
//@{
/**
* This returns the path to a dynamically loaded factory.
*/
vtkGetStringMacro(LibraryPath);
//@}
typedef vtkObject* (*CreateFunction)();
protected:
/**
* Register object creation information with the factory.
*/
void RegisterOverride(const char* classOverride,
const char* overrideClassName,
const char* description,
int enableFlag,
CreateFunction createFunction);
/**
* This method is provided by sub-classes of vtkObjectFactory.
* It should create the named vtk object or return 0 if that object
* is not supported by the factory implementation.
*/
virtual vtkObject* CreateObject(const char* vtkclassname );
vtkObjectFactory();
~vtkObjectFactory() VTK_OVERRIDE;
struct OverrideInformation
{
char* Description;
char* OverrideWithName;
vtkTypeBool EnabledFlag;
CreateFunction CreateCallback;
};
OverrideInformation* OverrideArray;
char** OverrideClassNames;
int SizeOverrideArray;
int OverrideArrayLength;
private:
void GrowOverrideArray();
/**
* Initialize the static members of vtkObjectFactory. RegisterDefaults
* is called here.
*/
static void Init();
/**
* Register default factories which are not loaded at run time.
*/
static void RegisterDefaults();
/**
* Load dynamic factories from the VTK_AUTOLOAD_PATH
*/
static void LoadDynamicFactories();
/**
* Load all dynamic libraries in the given path
*/
static void LoadLibrariesInPath( const char*);
// list of registered factories
static vtkObjectFactoryCollection* RegisteredFactories;
// member variables for a factory set by the base class
// at load or register time
void* LibraryHandle;
char* LibraryVTKVersion;
char* LibraryCompilerUsed;
char* LibraryPath;
private:
vtkObjectFactory(const vtkObjectFactory&) VTK_DELETE_FUNCTION;
void operator=(const vtkObjectFactory&) VTK_DELETE_FUNCTION;
};
// Implementation detail for Schwartz counter idiom.
class VTKCOMMONCORE_EXPORT vtkObjectFactoryRegistryCleanup
{
public:
vtkObjectFactoryRegistryCleanup();
~vtkObjectFactoryRegistryCleanup();
private:
vtkObjectFactoryRegistryCleanup(const vtkObjectFactoryRegistryCleanup& other) VTK_DELETE_FUNCTION;
vtkObjectFactoryRegistryCleanup& operator=(const vtkObjectFactoryRegistryCleanup& rhs) VTK_DELETE_FUNCTION;
};
static vtkObjectFactoryRegistryCleanup vtkObjectFactoryRegistryCleanupInstance;
// Macro to create an object creation function.
// The name of the function will by vtkObjectFactoryCreateclassname
// where classname is the name of the class being created
#define VTK_CREATE_CREATE_FUNCTION(classname) \
static vtkObject* vtkObjectFactoryCreate##classname() \
{ return classname::New(); }
#endif
#define VTK_FACTORY_INTERFACE_EXPORT VTKCOMMONCORE_EXPORT
// Macro to create the interface "C" functions used in
// a dll or shared library that contains a VTK object factory.
// Put this function in the .cxx file of your object factory,
// and pass in the name of the factory sub-class that you want
// the dll to create.
#define VTK_FACTORY_INTERFACE_IMPLEMENT(factoryName) \
extern "C" \
VTK_FACTORY_INTERFACE_EXPORT \
const char* vtkGetFactoryCompilerUsed() \
{ \
return VTK_CXX_COMPILER; \
} \
extern "C" \
VTK_FACTORY_INTERFACE_EXPORT \
const char* vtkGetFactoryVersion() \
{ \
return VTK_SOURCE_VERSION; \
} \
extern "C" \
VTK_FACTORY_INTERFACE_EXPORT \
vtkObjectFactory* vtkLoad() \
{ \
return factoryName ::New(); \
}
// Macro to implement the body of the object factory form of the New() method.
#define VTK_OBJECT_FACTORY_NEW_BODY(thisClass) \
vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, false); \
if(ret) \
{ \
return static_cast<thisClass*>(ret); \
} \
thisClass *result = new thisClass; \
result->InitializeObjectBase(); \
return result;
// Macro to implement the body of the abstract object factory form of the New()
// method, i.e. an abstract base class that can only be instantiated if the
// object factory overrides it.
#define VTK_ABSTRACT_OBJECT_FACTORY_NEW_BODY(thisClass) \
vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, true); \
if(ret) \
{ \
return static_cast<thisClass*>(ret); \
} \
vtkGenericWarningMacro("Error: no override found for '" #thisClass "'."); \
return NULL;
// Macro to implement the body of the standard form of the New() method.
#if defined(VTK_ALL_NEW_OBJECT_FACTORY)
# define VTK_STANDARD_NEW_BODY(thisClass) \
VTK_OBJECT_FACTORY_NEW_BODY(thisClass)
#else
# define VTK_STANDARD_NEW_BODY(thisClass) \
thisClass *result = new thisClass; \
result->InitializeObjectBase(); \
return result;
#endif
// Macro to implement the standard form of the New() method.
#define vtkStandardNewMacro(thisClass) \
thisClass* thisClass::New() \
{ \
VTK_STANDARD_NEW_BODY(thisClass) \
}
// Macro to implement the object factory form of the New() method.
#define vtkObjectFactoryNewMacro(thisClass) \
thisClass* thisClass::New() \
{ \
VTK_OBJECT_FACTORY_NEW_BODY(thisClass) \
}
// Macro to implement the abstract object factory form of the New() method.
// That is an abstract base class that can only be instantiated if the
// object factory overrides it.
#define vtkAbstractObjectFactoryNewMacro(thisClass) \
thisClass* thisClass::New() \
{ \
VTK_ABSTRACT_OBJECT_FACTORY_NEW_BODY(thisClass) \
}
|