ITK  4.3.0
Insight Segmentation and Registration Toolkit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
itk::ObjectFactoryBase Class Referenceabstract

#include <itkObjectFactoryBase.h>

+ Inheritance diagram for itk::ObjectFactoryBase:
+ Collaboration diagram for itk::ObjectFactoryBase:

Detailed Description

Create instances of classes using an object factory.

ObjectFactoryBase is used to create itk objects. The base class ObjectFactoryBase contains a static method CreateInstance() that is used to create itk objects from the list of registerd ObjectFactoryBase sub-classes. The first time CreateInstance() is called, all dll's or shared libraries in the environment variable ITK_AUTOLOAD_PATH are loaded into the current process. The C function itkLoad is called on each dll. itkLoad should return an instance of the factory sub-class implemented in the shared library. ITK_AUTOLOAD_PATH is an environment variable containing a colon separated (semi-colon on win32) list of paths.

This can be use to overide the creation of any object in ITK.

Definition at line 58 of file itkObjectFactoryBase.h.

Classes

class  OverrideInformation
 Internal implementation class for ObjectFactorBase. More...
 

Public Types

typedef SmartPointer< const SelfConstPointer
 
enum  InsertionPositionType {
  INSERT_AT_FRONT,
  INSERT_AT_BACK,
  INSERT_AT_POSITION
}
 
typedef SmartPointer< SelfPointer
 
typedef ObjectFactoryBase Self
 
typedef Object Superclass
 
- Public Types inherited from itk::Object
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef Object Self
 
typedef LightObject Superclass
 
- Public Types inherited from itk::LightObject
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef LightObject Self
 

Public Member Functions

virtual void Disable (const char *className)
 
virtual std::list< std::string > GetClassOverrideDescriptions ()
 
virtual std::list< std::string > GetClassOverrideNames ()
 
virtual std::list< std::string > GetClassOverrideWithNames ()
 
virtual const char * GetDescription (void) const =0
 
virtual bool GetEnableFlag (const char *className, const char *subclassName)
 
virtual std::list< bool > GetEnableFlags ()
 
virtual const char * GetITKSourceVersion (void) const =0
 
const char * GetLibraryPath ()
 
virtual const char * GetNameOfClass () const
 
virtual void SetEnableFlag (bool flag, const char *className, const char *subclassName)
 
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *)
 
unsigned long AddObserver (const EventObject &event, Command *) const
 
virtual LightObject::Pointer CreateAnother () const
 
virtual void DebugOff () const
 
virtual void DebugOn () const
 
CommandGetCommand (unsigned long tag)
 
bool GetDebug () const
 
MetaDataDictionaryGetMetaDataDictionary (void)
 
const MetaDataDictionaryGetMetaDataDictionary (void) const
 
virtual ModifiedTimeType GetMTime () const
 
virtual const TimeStampGetTimeStamp () const
 
bool HasObserver (const EventObject &event) const
 
void InvokeEvent (const EventObject &)
 
void InvokeEvent (const EventObject &) const
 
virtual void Modified () const
 
virtual void Register () const
 
void RemoveAllObservers ()
 
void RemoveObserver (unsigned long tag)
 
void SetDebug (bool debugFlag) const
 
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
 
virtual void SetReferenceCount (int)
 
virtual void UnRegister () const
 
- Public Member Functions inherited from itk::LightObject
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
 itkCloneMacro (Self)
 
void Print (std::ostream &os, Indent indent=0) const
 

Static Public Member Functions

static std::list
< LightObject::Pointer
CreateAllInstance (const char *itkclassname)
 
static LightObject::Pointer CreateInstance (const char *itkclassname)
 
static std::list
< ObjectFactoryBase * > 
GetRegisteredFactories ()
 
static void RegisterFactoryInternal (ObjectFactoryBase *)
 
static void ReHash ()
 
static void UnRegisterAllFactories ()
 
static void UnRegisterFactory (ObjectFactoryBase *)
 
static void RegisterFactory (ObjectFactoryBase *, InsertionPositionType where=INSERT_AT_BACK, vcl_size_t position=0)
 
static void SetStrictVersionChecking (bool)
 
static void StrictVersionCheckingOn ()
 
static void StrictVersionCheckingOff ()
 
static bool GetStrictVersionChecking ()
 
- Static Public Member Functions inherited from itk::Object
static bool GetGlobalWarningDisplay ()
 
static void GlobalWarningDisplayOff ()
 
static void GlobalWarningDisplayOn ()
 
