MDSTk Libraries  1.1.0
Medical Data Segmentation Toolkit
Classes | Public Types | Public Member Functions | Protected Attributes
mds::base::CSHMData< T > Class Template Reference

Class template managing references to a block of allocated memory. More...

#include <mdsSHMData.h>

Inheritance diagram for mds::base::CSHMData< T >:
Inheritance graph
[legend]

List of all members.

Classes

struct  SRefInfo
 Structure containing information on allocated data and the number of references to this data. More...

Public Types

typedef CDataAllocator< T > base
typedef base::tConstData tConstData
 Const data type.
typedef base::tConstDataPtr tConstDataPtr
 Pointer to the constant data.
typedef base::tData tData
 Data type.
typedef base::tDataPtr tDataPtr
 Pointer to the data.

Public Member Functions

tDataat (tSize i)
 Returns reference to the element [i].
const tDataat (tSize i) const
CSHMDatacreate (tSize Size)
 Allocates data of a given size.
CSHMDatacreate (tConstDataPtr pData, tSize Size)
 Allocates data and copies the specified data to it.
CSHMDatacreate (const CSHMData &Data)
 Allocates data and copies the specified data.
CSHMDatacreate (const CSHMData &Data, EMakeRef)
 Makes a new reference to existing data.
CSHMDatacreate (mds::sys::CSharedMem *pSharedMem, tDataPtr pBegin, tSize Size)
 Constructs data in a shared memory.
 CSHMData ()
 Default constructor allocates data of zero length.
 CSHMData (EEmptyConst)
 This constructor does no allocation of the data.
 CSHMData (tSize Size)
 Constructor that allocates a given size of data.
 CSHMData (tConstDataPtr pData, tSize Size)
 Constructor that copies a specified data.
 CSHMData (const CSHMData &Data)
 Constructor copies a given data.
 CSHMData (const CSHMData &Data, EMakeRef)
 Constructor which makes reference to an existing data.
CSHMDatafill (const tData &Value)
 Initializes the data.
template<class Function >
Function forEach (Function Func)
 Calls function object for every element.
template<class Function >
Function forEach (Function Func) const
 Calls function object for every element.
template<class Function >
Function forEach (Function Func)
template<class Function >
Function forEach (Function Func) const
template<class Function >
Function forRange (tSize i, tSize j, Function Func)
 Calls function object for every element.
template<class Function >
Function forRange (tSize i, tSize j, Function Func) const
 Calls function object for every element.
template<class Function >
Function forRange (tSize i, tSize j, Function Func)
template<class Function >
Function forRange (tSize i, tSize j, Function Func) const
int getNumOfReferences () const
 Returns the number of references to the data.
tDatagetPtr (tSize i)
 Returns pointer to the given element.
const tDatagetPtr (tSize i) const
tDataPtr getPtr ()
 Returns pointer to the data.
tConstDataPtr getPtr () const
mds::sys::CSharedMemgetSharedMemPtr ()
 Returns pointer to the shared memory or NULL if data are not located in the shared memory.
tSize getSize () const
 Returns data size.
bool isWithinBlock (tSize i, tSize j) const
 Returns true if the specified range of elements lie within a continuous block of memory.
tDataoperator() (tSize i)
 Returns reference to the subscripted element [i].
const tDataoperator() (tSize i) const
CSHMDataoperator= (const CSHMData &Data)
 Assignment operator.
CSHMDataset (tSize i, const T &Value)
 Sets the element of matrix at the position [i].
 ~CSHMData ()
 Destructor deallocates the data if the number of references decreases to zero.

Protected Attributes

SRefInfom_pRef
 Pointer to the structure containing the referenced data.

Detailed Description

template<typename T>
class mds::base::CSHMData< T >

Class template managing references to a block of allocated memory.


Member Typedef Documentation

template<typename T >
typedef CDataAllocator<T> mds::base::CSHMData< T >::base
template<typename T >
typedef base::tConstData mds::base::CSHMData< T >::tConstData

Const data type.

Reimplemented from mds::base::CDataAllocator< T >.

template<typename T >
typedef base::tConstDataPtr mds::base::CSHMData< T >::tConstDataPtr

Pointer to the constant data.

Reimplemented from mds::base::CDataAllocator< T >.

template<typename T >
typedef base::tData mds::base::CSHMData< T >::tData

Data type.

Reimplemented from mds::base::CDataAllocator< T >.

template<typename T >
typedef base::tDataPtr mds::base::CSHMData< T >::tDataPtr

Pointer to the data.

Reimplemented from mds::base::CDataAllocator< T >.


Constructor & Destructor Documentation

template<typename T >
CSHMData::CSHMData ( )

Default constructor allocates data of zero length.

template<typename T >
CSHMData::CSHMData ( EEmptyConst  ) [explicit]

This constructor does no allocation of the data.

  • Be sure that one of the methods create() is called somewhere.
  • Use with care!
template<typename T >
CSHMData::CSHMData ( tSize  Size) [explicit]

