fw4spl
fwDataTools::helper::Array Class Reference

Helper to manage array buffer. Lock the buffer before to modify it. More...

#include <Array.hpp>

Public Member Functions

FWDATATOOLS_API Array (::fwData::Array::sptr array)
 
virtual FWDATATOOLS_API void setItem (const ::fwData::Array::IndexType &id, const void *value)
 Setter for one item components of the array. More...
 
virtual FWDATATOOLS_API void setItem (const ::fwData::Array::IndexType &id, const size_t component, const void *value)
 Setter for one item component of the array. More...
 
virtual FWDATATOOLS_API void * getItem (const ::fwData::Array::IndexType &id, const size_t component=0)
 Getter for a buffer item. pointer to the requested item in the buffer. More...
 
template<typename T >
T * getItem (const ::fwData::Array::IndexType &id, const size_t component=0)
 Typed version of getItem. More...
 
virtual FWDATATOOLS_API void getItem (const ::fwData::Array::IndexType &id, void *value) const
 Copies the data into the buffer pointed by More...
 
virtual FWDATATOOLS_API void getItem (const ::fwData::Array::IndexType &id, const size_t component, void *value) const
 
FWDATATOOLS_API void setBuffer (void *buf, bool takeOwnership, const ::fwTools::Type &type, const ::fwData::Array::SizeType &size, size_t nbOfComponents,::fwMemory::BufferAllocationPolicy::sptr policy=::fwMemory::BufferMallocPolicy::New())
 Setter for the array buffer. More...
 
virtual FWDATATOOLS_API char * begin ()
 Returns the begining/end of the buffer interpreted as a char buffer.
 
virtual FWDATATOOLS_API char * end ()
 
virtual FWDATATOOLS_API const char * begin () const
 
virtual FWDATATOOLS_API const char * end () const
 
template<typename T >
T * begin ()
 Returns the begining/end of the buffer, casted to T.
 
template<typename T >
T * end ()
 
FWDATATOOLS_API::fwMemory::BufferObject::Lock getLock () const
 Returns a copy of current lock on array.
 
virtual FWDATATOOLS_API void * getBuffer ()
 Getter for the array buffer. More...
 
virtual FWDATATOOLS_API const void * getBuffer () const
 Getter for the array buffer. More...
 
FWDATATOOLS_API char * getBufferPtr (const ::fwData::Array::IndexType &id, size_t component, size_t sizeOfType)
 Get a pointer to the value described by given parameters. More...
 
FWDATATOOLS_API const char * getBufferPtr (const ::fwData::Array::IndexType &id, size_t component, size_t sizeOfType) const
 Get a pointer to the value described by given parameters. More...
 

Protected Member Functions

virtual FWDATATOOLS_API void setBuffer (void *buf, bool takeOwnership=false,::fwMemory::BufferAllocationPolicy::sptr policy=::fwMemory::BufferMallocPolicy::New())
 Protected setter for the array buffer. An existing buffer will be released if the array own it. More...
 

Protected Attributes

::fwData::Array::sptr m_array
 
::fwMemory::BufferObject::Lock m_lock
 

Friends

class ::boost::serialization::access
 
template<class , class >
struct ::boost::python::objects::pointer_holder
 
template<class , class , class >
class ::fwTools::ClassFactory
 
class ::fwTools::Factory
 

Detailed Description

Helper to manage array buffer. Lock the buffer before to modify it.

Definition at line 24 of file ools/include/fwDataTools/helper/Array.hpp.

Member Function Documentation

const void * fwDataTools::helper::Array::getBuffer ( ) const
virtual

Getter for the array buffer.

Returns
Array's buffer, if exists, else NULL

Definition at line 38 of file ools/src/fwDataTools/helper/Array.cpp.

char * fwDataTools::helper::Array::getBufferPtr ( const ::fwData::Array::IndexType id,
size_t  component,
size_t  sizeOfType 
)

Get a pointer to the value described by given parameters.

Parameters
idItem id
componentItem component id
sizeOfTypesize of a component
Returns
buffer item pointer

