![]() |
An object factory, once a class is registered with the factory it can be used to create instances of registered classes. More...
#include <SurgSim/Framework/ObjectFactory.h>
Public Member Functions | |
template<typename Derived > | |
bool | registerClass (const std::string &className) |
Register a class with the factory. More... | |
std::shared_ptr< Base > | create (const std::string &className) |
Create an instance of a class based on the specific class name. More... | |
bool | isRegistered (const std::string &className) const |
Check whether the class is registered in the factory. More... | |
Private Types | |
typedef boost::function< std::shared_ptr< Base >)> | Constructor |
Private Attributes | |
std::map< std::string, Constructor > | m_constructors |
All the constructors. More... | |
boost::mutex | m_mutex |
Threadsafety for registration. More... | |
An object factory, once a class is registered with the factory it can be used to create instances of registered classes.
All the classes registered need to have a default constructor.
Base | the base class for all classes that can be registered with the factory. |
|
private |
std::shared_ptr< Base > SurgSim::Framework::ObjectFactory< Base >::create | ( | const std::string & | className | ) |
Create an instance of a class based on the specific class name.
className | The class name that was used to register the class. |
bool SurgSim::Framework::ObjectFactory< Base >::isRegistered | ( | const std::string & | className | ) | const |
Check whether the class is registered in the factory.
className | Name of the class to check. |
bool SurgSim::Framework::ObjectFactory< Base >::registerClass | ( | const std::string & | className | ) |
Register a class with the factory.
T | The specific type of the class to be registered. |
className | The name of this class. |
|
private |
All the constructors.
|
mutableprivate |
Threadsafety for registration.