17 #ifndef SURGSIM_FRAMEWORK_OBJECTFACTORY_INL_H
18 #define SURGSIM_FRAMEWORK_OBJECTFACTORY_INL_H
23 template <
class Derived>
26 boost::mutex::scoped_lock lock(m_mutex);
28 if (m_constructors.find(className) == m_constructors.end())
30 m_constructors[className] = boost::factory<std::shared_ptr<Derived>>();
39 boost::mutex::scoped_lock lock(m_mutex);
40 auto it = m_constructors.find(className);
41 if (it == m_constructors.end())
43 SURGSIM_FAILURE() <<
"ObjectFactory does not know about class called " << className;
47 return (it->second)();
51 template <
typename Base>
54 boost::mutex::scoped_lock lock(m_mutex);
55 auto it = m_constructors.find(className);
56 return (it != m_constructors.end());
60 template <
typename Base,
typename Parameter1>
61 template <
typename Derived>
64 boost::mutex::scoped_lock lock(m_mutex);
66 if (m_constructors.find(className) == m_constructors.end())
68 m_constructors[className] = boost::factory<std::shared_ptr<Derived>>();
74 template <
typename Base,
typename Parameter1>
76 const std::string& className,
77 const Parameter1& val)
79 boost::mutex::scoped_lock lock(m_mutex);
80 auto it = m_constructors.find(className);
82 if (it == m_constructors.end())
84 SURGSIM_FAILURE() <<
"ObjectFactory does not know about class called " << className;
88 return (it->second)(val);
91 template <
typename Base,
typename Parameter1>
94 boost::mutex::scoped_lock lock(m_mutex);
95 auto it = m_constructors.find(className);
96 return (it != m_constructors.end());
100 #endif // SURGSIM_FRAMEWORK_OBJECTFACTORY_INL_H