Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

syn::FlyWeightPool Class Template Reference

FlyWeightPool. More...

#include <FlyWeightPool.h>

Collaboration diagram for syn::FlyWeightPool:

Collaboration graph
[legend]
List of all members.

Public Methods

 FlyWeightPool ()
 ~FlyWeightPool ()
void setAutoGrow (bool grow)
bool autoGrow () const
void acquire () const
bool tryAcquire () const
void release () const
void resize (unsigned int s)
 resize of flyweight pool is safe: i.e. More...

unsigned int size () const
 return the total number of objects this flyweight pool is managing. More...

int available () const
 number of flyweights available. More...

bool empty () const
 check to see if the pool is empty (then take() would fail). More...

void take (type *&t)
 take an item from the pool use this function like you would use "new" if autoGrow() == false then you must check empty() before takeing. More...

void putback (type *t)
 put back an item to the pool use this function like you would use "delete". More...


Detailed Description

template<class type> class syn::FlyWeightPool

FlyWeightPool.

Implements the flyweight pattern as described in "Design Patterns" You should think of the FlyWeightPool<_T> as a factory for objects of type _T. Use take/putback instead of new/delete for all objects of type _T.

flyweight pool rules: 1.) by default, and when autoGrow() == false, this is a fixed size pool of flyweights with no auto adjustment, when items are gone, they are gone, check empty() before taking any! 2.) pool is autogrowable if you setAutoGrow( true ), take() is then safe to call as many times as you need. 3.) resize of flyweight pool is safe: i.e. doesn't invalidate pointers 4.) all items must be checked back in before destroying this pool.

Definition at line 60 of file FlyWeightPool.h.


Constructor & Destructor Documentation

template<class type>
syn::FlyWeightPool<type>::FlyWeightPool<type> ( ) [inline]
 

Definition at line 63 of file FlyWeightPool.h.

template<class type>
syn::FlyWeightPool<type>::~FlyWeightPool<type> ( ) [inline]
 

Definition at line 69 of file FlyWeightPool.h.


Member Function Documentation

template<class type>
void syn::FlyWeightPool<type>::setAutoGrow ( bool grow ) [inline]
 

Definition at line 83 of file FlyWeightPool.h.

Referenced by syn::SampleBufferRepos::SampleBufferRepos().

template<class type>
bool syn::FlyWeightPool<type>::autoGrow ( ) const [inline]
 

Definition at line 84 of file FlyWeightPool.h.

template<class type>
void syn::FlyWeightPool<type>::acquire ( ) const [inline]
 

Definition at line 91 of file FlyWeightPool.h.

Referenced by FlyWeightPool(), putback(), resize(), take(), and ~FlyWeightPool().

template<class type>
bool syn::FlyWeightPool<type>::tryAcquire ( ) const [inline]
 

Definition at line 92 of file FlyWeightPool.h.

template<class type>
void syn::FlyWeightPool<type>::release ( ) const [inline]
 

Definition at line 93 of file FlyWeightPool.h.

Referenced by FlyWeightPool(), putback(), resize(), take(), and ~FlyWeightPool().

template<class type>
void syn::FlyWeightPool<type>::resize ( unsigned int s ) [inline]
 

resize of flyweight pool is safe: i.e.

doesn't invalidate pointers

Definition at line 96 of file FlyWeightPool.h.

template<class type>
unsigned int syn::FlyWeightPool<type>::size ( ) const [inline]
 

return the total number of objects this flyweight pool is managing.

Definition at line 106 of file FlyWeightPool.h.

template<class type>
int syn::FlyWeightPool<type>::available ( ) const [inline]
 

number of flyweights available.

Definition at line 109 of file FlyWeightPool.h.

template<class type>
bool syn::FlyWeightPool<type>::empty ( ) const [inline]
 

check to see if the pool is empty (then take() would fail).

Definition at line 112 of file FlyWeightPool.h.

Referenced by take().

template<class type>
void syn::FlyWeightPool<type>::take ( type *& t ) [inline]
 

take an item from the pool use this function like you would use "new" if autoGrow() == false then you must check empty() before takeing.

Definition at line 118 of file FlyWeightPool.h.

Referenced by syn::SampleBufferRepos::take().

template<class type>
void syn::FlyWeightPool<type>::putback ( type * t ) [inline]
 

put back an item to the pool use this function like you would use "delete".

Definition at line 135 of file FlyWeightPool.h.

Referenced by syn::SampleBufferRepos::putback().


The documentation for this class was generated from the following file:
Generated at Mon Apr 15 09:27:55 2002 for subsynth by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001