|
latest version v1.9 - last update 10 Apr 2010 |
|
This class defines a factory for objects. More...
#include <ltiObjectFactory.h>


Public Member Functions | |
| objectFactory (const char **names, const T *const *objs) | |
| objectFactory (const T *const *objs) | |
| virtual | ~objectFactory () |
| virtual const char * | getTypeName () const |
| virtual T * | newInstance (const char *name) const |
| virtual T * | newInstance (const std::string &name) const |
This class defines a factory for objects.
The instantiation of this class will fail if the template argument T is not a class which defines the clone() method. Usually, you will use an instance of this class as a class variable (C jargon: static class member). This class is thread-safe.
Please note that the C-type lists used in the constructor must be null-terminated.
| lti::objectFactory< T >::objectFactory | ( | const char ** | names, | |
| const T *const * | objs | |||
| ) |
Constructor.
Creates an object factory which is able to handle the types whose names and prototypes are given in these two tables. names is an array of (char*) which must be terminated by a null pointer. objs is a corresponding array of object pointers, and must also be null-terminated. Example:
const char* names[]={ "object1", "object2", "object3", 0 }; const obj_type* prototypes[] = { new object1(), new object2(), new object3(), 0 }; objectFactor<obj_type> t(names,prototypes);
| lti::objectFactory< T >::objectFactory | ( | const T *const * | objs | ) |
Constructor.
Creates an object factory which is able to handle the types whose prototypes are given in this table. The parameter is a null-terminated array of pointers.
The names of the prototypes are determined via the className functor.
Example:
const obj_type* prototypes[] = { new object1(), new object2(), new object3(), 0 }; objectFactor<obj_type> t(prototypes);
| objs | array of pointers to const objects. It must be null-terminated. |
| virtual lti::objectFactory< T >::~objectFactory | ( | ) | [virtual] |
Destructor.
| virtual const char* lti::objectFactory< T >::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("objectFactory")
Reimplemented from lti::object.
| virtual T* lti::objectFactory< T >::newInstance | ( | const std::string & | name | ) | const [inline, virtual] |
Creates a new instance of the class whose name is given as parameter, if this class is known to the factory.
Otherwise, it returns null.
| name | name of the to-be instantiated class. |
| virtual T* lti::objectFactory< T >::newInstance | ( | const char * | name | ) | const [virtual] |
Creates a new instance of the class whose name is given as parameter, if this class is known to the factory.
Otherwise, it returns null.
| name | name of the to-be instantiated class. |
Referenced by lti::objectFactory< splitImage >::newInstance().