Create objects of derived classes by specifying a class ID. More...
#include <itkFEMObjectFactory.h>
Classes | |
class | Dummy |
This class is defined in FEMObjectFactory just to get rid of some warnings about destructor being private in gcc. | |
Static Public Member Functions | |
static T::Pointer | Create (int id) |
static StrClassName | ID2ClassName (int id) |
static int | Register (COF f, const char *str) |
static int | ClassName2ID (StrClassName str) |
Friends | |
class | Dummy |
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.
static int itk::fem::FEMObjectFactory< T >::ClassName2ID | ( | StrClassName | str | ) | [inline, static] |
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 127 of file itkFEMObjectFactory.h.
static T::Pointer itk::fem::FEMObjectFactory< T >::Create | ( | int | id | ) | [inline, static] |
Create a new object based on class identifier id and return a pointer to it.
Definition at line 91 of file itkFEMObjectFactory.h.
static StrClassName itk::fem::FEMObjectFactory< T >::ID2ClassName | ( | int | id | ) | [inline, static] |
Return the name of the class (as a string) for the given ID.
Definition at line 116 of file itkFEMObjectFactory.h.
static int itk::fem::FEMObjectFactory< T >::Register | ( | COF | f, | |
const char * | str | |||
) | [inline, static] |
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 102 of file itkFEMObjectFactory.h.
friend class Dummy [friend] |
By defining a Dummy friend class, some warnings in gcc about destructor being private are eliminated.
Definition at line 196 of file itkFEMObjectFactory.h.