OpenRTM-aist  1.2.1
Classes | Public Types | Public Member Functions | List of all members
coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor > Class Template Reference

Factory template class. More...

#include <Factory.h>

Inheritance diagram for coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >:
Inheritance graph
[legend]

Public Types

enum  ReturnCode {
  FACTORY_OK, FACTORY_ERROR, ALREADY_EXISTS, NOT_FOUND,
  INVALID_ARG, UNKNOWN_ERROR
}
 
typedef std::map< Identifier, FactoryEntry > FactoryMap
 
typedef FactoryMap::iterator FactoryMapIt
 
typedef std::map< AbstractClass *, FactoryEntry > ObjectMap
 
typedef ObjectMap::iterator ObjectMapIt
 

Public Member Functions

bool hasFactory (const Identifier &id)
 Factory presence check. More...
 
std::vector< Identifier > getIdentifiers ()
 Get factory ID list. More...
 
ReturnCode addFactory (const Identifier &id, Creator creator, Destructor destructor)
 Add factory. More...
 
ReturnCode removeFactory (const Identifier &id)
 Remove factory. More...
 
AbstractClass * createObject (const Identifier &id)
 Create factory object. More...
 
ReturnCode deleteObject (const Identifier &id, AbstractClass *&obj)
 Delete factory object. More...
 
ReturnCode deleteObject (AbstractClass *&obj)
 Delete factory object. More...
 
std::vector< AbstractClass * > createdObjects ()
 Getting created objects. More...
 
bool isProducerOf (AbstractClass *obj)
 Whether a object is a product of this factory. More...
 
ReturnCode objectToIdentifier (AbstractClass *obj, Identifier &id)
 Getting class identifier (ID) from a object. More...
 
Creator objectToCreator (AbstractClass *obj)
 Getting destructor of the object. More...
 
Destructor objectToDestructor (AbstractClass *obj)
 Getting destructor of the object. More...
 

Detailed Description

template<class AbstractClass, typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
class coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >

Factory template class.

Member Typedef Documentation

template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
typedef std::map<Identifier, FactoryEntry> coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::FactoryMap
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
typedef FactoryMap::iterator coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::FactoryMapIt
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
typedef std::map<AbstractClass*, FactoryEntry> coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::ObjectMap
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
typedef ObjectMap::iterator coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::ObjectMapIt

Member Enumeration Documentation

template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
enum coil::Factory::ReturnCode
Enumerator
FACTORY_OK 
FACTORY_ERROR 
ALREADY_EXISTS 
NOT_FOUND 
INVALID_ARG 
UNKNOWN_ERROR 

Member Function Documentation

template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::addFactory ( const Identifier &  id,
Creator  creator,
Destructor  destructor 
)
inline

Add factory.

Add a factory.

Parameters
idFactory ID.
creatorFunctor for creator.
destructorFunctor for destructor.
Returns
FACTORY_OK: Successful ALREADY_EXISTS: already exists. INVALID_ARG: creator or destructor with invalid values.
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
std::vector<AbstractClass*> coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::createdObjects ( )
inline

Getting created objects.

This operation returns a list of created objects by the factory.

Returns
created object list
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
AbstractClass* coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::createObject ( const Identifier &  id)
inline

Create factory object.

Create a factory object.

Parameters
idFactory ID.
Returns
Pointer of AbstractClass
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::deleteObject ( const Identifier &  id,
AbstractClass *&  obj 
)
inline

Delete factory object.

Delete a factory object.

Parameters
idFactory ID.
objFactory object.
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::deleteObject ( AbstractClass *&  obj)
inline

Delete factory object.

Delete a factory object.

Parameters
objFactory object.
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
std::vector<Identifier> coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::getIdentifiers ( )
inline

Get factory ID list.

Return a list of factory ID.

Returns
ID list
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
bool coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::hasFactory ( const Identifier &  id)
inline

Factory presence check.

Return a factory having ID or not.

Parameters
idFactory ID.
Returns
true: found, false: not found
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
bool coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::isProducerOf ( AbstractClass *  obj)
inline

Whether a object is a product of this factory.

Parameters
objA target object
Returns
true: The object is a product of the factory false: The object is not a product of the factory
created object list
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
Creator coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::objectToCreator ( AbstractClass *  obj)
inline

Getting destructor of the object.

This operation returns a constructor of the object created by the factory. obj must be a product of the factory. User must check if the object is a product of the factory by using isProducerOf()-function, before using this function.

Returns
destructor of the object
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
Destructor coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::objectToDestructor ( AbstractClass *  obj)
inline

Getting destructor of the object.

This operation returns a destructor of the object created by the factory. obj must be a product of the factory. User must check if the object is a product of the factory by using isProducerOf()-function, before using this function.

Returns
destructor of the object

References coil::Destructor().

template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::objectToIdentifier ( AbstractClass *  obj,
Identifier &  id 
)
inline

Getting class identifier (ID) from a object.

This operation returns a class identifier (ID) from a object.

Parameters
obj[in] An object to investigate its class ID.
id[out] Class identifier (ID)
Returns
Return code NOT_FOUND: ID not found FACTORY_OK: normal return
template<class AbstractClass , typename Identifier = std::string, typename Compare = std::less<Identifier>, typename Creator = AbstractClass* (*)(), typename Destructor = void (*)(AbstractClass*&)>
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::removeFactory ( const Identifier &  id)
inline

Remove factory.

Remove a factory.

Parameters
idFactory ID.
Returns
FACTORY_OK: Successful NOT_FOUND: ID not found

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