static Pointer New ()
 
static void SetGlobalWarningDisplay (bool flag)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

virtual std::list
< LightObject::Pointer
CreateAllObject (const char *itkclassname)
 
virtual LightObject::Pointer CreateObject (const char *itkclassname)
 
 ObjectFactoryBase ()
 
virtual void PrintSelf (std::ostream &os, Indent indent) const
 
void RegisterOverride (const char *classOverride, const char *overrideClassName, const char *description, bool enableFlag, CreateObjectFunctionBase *createFunction)
 
virtual ~ObjectFactoryBase ()
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &time)
 
virtual ~Object ()
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Private Member Functions

 ObjectFactoryBase (const Self &)
 
void operator= (const Self &)
 

Static Private Member Functions

static void Initialize ()
 
static void InitializeFactoryList ()
 
static void LoadDynamicFactories ()
 
static void LoadLibrariesInPath (const char *)
 
static void RegisterDefaults ()
 

Private Attributes

unsigned long m_LibraryDate
 
void * m_LibraryHandle
 
std::string m_LibraryPath
 
OverRideMap * m_OverrideMap
 

Static Private Attributes

static bool m_StrictVersionChecking
 

Additional Inherited Members

- Protected Types inherited from itk::LightObject
typedef int InternalReferenceCountType
 
- Protected Attributes inherited from itk::LightObject
InternalReferenceCountType m_ReferenceCount
 
SimpleFastMutexLock m_ReferenceCountLock
 

Member Typedef Documentation

Definition at line 65 of file itkObjectFactoryBase.h.

Definition at line 64 of file itkObjectFactoryBase.h.

Standard class typedefs.

Definition at line 62 of file itkObjectFactoryBase.h.

Definition at line 63 of file itkObjectFactoryBase.h.

Member Enumeration Documentation

Position at which the new factory will be registered in the internal factory container.

Enumerator:
INSERT_AT_FRONT 
INSERT_AT_BACK 
INSERT_AT_POSITION 

Definition at line 96 of file itkObjectFactoryBase.h.

Constructor & Destructor Documentation

itk::ObjectFactoryBase::ObjectFactoryBase ( )
protected
virtual itk::ObjectFactoryBase::~ObjectFactoryBase ( )
protectedvirtual
itk::ObjectFactoryBase::ObjectFactoryBase ( const Self )
private

Member Function Documentation

static std::list< LightObject::Pointer > itk::ObjectFactoryBase::CreateAllInstance ( const char *  itkclassname)
static

Create and return all possible instances of the named itk object. Each loaded ObjectFactoryBase will be asked in the order the factory was in the ITK_AUTOLOAD_PATH. All created objects will be returned in the list.

virtual std::list< LightObject::Pointer > itk::ObjectFactoryBase::CreateAllObject ( const char *  itkclassname)
protectedvirtual

This method creates all the objects with the class overide of itkclass name, which are provide by this object

static LightObject::Pointer itk::ObjectFactoryBase::CreateInstance ( const char *  itkclassname)
static

Create and return an instance of the named itk object. Each loaded ObjectFactoryBase will be asked in the order the factory was in the ITK_AUTOLOAD_PATH. After the first factory returns the object no other factories are asked.

Referenced by itk::ObjectFactory< T >::Create().

virtual LightObject::Pointer itk::ObjectFactoryBase::CreateObject ( const char *  itkclassname)
protectedvirtual

This method is provided by sub-classes of ObjectFactoryBase. It should create the named itk object or return 0 if that object is not supported by the factory implementation.

virtual void itk::ObjectFactoryBase::Disable ( const char *  className)
virtual

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 std::list< std::string > itk::ObjectFactoryBase::GetClassOverrideDescriptions ( )
virtual

Return a list of descriptions for class overrides.

virtual std::list< std::string > itk::ObjectFactoryBase::GetClassOverrideNames ( )
virtual

Return a list of classes that this factory overrides.

virtual std::list< std::string > itk::ObjectFactoryBase::GetClassOverrideWithNames ( )
virtual

Return a list of the names of classes that override classes.

virtual const char* itk::ObjectFactoryBase::GetDescription ( void  ) const
pure virtual
virtual bool itk::ObjectFactoryBase::GetEnableFlag ( const char *  className,
const char *  subclassName 
)
virtual

Get the Enable flag for the specific override of className.

virtual std::list< bool > itk::ObjectFactoryBase::GetEnableFlags ( )
virtual

Return a list of enable flags.

