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

Class template managing references to a block of memory that is allocated in parts as a sequence of smaller memory blocks. More...

#include <mdsPartedData.h>

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

List of all members.

Classes

struct  SRefInfo
 Structure containing information on allocated data and the number of references. 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
 CPartedData ()
 Default constructor allocates data of zero length.
 CPartedData (EEmptyConst)
 This constructor does no allocation of the data.
 CPartedData (tSize Size)
 Constructor that allocates a given size of data.
 CPartedData (tConstDataPtr pData, tSize Size)
 Constructor that copies a specified data.
 CPartedData (const CPartedData &Data)
 Constructor copies a given data.
 CPartedData (const CPartedData &Data, EMakeRef)
 Constructor which makes reference to an existing data.
CPartedDatacreate (tSize Size)
 Allocates data of a given size.
CPartedDatacreate (tConstDataPtr pData, tSize Size)
 Allocates data and copies the specified data to it.
CPartedDatacreate (const CPartedData &Data)
 Allocates data and copies the specified data.
CPartedDatacreate (const CPartedData &Data, EMakeRef)
 Makes a new reference to existing data.
CPartedDatafill (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.
tDataPtr getPtr (tSize i)
 Returns pointer to the given element.
tConstDataPtr getPtr (tSize i) const
tDataPtr getPtr ()
 Returns pointer to the beginning of the data.
tConstDataPtr getPtr () const
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
CPartedDataoperator= (const CPartedData &Data)
 Assignment operator.
CPartedDataset (tSize i, const T &Value)
 Sets the element of matrix at the position [i].
 ~CPartedData ()
 Destructor deallocates the data if the number of references decreases to zero.

Protected Types

typedef tDataPtrtDataBlocks
 Vector of allocated data blocks.

Protected Attributes

SRefInfom_pRef
 Pointer to the structure containing the referenced data.

Detailed Description

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

Class template managing references to a block of memory that is allocated in parts as a sequence of smaller memory blocks.


Member Typedef Documentation

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

Const data type.

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

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

Pointer to the constant data.

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

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

Data type.

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

template<typename T >
typedef tDataPtr* mds::base::CPartedData< T >::tDataBlocks [protected]

Vector of allocated data blocks.

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

Pointer to the data.

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


Constructor & Destructor Documentation

template<typename T >
CPartedData::CPartedData ( )

Default constructor allocates data of zero length.

template<typename T >
CPartedData::CPartedData ( 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 >
CPartedData::CPartedData ( tSize  Size) [explicit]

Constructor that allocates a given size of data.

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

Constructor that copies a specified data.

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

Constructor copies a given data.

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

Constructor which makes reference to an existing data.

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

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


Member Function Documentation

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

Returns reference to the element [i].

template<typename T >
const tData& mds::base::CPartedData< T >::at ( tSize  i) const
template<typename T >
CPartedData< T > & CPartedData::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 >
CPartedData< T > & CPartedData::create ( tConstDataPtr  pData,
tSize  Size 
)

Allocates data and copies the specified data to it.

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

Allocates data and copies the specified data.

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

Makes a new reference to existing data.

  • Eventually deallocates the associated data.
  • Returns reference to this.
template<typename T >
CPartedData< T > & CPartedData::fill ( const tData Value)

Initializes the data.

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

Calls function object for every element.

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

Calls function object for every element.

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

Calls function object for every element.

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

Calls function object for every element.

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

Returns the number of references to the data.

template<typename T >
tDataPtr mds::base::CPartedData< T >::getPtr ( tSize  i)

Returns pointer to the given element.

template<typename T >
tConstDataPtr mds::base::CPartedData< T >::getPtr ( tSize  i) const
template<typename T >
tDataPtr mds::base::CPartedData< T >::getPtr ( )

Returns pointer to the beginning of the data.

template<typename T >
tConstDataPtr mds::base::CPartedData< T >::getPtr ( ) const
template<typename T >
tSize mds::base::CPartedData< T >::getSize ( ) const

Returns data size.

template<typename T >
bool mds::base::CPartedData< 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::CPartedData< T >::operator() ( tSize  i)

Returns reference to the subscripted element [i].

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

Assignment operator.

  • Makes copy of the data.
template<typename T >
CPartedData& mds::base::CPartedData< 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::CPartedData< T >::m_pRef [protected]

Pointer to the structure containing the referenced data.


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