dbp::pool< T > Class Template Reference

Objects pool template class. More...

#include <pool.h>

Inheritance diagram for dbp::pool< T >:
Inheritance graph
[legend]
Collaboration diagram for dbp::pool< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~pool ()
 Destructor.
pool_ptr< T > acquire (const std::string &key=std::string(""))
 Acquire an object.
int size () const
 Get current pool size.
int in_use () const
 Get the number of cached entries.

Friends

class pool_ptr< T >

Detailed Description

template<class T>
class dbp::pool< T >

Objects pool template class.

This is a specialized object factory class with caching feature. When acquiring an object, the factory checks the pool for the not acquired one; if none found, the factory creates one.

When the object is not needed by caller, it is returning into the pool. So, this pool class preserving time for the object creation if the object constructing or initializing is expensive.


Member Function Documentation

template<class T >
pool_ptr<T> dbp::pool< T >::acquire ( const std::string &  key = std::string("")  )  [inline]

Acquire an object.

Create the object instance if the instance is not found in the pool or return the instance from the pool otherwise.

Returns:
the smart pointer to the object instance

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

 
Support This Project
SourceForge.net Logo