virtual const char* itk::ObjectFactoryBase::GetITKSourceVersion ( void  ) const
pure virtual

All sub-classes of ObjectFactoryBase should must return the version of ITK they were built with. This should be implemented with the macro ITK_SOURCE_VERSION and NOT a call to Version::GetITKSourceVersion. As the version needs to be compiled into the file as a string constant. This is critical to determine possible incompatible dynamic factory loads.

Implemented in itk::GPUImageFactory, itk::GPUDemonsRegistrationFilterFactory, itk::RawImageIOFactory< TPixel, VImageDimension >, itk::GPUBinaryThresholdImageFilterFactory, itk::GPUGradientAnisotropicDiffusionImageFilterFactory, itk::GPUMeanImageFilterFactory, itk::MRCImageIOFactory, itk::JPEG2000ImageIOFactory, itk::FEMFactoryBase, itk::BioRadImageIOFactory, itk::LSMImageIOFactory, itk::StimulateImageIOFactory, itk::VTKImageIOFactory, itk::SpatialObjectFactoryBase, itk::TransformFactoryBase, itk::Bruker2DSEQImageIOFactory, itk::MINC2ImageIOFactory, itk::VoxBoCUBImageIOFactory, itk::HDF5ImageIOFactory, itk::HDF5TransformIOFactory, itk::MatlabTransformIOFactory, itk::JPEGImageIOFactory, itk::TIFFImageIOFactory, itk::NiftiImageIOFactory, itk::PNGImageIOFactory, itk::GE4ImageIOFactory, itk::GE5ImageIOFactory, itk::GEAdwImageIOFactory, itk::SiemensVisionImageIOFactory, itk::TxtTransformIOFactory, itk::FileListVideoIOFactory, itk::BMPImageIOFactory, itk::GDCMImageIOFactory, itk::GiplImageIOFactory, itk::MetaImageIOFactory, itk::NrrdImageIOFactory, itk::BYUMeshIOFactory, itk::FreeSurferAsciiMeshIOFactory, itk::FreeSurferBinaryMeshIOFactory, itk::GiftiMeshIOFactory, itk::OBJMeshIOFactory, itk::OFFMeshIOFactory, and itk::VTKPolyDataMeshIOFactory.

const char* itk::ObjectFactoryBase::GetLibraryPath ( )

This returns the path to a dynamically loaded factory.

virtual const char* itk::ObjectFactoryBase::GetNameOfClass ( ) const
virtual
static std::list< ObjectFactoryBase * > itk::ObjectFactoryBase::GetRegisteredFactories ( )
static

Return the list of all registered factories. This is NOT a copy, do not remove items from this list!

static bool itk::ObjectFactoryBase::GetStrictVersionChecking ( )
static

Require the ITK version of this application to exactly match the ITK version used to compile a dynamic library. When this is set to true, if the versions do not match, an exception will be thrown. When this is false, and the versions do not match, only a warning message is printed out in the console, and the factory is still registered.

static void itk::ObjectFactoryBase::Initialize ( )
staticprivate

Initialize the static members of ObjectFactoryBase. RegisterDefaults() and InitializeFactoryList() are called here.

static void itk::ObjectFactoryBase::InitializeFactoryList ( )
staticprivate

Initialize the static list of Factories.

static void itk::ObjectFactoryBase::LoadDynamicFactories ( )
staticprivate

Load dynamic factories from the ITK_AUTOLOAD_PATH

static void itk::ObjectFactoryBase::LoadLibrariesInPath ( const char *  )
staticprivate

Load all dynamic libraries in the given path

void itk::ObjectFactoryBase::operator= ( const Self )
private
virtual void itk::ObjectFactoryBase::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
protectedvirtual
static void itk::ObjectFactoryBase::RegisterDefaults ( )
staticprivate

Register default factories which are not loaded at run time.

static void itk::ObjectFactoryBase::RegisterFactory ( ObjectFactoryBase ,
InsertionPositionType  where = INSERT_AT_BACK,
vcl_size_t  position = 0 
)
static

Register a factory so it can be used to create itk objects.

When INSERT_AT_POSITION is selected, a third argument must be provided
with the actual integer number of the intended position. The position
number must be in the range [0, numberOfRegisteredFactories-1].

Usage should be any of the following:

itk::ObjectFactoryBase::RegisterFactory( newFactory1 ); // at back
itk::ObjectFactoryBase::RegisterFactory( newFactory2, INSERT_AT_FRONT );
itk::ObjectFactoryBase::RegisterFactory( newFactory3, INSERT_AT_BACK );
itk::ObjectFactoryBase::RegisterFactory( newFactory4, INSERT_AT_POSITION, 5 );

