nidas  v1.2-1520
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::SamplePool< SampleType > Class Template Reference

A pool of Samples. More...

#include <SamplePool.h>

Inheritance diagram for nidas::core::SamplePool< SampleType >:
Inheritance graph
[legend]

Public Member Functions

SampleType * getSample (unsigned int len) throw (SampleLengthException)
 Get a sample of at least len elements from the pool. More...
 
void putSample (const SampleType *)
 Return a sample to the pool. More...
 
int getNSamplesAlloc () const
 
int getNSamplesOut () const
 
int getNSmallSamplesIn () const
 
int getNMediumSamplesIn () const
 
int getNLargeSamplesIn () const
 

Static Public Member Functions

static SamplePoolgetInstance ()
 Get a pointer to the singleton instance. More...
 
static void deleteInstance ()
 Singleton cleanup on program exit. More...
 

Public Attributes

int _nsmall
 
int _nmedium
 
int _nlarge
 
int _nsamplesOut
 
int _nsamplesAlloc
 

Private Member Functions

 SamplePool ()
 
 ~SamplePool ()
 
SampleType * getSample (SampleType **vec, int *veclen, unsigned int len) throw (SampleLengthException)
 
void putSample (const SampleType *, SampleType ***vecp, int *veclen, int *nalloc)
 
 SamplePool (const SamplePool &)
 No copying. More...
 
SamplePooloperator= (const SamplePool &)
 No assignment. More...
 

Private Attributes

SampleType ** _smallSamples
 
SampleType ** _mediumSamples
 
SampleType ** _largeSamples
 
int _smallSize
 
int _mediumSize
 
int _largeSize
 
nidas::util::Mutex _poolLock
 

Static Private Attributes

static SamplePool_instance = 0
 
static nidas::util::Mutex _instanceLock = nidas::util::Mutex()
 
static const unsigned int SMALL_SAMPLE_MAXSIZE = 64
 maximum number of elements in a small sample More...
 
static const unsigned int MEDIUM_SAMPLE_MAXSIZE = 512
 maximum number of elements in a medium sized sample More...
 

Detailed Description

template<typename SampleType>
class nidas::core::SamplePool< SampleType >

A pool of Samples.

Actually three pools, containing samples segregated by size. A SamplePool can used as a singleton, and accessed from anywhere, via the getInstance() static member function.

Constructor & Destructor Documentation

template<class SampleType >
nidas::core::SamplePool< SampleType >::SamplePool ( )
private
template<class SampleType >
nidas::core::SamplePool< SampleType >::~SamplePool ( )
private
template<typename SampleType>
nidas::core::SamplePool< SampleType >::SamplePool ( const SamplePool< SampleType > &  )
private

No copying.

Member Function Documentation

template<class SampleType >
void nidas::core::SamplePool< SampleType >::deleteInstance ( )
static

Singleton cleanup on program exit.

template<class SampleType >
SamplePool< SampleType > * nidas::core::SamplePool< SampleType >::getInstance ( )
static

Get a pointer to the singleton instance.

References nidas::core::SamplePools::addPool(), and nidas::core::SamplePools::getInstance().

template<typename SampleType>
int nidas::core::SamplePool< SampleType >::getNLargeSamplesIn ( ) const
inlinevirtual
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::getNMediumSamplesIn ( ) const
inlinevirtual
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::getNSamplesAlloc ( ) const
inlinevirtual
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::getNSamplesOut ( ) const
inlinevirtual
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::getNSmallSamplesIn ( ) const
inlinevirtual
template<class SampleType >
SampleType * nidas::core::SamplePool< SampleType >::getSample ( unsigned int  len)
throw (SampleLengthException
)

Get a sample of at least len elements from the pool.

References nidas::core::getSample().

Referenced by nidas::core::getSample().

template<class SampleType >
SampleType * nidas::core::SamplePool< SampleType >::getSample ( SampleType **  vec,
int *  veclen,
unsigned int  len 
)
throw (SampleLengthException
)
private

References nidas::core::floatNAN, and len.

template<typename SampleType>
SamplePool& nidas::core::SamplePool< SampleType >::operator= ( const SamplePool< SampleType > &  )
private

No assignment.

template<class SampleType >
void nidas::core::SamplePool< SampleType >::putSample ( const SampleType *  sample)

Return a sample to the pool.

References DLOG.

Referenced by nidas::core::SampleT< DataT >::freeReference().

template<class SampleType >
void nidas::core::SamplePool< SampleType >::putSample ( const SampleType *  sample,
SampleType ***  vecp,
int *  veclen,
int *  nalloc 
)
private

References DLOG.

Member Data Documentation

template<typename SampleType>
SamplePool< SampleType > * nidas::core::SamplePool< SampleType >::_instance = 0
staticprivate
template<typename SampleType>
nidas::util::Mutex nidas::core::SamplePool< SampleType >::_instanceLock = nidas::util::Mutex()
staticprivate
template<typename SampleType>
SampleType** nidas::core::SamplePool< SampleType >::_largeSamples
private
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::_largeSize
private
template<typename SampleType>
SampleType** nidas::core::SamplePool< SampleType >::_mediumSamples
private
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::_mediumSize
private
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::_nlarge
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::_nmedium
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::_nsamplesAlloc
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::_nsamplesOut
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::_nsmall
template<typename SampleType>
nidas::util::Mutex nidas::core::SamplePool< SampleType >::_poolLock
private
template<typename SampleType>
SampleType** nidas::core::SamplePool< SampleType >::_smallSamples
private
template<typename SampleType>
int nidas::core::SamplePool< SampleType >::_smallSize
private
template<typename SampleType>
const unsigned int nidas::core::SamplePool< SampleType >::MEDIUM_SAMPLE_MAXSIZE = 512
staticprivate

maximum number of elements in a medium sized sample

Referenced by nidas::core::SamplePool< SampleType >::SamplePool().

template<typename SampleType>
const unsigned int nidas::core::SamplePool< SampleType >::SMALL_SAMPLE_MAXSIZE = 64
staticprivate

maximum number of elements in a small sample

Referenced by nidas::core::SamplePool< SampleType >::SamplePool().


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