Constructor that allocates a given size of data.

  • Data of the zero size can be allocated.
template<typename T >
CSHMData::CSHMData ( tConstDataPtr  pData,
tSize  Size 
)

Constructor that copies a specified data.

template<typename T >
mds::base::CSHMData< T >::CSHMData ( const CSHMData< T > &  Data)

Constructor copies a given data.

template<typename T >
mds::base::CSHMData< T >::CSHMData ( const CSHMData< T > &  Data,
EMakeRef  MakeRef 
)

Constructor which makes reference to an existing data.

  • Usage: CSHMData(Data, REFERENCE).
template<typename T >
CSHMData::~CSHMData ( )

Destructor deallocates the data if the number of references decreases to zero.


Member Function Documentation

template<typename T >
tData& mds::base::CSHMData< T >::at ( tSize  i)

Returns reference to the element [i].

template<typename T >
const tData& mds::base::CSHMData< T >::at ( tSize  i) const
template<typename T >
CSHMData< T > & CSHMData::create ( tSize  Size)

Allocates data of a given size.

  • In case of several references to the existing data, the reference counter is decremented and new data are allocated.
  • Returns reference to this.
template<typename T >
CSHMData< T > & CSHMData::create ( tConstDataPtr  pData,
tSize  Size 
)

Allocates data and copies the specified data to it.

  • Returns reference to this.
template<typename T >
CSHMData< T > & mds::base::CSHMData< T >::create ( const CSHMData< T > &  Data)

Allocates data and copies the specified data.

  • Returns reference to this.
template<typename T >
CSHMData< T > & mds::base::CSHMData< T >::create ( const CSHMData< T > &  Data,
EMakeRef   
)

Makes a new reference to existing data.

  • Eventually deallocates the associated data.
  • Returns reference to this.
template<typename T >
CSHMData< T > & CSHMData::create ( mds::sys::CSharedMem pSharedMem,
tDataPtr  pBegin,
tSize  Size 
)

Constructs data in a shared memory.

  • Returns reference to this.
template<typename T >
CSHMData< T > & CSHMData::fill ( const tData Value)

Initializes the data.

  • Returns reference to this.
template<typename T >
template<class Function >
Function mds::base::CSHMData< T >::forEach ( Function  Func)

Calls function object for every element.

template<typename T >
template<class Function >
Function mds::base::CSHMData< T >::forEach ( Function  Func) const

Calls function object for every element.

template<typename T >
template<class Function >
Function mds::base::CSHMData< T >::forEach ( Function  Func)
template<typename T >
template<class Function >
Function mds::base::CSHMData< T >::forEach ( Function  Func) const
template<typename T >
template<class Function >
Function mds::base::CSHMData< T >::forRange ( tSize  i,
tSize  j,
Function  Func 
)

Calls function object for every element.

template<typename T >
template<class Function >
Function mds::base::CSHMData< T >::forRange ( tSize  i,
tSize  j,
Function  Func 
) const

Calls function object for every element.

template<typename T >
template<class Function >
Function mds::base::CSHMData< T >::forRange ( tSize  i,
tSize  j,
Function  Func 
)
template<typename T >
template<class Function >
Function mds::base::CSHMData< T >::forRange ( tSize  i,
tSize  j,
Function  Func 
) const
template<typename T >
int mds::base::CSHMData< T >::getNumOfReferences ( ) const

Returns the number of references to the data.

template<typename T >
tData* mds::base::CSHMData< T >::getPtr ( tSize  i)

Returns pointer to the given element.

template<typename T >
const tData* mds::base::CSHMData< T >::getPtr ( tSize  i) const
template<typename T >
tDataPtr mds::base::CSHMData< T >::getPtr ( )

Returns pointer to the data.

template<typename T >
tConstDataPtr mds::base::CSHMData< T >::getPtr ( ) const
template<typename T >
mds::sys::CSharedMem* mds::base::CSHMData< T >::getSharedMemPtr ( )

Returns pointer to the shared memory or NULL if data are not located in the shared memory.

template<typename T >
tSize mds::base::CSHMData< T >::getSize ( ) const

Returns data size.

template<typename T >
bool mds::base::CSHMData< T >::isWithinBlock ( tSize  i,
tSize  j 
) const

Returns true if the specified range of elements lie within a continuous block of memory.

template<typename T >
tData& mds::base::CSHMData< T >::operator() ( tSize  i)

Returns reference to the subscripted element [i].

template<typename T >
const tData& mds::base::CSHMData< T >::operator() ( tSize  i) const
template<typename T >
CSHMData< T > & CSHMData::operator= ( const CSHMData< T > &  Data)

Assignment operator.

  • Makes copy of the data.
template<typename T >
CSHMData& mds::base::CSHMData< T >::set ( tSize  i,
const T &  Value 
)

Sets the element of matrix at the position [i].


Member Data Documentation

template<typename T >
SRefInfo* mds::base::CSHMData< T >::m_pRef [protected]

Pointer to the structure containing the referenced data.


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