If the position value is out of range, an exception will be thrown.

Referenced by itk::SpatialObjectFactoryBase::GetFactory(), itk::TransformFactoryBase::GetFactory(), itk::FEMFactoryBase::GetFactory(), ProcessArgumentsAndRegisterBuiltInFactories(), itk::FreeSurferAsciiMeshIOFactory::RegisterOneFactory(), itk::FreeSurferBinaryMeshIOFactory::RegisterOneFactory(), itk::VTKPolyDataMeshIOFactory::RegisterOneFactory(), itk::BYUMeshIOFactory::RegisterOneFactory(), itk::OFFMeshIOFactory::RegisterOneFactory(), itk::GiftiMeshIOFactory::RegisterOneFactory(), itk::OBJMeshIOFactory::RegisterOneFactory(), itk::Bruker2DSEQImageIOFactory::RegisterOneFactory(), itk::VoxBoCUBImageIOFactory::RegisterOneFactory(), itk::MINC2ImageIOFactory::RegisterOneFactory(), itk::JPEG2000ImageIOFactory::RegisterOneFactory(), itk::GPUMeanImageFilterFactory::RegisterOneFactory(), itk::GPUGradientAnisotropicDiffusionImageFilterFactory::RegisterOneFactory(), itk::GPUBinaryThresholdImageFilterFactory::RegisterOneFactory(), itk::RawImageIOFactory< TPixel, VImageDimension >::RegisterOneFactory(), itk::GPUDemonsRegistrationFilterFactory::RegisterOneFactory(), itk::GPUImageFactory::RegisterOneFactory(), and RegisterRequiredFactories().

static void itk::ObjectFactoryBase::RegisterFactoryInternal ( ObjectFactoryBase )
static
void itk::ObjectFactoryBase::RegisterOverride ( const char *  classOverride,
const char *  overrideClassName,
const char *  description,
bool  enableFlag,
CreateObjectFunctionBase createFunction 
)
protected

Register object creation information with the factory.

static void itk::ObjectFactoryBase::ReHash ( )
static

Re-check the ITK_AUTOLOAD_PATH for new factory libraries. This calls UnRegisterAll before re-loading.

virtual void itk::ObjectFactoryBase::SetEnableFlag ( bool  flag,
const char *  className,
const char *  subclassName 
)
virtual

Set the Enable flag for the specific override of className.

static void itk::ObjectFactoryBase::SetStrictVersionChecking ( bool  )
static

Require the ITK version of this application to exactly match the ITK version used to compile a dynamic library. When this is set to true, if the versions do not match, an exception will be thrown. When this is false, and the versions do not match, only a warning message is printed out in the console, and the factory is still registered.

static void itk::ObjectFactoryBase::StrictVersionCheckingOff ( )
static

Require the ITK version of this application to exactly match the ITK version used to compile a dynamic library. When this is set to true, if the versions do not match, an exception will be thrown. When this is false, and the versions do not match, only a warning message is printed out in the console, and the factory is still registered.

static void itk::ObjectFactoryBase::StrictVersionCheckingOn ( )
static

Require the ITK version of this application to exactly match the ITK version used to compile a dynamic library. When this is set to true, if the versions do not match, an exception will be thrown. When this is false, and the versions do not match, only a warning message is printed out in the console, and the factory is still registered.

static void itk::ObjectFactoryBase::UnRegisterAllFactories ( )
static

Unregister all factories.

static void itk::ObjectFactoryBase::UnRegisterFactory ( ObjectFactoryBase )
static

Remove a factory from the list of registered factories.

Member Data Documentation

unsigned long itk::ObjectFactoryBase::m_LibraryDate
private

Definition at line 242 of file itkObjectFactoryBase.h.

void* itk::ObjectFactoryBase::m_LibraryHandle
private

Member variables for a factory set by the base class at load or register time

Definition at line 241 of file itkObjectFactoryBase.h.

std::string itk::ObjectFactoryBase::m_LibraryPath
private

Definition at line 243 of file itkObjectFactoryBase.h.

OverRideMap* itk::ObjectFactoryBase::m_OverrideMap
private

Definition at line 218 of file itkObjectFactoryBase.h.

bool itk::ObjectFactoryBase::m_StrictVersionChecking
staticprivate

Definition at line 245 of file itkObjectFactoryBase.h.


The documentation for this class was generated from the following file: