Orfeo Toolbox  3.16
Classes | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
itk::fem::FEMObjectFactory< T > Class Template Reference

Create objects of derived classes by specifying a class ID. More...

#include <itkFEMObjectFactory.h>

+ Inheritance diagram for itk::fem::FEMObjectFactory< T >:
+ Collaboration diagram for itk::fem::FEMObjectFactory< T >:

Classes

class  Dummy
 This class is defined in FEMObjectFactory just to get rid of some warnings about destructor being private in gcc. More...
 

Static Public Member Functions

static int ClassName2ID (StrClassName str)
 
static T::Pointer Create (int id)
 
static StrClassName ID2ClassName (int id)
 
static int Register (COF f, const char *str)
 

Private Types

typedef T::Pointer(* COF )()
 
typedef std::vector< std::pair
< COF, StrClassName > > 
COF_Array
 
typedef COF_Array::value_type COF_Array_value_type
 
typedef std::string StrClassName
 

Private Member Functions

 FEMObjectFactory ()
 
 FEMObjectFactory (const FEMObjectFactory &)
 
 ~FEMObjectFactory ()
 

Static Private Member Functions

static void CleanUP ()
 
static FEMObjectFactoryInstance ()
 

Private Attributes

COF_Array cofs_
 
SimpleFastMutexLock m_MutexLock
 

Static Private Attributes

static FEMObjectFactoryobj = 0
 

Friends

class Dummy
 

Detailed Description

template<class T>
class itk::fem::FEMObjectFactory< T >

Create objects of derived classes by specifying a class ID.

ObjectFactory is used to create various objects of derived classes by specifying an ID of a derived class. Before the objects can be created by object factory, you should first call the Register method for each class:

int ID_Derived=FEMObjectFactory<BaseClass>.Register( NewDerivedClass, "NewDerivedClassName" );

You should also put the NewDerivedClass function in an anonymous namespace and make it static. So a complete registration of a derived class looks like:

Definition at line 66 of file itkFEMObjectFactory.h.

Member Typedef Documentation

template<class T>
typedef T::Pointer(* itk::fem::FEMObjectFactory< T >::COF)()
private

Type that holds a pointer to function which can create a new object of a derived class.

Definition at line 72 of file itkFEMObjectFactory.h.

template<class T>
typedef std::vector<std::pair<COF,StrClassName> > itk::fem::FEMObjectFactory< T >::COF_Array
private

Type that holds an array of pairs of the COF pointers to functions and class names.

Definition at line 82 of file itkFEMObjectFactory.h.

template<class T>
typedef COF_Array::value_type itk::fem::FEMObjectFactory< T >::COF_Array_value_type
private

Definition at line 83 of file itkFEMObjectFactory.h.

template<class T>
typedef std::string itk::fem::FEMObjectFactory< T >::StrClassName
private

Type that holds class name as a string.

Definition at line 77 of file itkFEMObjectFactory.h.

Constructor & Destructor Documentation

template<class T >
itk::fem::FEMObjectFactory< T >::FEMObjectFactory ( )
private

Private constructor. This class is implemented as a singleton, so we don't allow anybody from outside to construct it.

Definition at line 202 of file itkFEMObjectFactory.h.

template<class T >
itk::fem::FEMObjectFactory< T >::FEMObjectFactory ( const FEMObjectFactory< T > &  )
private

Private copy constructor.

Definition at line 205 of file itkFEMObjectFactory.h.

template<class T >
itk::fem::FEMObjectFactory< T >::~FEMObjectFactory ( )
private

Private destructor.

Definition at line 208 of file itkFEMObjectFactory.h.

Member Function Documentation

template<class T>
static int itk::fem::FEMObjectFactory< T >::ClassName2ID ( StrClassName  str)
inlinestatic

Find the ID of the class with specified name (this is a slow function). If you have to create many objects of the same class, obtain the class ID with this function first and then use that ID with the Create member function.

Definition at line 125 of file itkFEMObjectFactory.h.

template<class T >
void itk::fem::FEMObjectFactory< T >::CleanUP ( )
staticprivate

Deletes the object in obj member. This function is called when application finishes (atexit() function).

Definition at line 239 of file itkFEMObjectFactory.h.

template<class T>
static T::Pointer itk::fem::FEMObjectFactory< T >::Create ( int  id)
inlinestatic

Create a new object based on class identifier id and return a pointer to it.

Definition at line 90 of file itkFEMObjectFactory.h.

template<class T>
static StrClassName itk::fem::FEMObjectFactory< T >::ID2ClassName ( int  id)
inlinestatic

Return the name of the class (as a string) for the given ID.

Definition at line 114 of file itkFEMObjectFactory.h.

template<class T >
FEMObjectFactory< T > & itk::fem::FEMObjectFactory< T >::Instance ( )
inlinestaticprivate

Access to the only instance of the FEMObjectFactory object.

Create a new FEMObjectFactory object if we don't have it already.

Make sure that the object that ws just created is also destroyed when program finishes.

Return the actual FEMObjectFactory object

Definition at line 215 of file itkFEMObjectFactory.h.

Referenced by itk::fem::FEMObjectFactory< FEMLightObject >::ClassName2ID(), itk::fem::FEMObjectFactory< FEMLightObject >::Create(), itk::fem::FEMObjectFactory< FEMLightObject >::ID2ClassName(), and itk::fem::FEMObjectFactory< FEMLightObject >::Register().

template<class T>
static int itk::fem::FEMObjectFactory< T >::Register ( COF  f,
const char *  str 
)
inlinestatic

Register the class with the factory. A pointer to a 'create' function and class name as a string must be provided. Function returns the newly assigned ID of the class, which can be later used to create objects of that class.

Definition at line 101 of file itkFEMObjectFactory.h.

Friends And Related Function Documentation

template<class T>
friend class Dummy
friend

By defining a Dummy friend class, some warnings in gcc about destructor being private are eliminated.

Definition at line 193 of file itkFEMObjectFactory.h.

Member Data Documentation

template<class T>
COF_Array itk::fem::FEMObjectFactory< T >::cofs_
private
template<class T>
SimpleFastMutexLock itk::fem::FEMObjectFactory< T >::m_MutexLock
mutableprivate

Mutex lock to protect modification to the cofs_ array during class registration.

Definition at line 147 of file itkFEMObjectFactory.h.

Referenced by itk::fem::FEMObjectFactory< FEMLightObject >::Register().

template<class T>
FEMObjectFactory< T > * itk::fem::FEMObjectFactory< T >::obj = 0
staticprivate

Pointer to the only instance of the FEMObjectFactory class.

Definition at line 179 of file itkFEMObjectFactory.h.


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

Generated at Sun May 12 2013 03:02:12 for Orfeo Toolbox with doxygen 1.8.3.1