|
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, const Parameter1 &val) |
| Create an instance of a class based on the specific class name, whose constructor takes 1 parameter. 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 >const Parameter1 &)> | 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 one parameter constructor, the type for that parameter can be passed as a template parameter.
| Base | The base class for all classes that can be registered with the factory. |
| Parameter1 | The class for the constructor parameter. |
|
private |
| std::shared_ptr< Base > SurgSim::Framework::ObjectFactory1< Base, Parameter1 >::create | ( | const std::string & | className, |
| const Parameter1 & | val | ||
| ) |
Create an instance of a class based on the specific class name, whose constructor takes 1 parameter.
| className | The class name. |
| val | The value of the parameter. |
| bool SurgSim::Framework::ObjectFactory1< Base, Parameter1 >::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::ObjectFactory1< Base, Parameter1 >::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.
1.8.13