Public Member Functions | Private Types | Private Attributes | List of all members
ObjectPool< T, C > Class Template Reference

#include <object_pool.hpp>

Public Member Functions

bool acquire (T &obj)
 
bool add (const T &obj)
 
bool busy (void)
 
std::vector< TgetPool () const
 
 ObjectPool ()
 
bool release (const T &obj)
 
unsigned size (void)
 
 ~ObjectPool ()
 

Private Types

typedef std::map< T, bool, C > poolMap
 

Private Attributes

poolMap pool
 

Detailed Description

template<typename T, typename C = std::less< T >>
class ObjectPool< T, C >

An object pool class that creates and reuses objects of an arbitrary type.

Definition at line 41 of file object_pool.hpp.

Member Typedef Documentation

template<typename T, typename C = std::less< T >>
typedef std::map<T, bool, C> ObjectPool< T, C >::poolMap
private

Definition at line 143 of file object_pool.hpp.

Constructor & Destructor Documentation

template<typename T, typename C = std::less< T >>
ObjectPool< T, C >::ObjectPool ( )
inline

Default constructor

Definition at line 45 of file object_pool.hpp.

template<typename T, typename C = std::less< T >>
ObjectPool< T, C >::~ObjectPool ( )
inline

Default destructor

Definition at line 49 of file object_pool.hpp.

Member Function Documentation

template<typename T, typename C = std::less< T >>
bool ObjectPool< T, C >::acquire ( T obj)
inline

When user code demands an object, pool first looks if there is any spare object to return. In case there is not any available object in the pool, a new object will be created and returned.

Definition at line 87 of file object_pool.hpp.

template<typename T, typename C = std::less< T >>
bool ObjectPool< T, C >::add ( const T obj)
inline

This function enables one to explicitly put an object into the pool.

In case the object is already in the pool, the function returns false. Otherwise, it returns true.

Definition at line 57 of file object_pool.hpp.

template<typename T, typename C = std::less< T >>
bool ObjectPool< T, C >::busy ( void  )
inline

Definition at line 70 of file object_pool.hpp.

template<typename T, typename C = std::less< T >>
std::vector< T > ObjectPool< T, C >::getPool ( void  ) const
inline

This function return a vector containing all objects in the pool

Definition at line 125 of file object_pool.hpp.

template<typename T, typename C = std::less< T >>
bool ObjectPool< T, C >::release ( const T obj)
inline

This function releases an object in the pool

Definition at line 111 of file object_pool.hpp.

template<typename T, typename C = std::less< T >>
unsigned ObjectPool< T, C >::size ( void  )
inline

Number of objects in the pool

Definition at line 137 of file object_pool.hpp.

Member Data Documentation

template<typename T, typename C = std::less< T >>
poolMap ObjectPool< T, C >::pool
private

Definition at line 145 of file object_pool.hpp.


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


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:25