NDArrayPool Class Reference

The NDArrayPool class manages a free list (pool) of NDArray objects. More...

#include <NDArray.h>

List of all members.

Public Member Functions

 NDArrayPool (int maxBuffers, size_t maxMemory)
 NDArrayPool constructor.
NDArrayalloc (int ndims, int *dims, NDDataType_t dataType, int dataSize, void *pData)
 Allocates a new NDArray object; the first 3 arguments are required.
NDArraycopy (NDArray *pIn, NDArray *pOut, int copyData)
 This method makes a copy of an NDArray object.
int reserve (NDArray *pArray)
 This method increases the reference count for the NDArray object.
int release (NDArray *pArray)
 This method decreases the reference count for the NDArray object.
int convert (NDArray *pIn, NDArray **ppOut, NDDataType_t dataTypeOut, NDDimension_t *outDims)
 Creates a new output NDArray from an input NDArray, performing conversion operations.
int convert (NDArray *pIn, NDArray **ppOut, NDDataType_t dataTypeOut)
 Creates a new output NDArray from an input NDArray, performing conversion operations.
int report (int details)
 Reports on the free list size and other properties of the NDArrayPool object.
int maxBuffers ()
 Returns maximum number of buffers this object is allowed to allocate; -1=unlimited.
int numBuffers ()
 Returns number of buffers this object has currently allocated.
size_t maxMemory ()
 Returns maximum bytes of memory this object is allowed to allocate; -1=unlimited.
size_t memorySize ()
 Returns mumber of bytes of memory this object has currently allocated.
int numFree ()
 Returns number of NDArray objects in the free list.


Detailed Description

The NDArrayPool class manages a free list (pool) of NDArray objects.

Drivers allocate NDArray objects from the pool, and pass these objects to plugins. Plugins increase the reference count on the object when they place the object on their queue, and decrease the reference count when they are done processing the array. When the reference count reaches 0 again the NDArray object is placed back on the free list. This mechanism minimizes the copying of array data in plugins.


Constructor & Destructor Documentation

NDArrayPool::NDArrayPool ( int  maxBuffers,
size_t  maxMemory 
)

NDArrayPool constructor.

Parameters:
[in] maxBuffers Maximum number of NDArray objects that the pool is allowed to contain; -1=unlimited.
[in] maxMemory Maxiumum number of bytes of memory the the pool is allowed to use, summed over all of the NDArray objects; -1=unlimited.


Member Function Documentation

NDArray * NDArrayPool::alloc ( int  ndims,
int *  dims,
NDDataType_t  dataType,
int  dataSize,
void *  pData 
)

Allocates a new NDArray object; the first 3 arguments are required.

Parameters:
[in] ndims The number of dimensions in the NDArray.
[in] dims Array of dimensions, whose size must be at least ndims.
[in] dataType Data type of the NDArray data.
[in] dataSize Number of bytes to allocate for the array data; if 0 then alloc() will compute the size required from ndims, dims, and dataType.
[in] pData Pointer to a data buffer; if NULL then alloc will allocate a new array buffer; if not NULL then it is assumed to point to a valid buffer.
If pData is not NULL then dataSize must contain the actual number of bytes in the existing array, and this array must be large enough to hold the array data. alloc() searches its free list to find a free NDArray buffer. If is cannot find one then it will allocate a new one and add it to the free list. If doing so would exceed maxBuffers then alloc() will return an error. Similarly if allocating the memory required for this NDArray would cause the cumulative memory allocated for the pool to exceed maxMemory then an error will be returned. alloc() sets the reference count for the returned NDArray to 1.

int NDArrayPool::convert ( NDArray pIn,
NDArray **  ppOut,
NDDataType_t  dataTypeOut 
)

Creates a new output NDArray from an input NDArray, performing conversion operations.

This form of the function is for changing the data type only, not the dimensions, which are preserved.

Parameters:
[in] pIn The input array, source of the conversion.
[out] ppOut The output array, result of the conversion.
[in] dataTypeOut The data type of the output array.

int NDArrayPool::convert ( NDArray pIn,
NDArray **  ppOut,
NDDataType_t  dataTypeOut,
NDDimension_t dimsOut 
)

Creates a new output NDArray from an input NDArray, performing conversion operations.

The conversion can change the data type if dataTypeOut is different from pIn->dataType. It can also change the dimensions. outDims may have different values of size, binning, offset and reverse for each of its dimensions from input array dimensions (pIn->dims).

Parameters:
[in] pIn The input array, source of the conversion.
[out] ppOut The output array, result of the conversion.
[in] dataTypeOut The data type of the output array.
[in] dimsOut The dimensions of the output array.

NDArray * NDArrayPool::copy ( NDArray pIn,
NDArray pOut,
int  copyData 
)

This method makes a copy of an NDArray object.

Parameters:
[in] pIn The input array to be copied.
[in] pOut The output array that will be copied to.
[in] copyData If this flag is 1 then everything including the array data is copied; if 0 then everything except the data (including attributes) is copied.
Returns:
Returns a pointer to the output array.
If pOut is NULL then it is first allocated. If the output array object already exists (pOut!=NULL) then it must have sufficient memory allocated to it to hold the data.

int NDArrayPool::maxBuffers (  ) 

Returns maximum number of buffers this object is allowed to allocate; -1=unlimited.

size_t NDArrayPool::maxMemory (  ) 

Returns maximum bytes of memory this object is allowed to allocate; -1=unlimited.

size_t NDArrayPool::memorySize (  ) 

Returns mumber of bytes of memory this object has currently allocated.

int NDArrayPool::numBuffers (  ) 

Returns number of buffers this object has currently allocated.

int NDArrayPool::numFree (  ) 

Returns number of NDArray objects in the free list.

int NDArrayPool::release ( NDArray pArray  ) 

This method decreases the reference count for the NDArray object.

Parameters:
[in] pArray The array on which to decrease the reference count.
When the reference count reaches 0 the NDArray is placed back in the free list. Plugins must call release() when an NDArray is removed from the queue and processing on it is complete. Drivers must call release() after calling all plugins.

int NDArrayPool::report ( int  details  ) 

Reports on the free list size and other properties of the NDArrayPool object.

Parameters:
[in] details Level of report details desired; does nothing at present.

int NDArrayPool::reserve ( NDArray pArray  ) 

This method increases the reference count for the NDArray object.

Parameters:
[in] pArray The array on which to increase the reference count.
Plugins must call reserve() when an NDArray is placed on a queue for later processing.


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

Generated on Tue Aug 9 14:44:38 2011 for areaDetector by  doxygen 1.5.7.1