Factory for acquiring new or unused existing instances of class T to reduce repeated deallocation and reallocation of objects with short lifespans.
More...
template<class T>
class SurgSim::Framework::ReuseFactory< T >
Factory for acquiring new or unused existing instances of class T to reduce repeated deallocation and reallocation of objects with short lifespans.
Example Usage:
{
ReuseFactory<MyObject> factory;
std::shared_ptr<MyObject> myObject = factory.getInstance();
myObject.set(...);
}
std::shared_ptr<MyObject> myObject2 = factory.getInstance();
myObject2.set(...);
Limitations:
- The class T must have a default constructor.
- The state of returned objects are in no way reset, so the state will need to be setup after retrieving the instance from the factory.
- Custom deleters for an instance of T cannot be specified, as a custom deleter is used to manage the unused objects.
- Template Parameters
-
T | Instances of this class are provided by this factory |