WPOCT Software Developer's Kit (SDK)
SDK For using Wasatch Photonics OCT Spectrometers
Public Member Functions | List of all members
SameSizeBuffers< T, U > Class Template Reference

A general purpose templated class that holds a programmable number of buffers, each the same size. More...

#include <SameSizeBuffers.h>

Public Member Functions

 SameSizeBuffers ()
 Initializes a new instance of the SameSizeBuffers<T, U> class. More...
 
 SameSizeBuffers (int sizeOfBuffer)
 Initializes a new instance of the SameSizeBuffers<T, U> class. More...
 
 SameSizeBuffers (int sizeOfBuffer, int numBuffers)
 Initializes a new instance of the SameSizeBuffers<T, U> class and creates the buffers specified. More...
 
virtual ~SameSizeBuffers ()
 Finalizes an instance of the SameSizeBuffers<T, U> class. More...
 
int GetNumBuffers () const
 
int GetBufferSize () const
 
int GetCurrentBuffer () const
 
int GetFirstBufferIndex () const
 
int GetNumBuffersInRing () const
 
int GetNextBufferIndex ()
 Gets the index of the next buffer in the circular queue. More...
 
T * operator[] (int index)
 Returns a pointer to the buffer specified by the index. More...
 
void SetCurrentBuffer (int value)
 Sets the value of the current buffer. More...
 
int ResetCurrentBuffer ()
 Resets the current buffer to the index of the first buffer in the circular queue. More...
 
void SetFirstBufferIndex (int value)
 Sets the first index of the circular buffer. More...
 
bool CreateBuffers (int bufferSize, int numBuffers)
 Creates the buffers specified by the supplied parameters. More...
 
bool SetBufferToValue (int index, U value)
 Sets each element in the buffer to value supplied. More...
 
bool AddTogether (int sourceIndex, int destIndex)
 Adds the source and destination buffers together and places the result in the destination. More...
 
bool Subtract (int sourceIndex, int destIndex)
 Subtracts the source buffer from the destination buffer and places the result in the destination. More...
 
bool CopyBufferIn (U *buffer, int index)
 Copies the buffer supplied to the buffer specified by the index. More...
 
bool AddBufferToAverage (U *buffer, int index, int divisor)
 Copies the buffer supplied to the buffer specified by the index. More...
 
bool CopyBufferOut (U *buffer, int index)
 Copies the buffer specified by the index out to the buffer supplied. More...
 
void Clear ()
 Deletes all buffers and the pointers to them. More...
 

Detailed Description

template<typename T, typename U>
class SameSizeBuffers< T, U >

A general purpose templated class that holds a programmable number of buffers, each the same size.

In addition, some or all of the buffers can be used as a circular queue.

Constructor & Destructor Documentation

◆ SameSizeBuffers() [1/3]

template<typename T , typename U >
SameSizeBuffers< T, U >::SameSizeBuffers

Initializes a new instance of the SameSizeBuffers<T, U> class.

◆ SameSizeBuffers() [2/3]

template<typename T , typename U >
SameSizeBuffers< T, U >::SameSizeBuffers ( int  sizeOfBuffer)

Initializes a new instance of the SameSizeBuffers<T, U> class.

Parameters
sizeOfBufferThe size of each buffer.

◆ SameSizeBuffers() [3/3]

template<typename T , typename U >
SameSizeBuffers< T, U >::SameSizeBuffers ( int  sizeOfBuffer,
int  numBuffers 
)

Initializes a new instance of the SameSizeBuffers<T, U> class and creates the buffers specified.

Parameters
sizeOfBufferThe size of each buffer.
numBuffersThe number buffers.

◆ ~SameSizeBuffers()

template<typename T , typename U >
SameSizeBuffers< T, U >::~SameSizeBuffers
virtual

Finalizes an instance of the SameSizeBuffers<T, U> class.

Member Function Documentation

◆ AddBufferToAverage()

template<typename T , typename U >
bool SameSizeBuffers< T, U >::AddBufferToAverage ( U *  buffer,
int  index,
int  divisor 
)

Copies the buffer supplied to the buffer specified by the index.

Each entry is divided by the divisor. This call can be used for averaging.

Parameters
bufferThe buffer to be copied from.
indexThe index of the buffer to be copied to.
Returns
bool - true if successful

◆ AddTogether()

template<typename T , typename U >
bool SameSizeBuffers< T, U >::AddTogether ( int  sourceIndex,
int  destIndex 
)

Adds the source and destination buffers together and places the result in the destination.

Parameters
sourceIndexIndex of the source.
destIndexIndex of the dest.
Returns
bool - true if successful

◆ Clear()

template<typename T , typename U >
void SameSizeBuffers< T, U >::Clear

Deletes all buffers and the pointers to them.

◆ CopyBufferIn()

template<typename T , typename U >
bool SameSizeBuffers< T, U >::CopyBufferIn ( U *  buffer,
int  index 
)

Copies the buffer supplied to the buffer specified by the index.

Parameters
bufferThe buffer to be copied from.
indexThe index of the buffer to be copied to.
Returns
bool - true if successful

◆ CopyBufferOut()

template<typename T , typename U >
bool SameSizeBuffers< T, U >::CopyBufferOut ( U *  buffer,
int  index 
)

Copies the buffer specified by the index out to the buffer supplied.

The buffer to copy to must already be allocated.

Parameters
bufferThe buffer to be copied to.
indexThe index of the buffer to be copied from.
Returns
bool - true if successful

◆ CreateBuffers()

template<typename T , typename U >
bool SameSizeBuffers< T, U >::CreateBuffers ( int  bufferSize,
int  numBuffers 
)

Creates the buffers specified by the supplied parameters.

Parameters
bufferSizeSize of each buffer.
numBuffersThe number of buffers.
Returns
bool - true if successful

◆ GetNextBufferIndex()

template<typename T , typename U >
int SameSizeBuffers< T, U >::GetNextBufferIndex

Gets the index of the next buffer in the circular queue.

Returns
int - the next buffer index

◆ operator[]()

template<typename T , typename U >
T * SameSizeBuffers< T, U >::operator[] ( int  index)

Returns a pointer to the buffer specified by the index.

Parameters
indexThe index.
Returns
T* - a pointer to the buffer

◆ ResetCurrentBuffer()

template<typename T , typename U >
int SameSizeBuffers< T, U >::ResetCurrentBuffer

Resets the current buffer to the index of the first buffer in the circular queue.

Returns
int - the start index of the circular buffer.

◆ SetBufferToValue()

template<typename T , typename U >
bool SameSizeBuffers< T, U >::SetBufferToValue ( int  index,
value 
)

Sets each element in the buffer to value supplied.

Parameters
indexThe index of the buffer to initialize.
valueThe value to initialize to.
Returns
bool - true if successful

◆ SetCurrentBuffer()

template<typename T , typename U >
void SameSizeBuffers< T, U >::SetCurrentBuffer ( int  value)

Sets the value of the current buffer.

Parameters
valueThe value.

◆ SetFirstBufferIndex()

template<typename T , typename U >
void SameSizeBuffers< T, U >::SetFirstBufferIndex ( int  value)

Sets the first index of the circular buffer.

Parameters
valueThe value of the first index.

◆ Subtract()

template<typename T , typename U >
bool SameSizeBuffers< T, U >::Subtract ( int  sourceIndex,
int  destIndex 
)

Subtracts the source buffer from the destination buffer and places the result in the destination.

Parameters
sourceIndexIndex of the source.
destIndexIndex of the destination.
Returns
bool - true if successful

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