Definition at line 108 of file ools/src/fwDataTools/helper/Array.cpp.

Referenced by fwDataTools::helper::ArrayGetter::getItem().

+ Here is the caller graph for this function:

const char * fwDataTools::helper::Array::getBufferPtr ( const ::fwData::Array::IndexType id,
size_t  component,
size_t  sizeOfType 
) const

Get a pointer to the value described by given parameters.

Parameters
idItem id
componentItem component id
sizeOfTypesize of a component
Returns
buffer item pointer

Definition at line 118 of file ools/src/fwDataTools/helper/Array.cpp.

void * fwDataTools::helper::Array::getItem ( const ::fwData::Array::IndexType id,
const size_t  component = 0 
)
virtual

Getter for a buffer item. pointer to the requested item in the buffer.

Parameters
idItem id
componentComponent id
Returns
Pointer to the requested item in the buffer

Definition at line 147 of file ools/src/fwDataTools/helper/Array.cpp.

template<typename T >
T * fwDataTools::helper::Array::getItem ( const ::fwData::Array::IndexType id,
const size_t  component = 0 
)

Typed version of getItem.

Template Parameters
TType in which the pointer will be returned
Parameters
idItem id
componentComponent id
Returns
Array buffer pointer casted to T

Definition at line 185 of file ools/include/fwDataTools/helper/Array.hpp.

void fwDataTools::helper::Array::getItem ( const ::fwData::Array::IndexType id,
void *  value 
) const
virtual

Copies the data into the buffer pointed by

Parameters
idItem id
[out]valueBuffer to write into

Definition at line 156 of file ools/src/fwDataTools/helper/Array.cpp.

void fwDataTools::helper::Array::setBuffer ( void *  buf,
bool  takeOwnership,
const ::fwTools::Type type,
const ::fwData::Array::SizeType size,
size_t  nbOfComponents,
::fwMemory::BufferAllocationPolicy::sptr  policy = ::fwMemory::BufferMallocPolicy::New() 
)

Setter for the array buffer.

An existing buffer will be released if the array own it.

Parameters
bufBuffer to set as Array's buffer
takeOwnershipif true, the Array will manage allocation and destroy the buffer when needed.
typeType of the array view
sizeSize of the array view
nbOfComponentsNumber of components of the array view, Min value : 1
policyIf the array takes ownership of the buffer, specifies the buffer allocation policy.

Definition at line 66 of file ools/src/fwDataTools/helper/Array.cpp.

Referenced by fwItkIO::dataImageFactory(), and fwGdcmIO::reader::ie::Image::readImagePixelModule().

+ Here is the caller graph for this function:

void fwDataTools::helper::Array::setBuffer ( void *  buf,
bool  takeOwnership = false,
::fwMemory::BufferAllocationPolicy::sptr  policy = ::fwMemory::BufferMallocPolicy::New() 
)
protectedvirtual

Protected setter for the array buffer. An existing buffer will be released if the array own it.

Parameters
bufBuffer to set as Array's buffer
takeOwnershipif true, the Array will manage allocation and destroy the buffer when needed.
policyIf the array takes ownership of the buffer, specifies the buffer allocation policy.

Definition at line 45 of file ools/src/fwDataTools/helper/Array.cpp.

void fwDataTools::helper::Array::setItem ( const ::fwData::Array::IndexType id,
const void *  value 
)
virtual

Setter for one item components of the array.

Parameters
idItem id
valueValid buffer of elements of type <m_type> with a length equal to <m_nbOfComponents> to be copied to array 'id'

Definition at line 128 of file ools/src/fwDataTools/helper/Array.cpp.

void fwDataTools::helper::Array::setItem ( const ::fwData::Array::IndexType id,
const size_t  component,
const void *  value 
)
virtual

Setter for one item component of the array.

Parameters
idItem id
componentComponent id to write data in.
valueValid buffer of elements of type <m_type> with a length equal to <m_nbOfComponents> to be copied to array 'id', component index 'component'

Definition at line 137 of file ools/src/fwDataTools/helper/Array.cpp.


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