Eclipse SUMO - Simulation of Urban MObility
InstancePool< T > Class Template Reference

A pool of resuable instances. More...

#include <InstancePool.h>

Public Member Functions

void addFreeInstance (T *instance)
 Adds a free, reusable instance. More...
 
void addFreeInstances (const std::vector< T * > instances)
 Adds some free, reusable instances. More...
 
T * getFreeInstance ()
 Returns a free instance or 0 if no such exists. More...
 
 InstancePool (bool deleteOnQuit)
 Constructor. More...
 
 ~InstancePool ()
 Destructor. More...
 

Private Attributes

bool myDeleteOnQuit
 Information whether the stored instances shall be deleted. More...
 
std::vector< T * > myFreeInstances
 List of reusable instances. More...
 

Detailed Description

template<typename T>
class InstancePool< T >

A pool of resuable instances.

Definition at line 34 of file InstancePool.h.

Constructor & Destructor Documentation

◆ InstancePool()

template<typename T >
InstancePool< T >::InstancePool ( bool  deleteOnQuit)
inline

Constructor.

Parameters
[in]deleteOnQuitInformation whether stored instances shall be deleted when this container is deleted

Definition at line 40 of file InstancePool.h.

◆ ~InstancePool()

template<typename T >
InstancePool< T >::~InstancePool ( )
inline

Destructor.

Definition at line 44 of file InstancePool.h.

References InstancePool< T >::myDeleteOnQuit, and InstancePool< T >::myFreeInstances.

Member Function Documentation

◆ addFreeInstance()

template<typename T >
void InstancePool< T >::addFreeInstance ( T *  instance)
inline

Adds a free, reusable instance.

Parameters
[in]instanceAn instance to add

Definition at line 76 of file InstancePool.h.

References InstancePool< T >::myFreeInstances.

◆ addFreeInstances()

template<typename T >
void InstancePool< T >::addFreeInstances ( const std::vector< T * >  instances)
inline

Adds some free, reusable instances.

Parameters
[in]instancesA vector of instances to add

Definition at line 85 of file InstancePool.h.

References InstancePool< T >::myFreeInstances.

◆ getFreeInstance()

template<typename T >
T* InstancePool< T >::getFreeInstance ( )
inline

Returns a free instance or 0 if no such exists.

If any free instance is stored, it is returned and removed from the storage. If no one is stored, 0 is returned.

Returns
A free instance or 0 if no such exists

Definition at line 61 of file InstancePool.h.

References InstancePool< T >::myFreeInstances.

Field Documentation

◆ myDeleteOnQuit

template<typename T >
bool InstancePool< T >::myDeleteOnQuit
private

Information whether the stored instances shall be deleted.

Definition at line 96 of file InstancePool.h.

Referenced by InstancePool< T >::~InstancePool().

◆ myFreeInstances

template<typename T >
std::vector<T*> InstancePool< T >::myFreeInstances
private

The documentation for this class was generated from the following file: