16 #ifndef SURGSIM_FRAMEWORK_SHAREDINSTANCE_INL_H 17 #define SURGSIM_FRAMEWORK_SHAREDINSTANCE_INL_H 22 #include <boost/thread/mutex.hpp> 23 #include <boost/thread/locks.hpp> 35 m_instanceCreator(defaultInstanceCreator())
53 boost::lock_guard<boost::mutex> lock(
m_mutex);
60 return std::move(instance);
68 return std::move(instance);
74 return []() {
return std::make_shared<T>(); };
81 #endif // SURGSIM_FRAMEWORK_SHAREDINSTANCE_INL_H Definition: DriveElementFromInputBehavior.cpp:27
std::weak_ptr< T > m_weakInstance
A weak reference to the shared instance, if any.
Definition: SharedInstance.h:155
~SharedInstance()
Destroy the container and the data it contains.
Definition: SharedInstance-inl.h:46
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
boost::mutex m_mutex
Mutex for synchronization of object creation.
Definition: SharedInstance.h:158
static InstanceCreator defaultInstanceCreator()
Creates a function that can create an instance using std::make_shared<T>().
Definition: SharedInstance-inl.h:72
SharedInstance()
Create the SharedInstance object used to manage the shared instance.
Definition: SharedInstance-inl.h:34
InstanceCreator m_instanceCreator
A creator function used to construct the shared instance.
Definition: SharedInstance.h:152
The header that provides the assertion API.
std::shared_ptr< T > get()
Gets the shared object instance.
Definition: SharedInstance-inl.h:51
std::function< std::shared_ptr< T >)> InstanceCreator
A type that can hold a function object or lambda that takes no arguments and returns std::shared_ptr<...
Definition: SharedInstance.h:109
std::shared_ptr< T > createInstance()
Creates an object instance.
Definition: SharedInstance-inl.h:64