sofa::core::RegisterObject Class Reference

Helper class used to register a class in the ObjectFactory. More...

#include <ObjectFactory.h>

Collaboration diagram for sofa::core::RegisterObject:

Collaboration graph
[legend]

Data Structures

class  Conversion
 Test whether T* converts to U*, that is, if T is derived from U taken from Modern C++ Design. More...

Public Member Functions

 RegisterObject (const std::string &description)
 Start the registration by giving the description of this class.
RegisterObject & addAlias (std::string val)
 Add an alias name for this class.
RegisterObject & addDescription (std::string val)
 Add more descriptive text about this class.
RegisterObject & addAuthor (std::string val)
 Specify a list of authors (separated with spaces).
RegisterObject & addLicense (std::string val)
 Specify a license (LGPL, GPL, ...).
RegisterObject & addCreator (std::string classname, std::string templatename, ObjectFactory::Creator *creator)
 Add a creator able to instance this class with the given templatename.
template<class RealClass , class BaseClass >
bool implements ()
 Test whether T* converts to U*, that is, if T is derived from U.
template<class RealObject >
RegisterObject & add (bool defaultTemplate=false)
 Add a template instanciation of this class.
 operator int ()
 This is the final operation that will actually commit the additions to the ObjectFactory.

Protected Attributes

ObjectFactory::ClassEntry entry
 Class entry being constructed.

Detailed Description

Helper class used to register a class in the ObjectFactory.

This class accumulate information about a given class, as well as creators for each supported template instanciation, to register a new entry in the ObjectFactory.

It should be used as a temporary object, finalized when used to initialize an int static variable. For example :

    int Fluid3DClass = core::RegisterObject("Eulerian 3D fluid")
    .add\< Fluid3D \>()
    .addLicense("LGPL")
    .addAuthor("Jeremie Allard")
    ;

Definition at line 216 of file ObjectFactory.h.


Constructor & Destructor Documentation

sofa::core::RegisterObject::RegisterObject ( const std::string &  description  ) 

Start the registration by giving the description of this class.

Definition at line 283 of file ObjectFactory.cpp.

References addDescription().


Member Function Documentation

template<class RealObject >
RegisterObject& sofa::core::RegisterObject::add ( bool  defaultTemplate = false  )  [inline]

Add a template instanciation of this class.

Parameters:
defaultTemplate set to true if this should be the default instance when no template name is given.

Definition at line 278 of file ObjectFactory.h.

References addCreator(), sofa::core::ObjectFactory::ClassEntry::baseClasses, sofa::core::ObjectFactory::ClassEntry::defaultTemplate, and entry.

RegisterObject & sofa::core::RegisterObject::addAlias ( std::string  val  ) 

Add an alias name for this class.

Definition at line 291 of file ObjectFactory.cpp.

References sofa::core::ObjectFactory::ClassEntry::aliases, and entry.

RegisterObject & sofa::core::RegisterObject::addAuthor ( std::string  val  ) 

Specify a list of authors (separated with spaces).

Definition at line 305 of file ObjectFactory.cpp.

References sofa::core::ObjectFactory::ClassEntry::authors, and entry.

RegisterObject & sofa::core::RegisterObject::addCreator ( std::string  classname,
std::string  templatename,
ObjectFactory::Creator *  creator 
)

Add a creator able to instance this class with the given templatename.

See the add<RealObject>() method for an easy way to add a Creator.

Definition at line 320 of file ObjectFactory.cpp.

References sofa::core::ObjectFactory::ClassEntry::className, sofa::core::ObjectFactory::ClassEntry::creatorList, sofa::core::ObjectFactory::ClassEntry::creatorMap, and entry.

Referenced by add().

RegisterObject & sofa::core::RegisterObject::addDescription ( std::string  val  ) 

Add more descriptive text about this class.

Definition at line 297 of file ObjectFactory.cpp.

References sofa::core::ObjectFactory::ClassEntry::description, and entry.

Referenced by RegisterObject().

RegisterObject & sofa::core::RegisterObject::addLicense ( std::string  val  ) 

Specify a license (LGPL, GPL, ...).

Definition at line 313 of file ObjectFactory.cpp.

References entry, and sofa::core::ObjectFactory::ClassEntry::license.

template<class RealClass , class BaseClass >
bool sofa::core::RegisterObject::implements (  )  [inline]

Test whether T* converts to U*, that is, if T is derived from U.

Definition at line 262 of file ObjectFactory.h.

sofa::core::RegisterObject::operator int (  ) 


Field Documentation

Class entry being constructed.

Definition at line 220 of file ObjectFactory.h.

Referenced by add(), addAlias(), addAuthor(), addCreator(), addDescription(), addLicense(), and operator int().


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

Generated on Sun Nov 23 04:22:08 2008 for Sofa by  doxygen 1.5.7.1