InstantIO::Cache< T > Class Template Reference

Cache is a helper class used to cache objects. More...

#include <InstantIO/Cache.h>

Inheritance diagram for InstantIO::Cache< T >:
InstantIO::BasicCache

List of all members.

Public Member Functions

 ~Cache ()
 Destroys the Cache object.
RefCtr< T > * acquire ()
 Acquires a new object.
void release (RefCtr< T > *value)
 Releases an object.
 Cache ()
 Creates a new Cache object.

Static Public Member Functions

static Cache< T > & the ()
 Returns the single instance of the Cache class Cache is a singleton, i.e.

Detailed Description

template<class T>
class InstantIO::Cache< T >

Cache is a helper class used to cache objects.

Author:
Patrick Dähne

Constructor & Destructor Documentation

template<class T>
InstantIO::Cache< T >::~Cache (  )  [inline]

Destroys the Cache object.

Automatically destroys all objects stored in the cache. Throws an exception when there is any object still in use by the application.

template<class T>
InstantIO::Cache< T >::Cache (  )  [inline]

Creates a new Cache object.

The Constructor is protected because you are not allowed to create Cache objects. Cache is a singleton, i.e. only one instance of Cache exists. You can access this instance by calling the the method.

See also:
the

Member Function Documentation

template<class T>
static Cache<T>& InstantIO::Cache< T >::the (  )  [inline, static]

Returns the single instance of the Cache class Cache is a singleton, i.e.

only one instance of this class exists. You can access this instance by calling this method.

Returns:
The single instance of the Cache class
template<class T>
RefCtr<T>* InstantIO::Cache< T >::acquire (  )  [inline]

Acquires a new object.

Call this method when you need a new object. When there is an unused object available in the cache, returns this object. Otherwise, creates a new object. Because you may get an object already used before, you have to initialize the object! Call the release method when you do not need the object any more.

Returns:
The new object
See also:
release
template<class T>
void InstantIO::Cache< T >::release ( RefCtr< T > *  value  )  [inline]

Releases an object.

Call this method when you do not need an object you got from the acquire method any more. The object is inserted into the cache and reused when you call acquire again. Do not try to access the object after calling this method!

Parameters:
value The object
See also:
acquire

The documentation for this class was generated from the following file:
Generated on Thu Jul 31 17:17:32 2014 by  doxygen 1.6.3