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

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

#include <mdsRefData.h>

Inheritance diagram for mds::base::CRefData< 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
CRefDatacreate (tSize Size)
 Allocates data of a given size.
CRefDatacreate (tConstDataPtr pData, tSize Size)
 Allocates data and copies the specified data to it.
CRefDatacreate (const CRefData &Data)
 Allocates data and copies the specified data.
CRefDatacreate (const CRefData &Data, EMakeRef)
 Makes a new reference to existing data.
 CRefData ()
 Default constructor allocates data of zero length.
 CRefData (EEmptyConst)
 This constructor does no allocation of the data.
 CRefData (tSize Size)
 Constructor that allocates a given size of data.
 CRefData (tConstDataPtr pData, tSize Size)
 Constructor that copies a specified data.
 CRefData (const CRefData &Data)
 Constructor copies a given data.
 CRefData (const CRefData &Data, EMakeRef)
 Constructor which makes reference to an existing data.
CRefDatafill (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 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
CRefDataoperator= (const CRefData &Data)
 Assignment operator.
CRefDataset (tSize i, const T &Value)
 Sets the element of matrix at the position [i].
 ~CRefData ()
 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::CRefData< T >

Class template managing references to a block of memory.


Member Typedef Documentation

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

Const data type.

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

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

Pointer to the constant data.

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

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

Data type.

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

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

Pointer to the data.

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


Constructor & Destructor Documentation

template<typename T >
CRefData::CRefData ( )

Default constructor allocates data of zero length.

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

Constructor that allocates a given size of data.

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

Constructor that copies a specified data.

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

Constructor copies a given data.

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

Constructor which makes reference to an existing data.

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

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


Member Function Documentation

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

Returns reference to the element [i].

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

Allocates data and copies the specified data to it.

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

Allocates data and copies the specified data.

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

Makes a new reference to existing data.

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

Initializes the data.

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

Calls function object for every element.

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

Calls function object for every element.

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

Calls function object for every element.

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

Calls function object for every element.

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

Returns the number of references to the data.

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

Returns pointer to the given element.

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

Returns pointer to the data.

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

Returns data size.

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

Returns reference to the subscripted element [i].

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

Assignment operator.

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

Pointer to the structure containing the referenced data.


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