te::rp::Matrix< TemplateElementType > Class Template Reference

A generic template matrix. More...

#include <Matrix.h>

Classes

class  DiskLineInfo
 Disk lines info. More...
 
class  OpenDiskFileHandler
 Openend disk files info node. More...
 

Public Types

typedef TemplateElementType ElementTypeT
 Public matrix element type definition. More...
 
enum  MemoryPolicy { AutoMemPol, RAMMemPol, DiskMemPol }
 Memory polycy. More...
 

Public Member Functions

void clear ()
 Clear all allocated resources and go back to the initial default parameters. More...
 
unsigned int getColumnsNumber () const
 The number of current matrix columns. More...
 
unsigned int getLinesNumber () const
 The number of current matrix lines. More...
 
unsigned char getMaxMemPercentUsage () const
 Returns the max amount of free memory to use when necessary. More...
 
unsigned long int getMaxTmpFileSize () const
 Returns the current maximum temporary disk file size. More...
 
MemoryPolicy getMemPolicy () const
 Returns the current memory policy. More...
 
bool isEmpty () const
 Empty Matrix verification. More...
 
 Matrix ()
 
 Matrix (const Matrix< TemplateElementType > &external)
 
TemplateElementType & operator() (const unsigned int &line, const unsigned int &column)
 Operator () overload. More...
 
const TemplateElementType & operator() (const unsigned int &line, const unsigned int &column) const
 Operator () overload. More...
 
const Matrix< TemplateElementType > & operator= (const Matrix< TemplateElementType > &external)
 Operator = overload. More...
 
TemplateElementType * operator[] (const unsigned int &line)
 Operator [] overload. More...
 
TemplateElementType const * operator[] (const unsigned int &line) const
 Operator [] overload. More...
 
void reset ()
 Reset (clear) the active instance data. More...
 
void reset (MemoryPolicy memoryPolicy)
 Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters. More...
 
bool reset (unsigned int lines, unsigned int columns)
 Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters. More...
 
bool reset (unsigned int lines, unsigned int columns, MemoryPolicy memoryPolicy)
 Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters. More...
 
bool reset (unsigned int lines, unsigned int columns, MemoryPolicy memoryPolicy, unsigned char maxMemPercentUsage)
 Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters. More...
 
bool reset (unsigned int lines, unsigned int columns, MemoryPolicy memoryPolicy, unsigned long int maxTmpFileSize, unsigned char maxMemPercentUsage)
 Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters. More...
 
virtual ~Matrix ()
 

Protected Member Functions

bool allocateDiskLines (unsigned int startingLineIdx)
 Allocate disk lines. More...
 
bool createNewDiskFile (unsigned long int size, FILE **fileptr, std::string &fullFileName) const
 Create a new disk file. More...
 
TemplateElementType * getScanLine (const unsigned int &line) const
 Returns a pointer to the required line. More...
 
void init ()
 Reset the internal variables to the initial state. More...
 

Protected Attributes

std::vector< TemplateElementType * > m_allLinesPtrsVec
 A vector with pointers to all lines. More...
 
TemplateElementType * m_currentSwapTilePtr
 A pointer to the current swap tile. More...
 
std::vector< DiskLineInfom_diskLinesInfoVec
 Info of all lines, used when a line is on disk. More...
 
unsigned char m_maxMemPercentUsage
 the max amount of free memory to use when necessary. More...
 
unsigned long int m_maxTmpFileSize
 Max bytes per temp file (for swapped tiles only, default: 2GB). More...
 
std::vector< TemplateElementType * > m_memoryblocksHandler
 
MemoryPolicy m_memoryPolicy
 The used memory policy (default:RAMMemPol). More...
 
unsigned int m_nextSwapLineRamLinesIndexesVecIdx
 The index inside ramLinesIndexesVec_ of the next RAM line index that will be swapped to disk when a disk line is required. More...
 
std::vector< OpenDiskFileHandlerm_openDiskFilesHandler
 A vector with open disk files handler. More...
 
std::vector< unsigned int > m_ramLinesIndexesVec
 The indexes of all lines loaded into RAM. More...
 
boost::scoped_array< TemplateElementType > m_swapMemoryBlockHandler
 An auxiliar line used when swapping data to/from disk. More...
 
unsigned int m_totalColumns
 The total columns number (default:0). More...
 
unsigned int m_totalLines
 The total lines number (default:0). More...
 

Detailed Description

template<typename TemplateElementType>
class te::rp::Matrix< TemplateElementType >

A generic template matrix.

Definition at line 51 of file Matrix.h.

Member Typedef Documentation

template<typename TemplateElementType>
typedef TemplateElementType te::rp::Matrix< TemplateElementType >::ElementTypeT

Public matrix element type definition.

Definition at line 57 of file Matrix.h.

Member Enumeration Documentation

template<typename TemplateElementType>
enum te::rp::Matrix::MemoryPolicy

Memory polycy.

Enumerator
AutoMemPol 

Automatic memory policy ( Try to use RAM or DISK, if there is no avaliable RAM ) DO NOT USE AutoMemPol FOR COMPLEX DATA TYPES.

RAMMemPol 

RAM memory policy.

DiskMemPol 

Disk memory policy ( virtual mapped memory ) - DO NOT USE DiskMemPol FOR COMPLEX DATA TYPES.

Definition at line 62 of file Matrix.h.

Constructor & Destructor Documentation

template<typename TemplateElementType >
te::rp::Matrix< TemplateElementType >::Matrix ( )

Definition at line 459 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::init().

template<typename TemplateElementType>
te::rp::Matrix< TemplateElementType >::Matrix ( const Matrix< TemplateElementType > &  external)
template<typename TemplateElementType >
te::rp::Matrix< TemplateElementType >::~Matrix ( )
virtual

Definition at line 474 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::clear().

Member Function Documentation

template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::allocateDiskLines ( unsigned int  startingLineIdx)
protected
template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::createNewDiskFile ( unsigned long int  size,
FILE **  fileptr,
std::string &  fullFileName 
) const
protected

Create a new disk file.

Parameters
sizeThe file size.
fileptrThe file pointer.
fullFileNameThe created full file name.
Returns
true if OK. false on errors.

Definition at line 891 of file Matrix.h.

References TERP_LOGERR, and TERP_TRUE_OR_RETURN_FALSE.

Referenced by te::rp::Matrix< TemplateElementType >::allocateDiskLines().

template<typename TemplateElementType >
unsigned int te::rp::Matrix< TemplateElementType >::getColumnsNumber ( ) const

The number of current matrix columns.

Returns
The number of current matrix columns

Definition at line 678 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_totalColumns.

Referenced by te::rp::Skeleton::applyMeanSmooth(), te::rp::CreateRasterFileFromMatrix(), and te::rp::Skeleton::getMagnitude().

template<typename TemplateElementType >
unsigned int te::rp::Matrix< TemplateElementType >::getLinesNumber ( ) const

The number of current matrix lines.

Returns
The number of current matrix lines.

Definition at line 671 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_totalLines.

Referenced by te::rp::Skeleton::applyMeanSmooth(), te::rp::CreateRasterFileFromMatrix(), and te::rp::Skeleton::getMagnitude().

template<typename TemplateElementType >
unsigned char te::rp::Matrix< TemplateElementType >::getMaxMemPercentUsage ( ) const

Returns the max amount of free memory to use when necessary.

Returns
Returns the max amount of free memory to use when necessary.

Definition at line 729 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage.

template<typename TemplateElementType >
unsigned long int te::rp::Matrix< TemplateElementType >::getMaxTmpFileSize ( ) const

Returns the current maximum temporary disk file size.

Returns
Returns the current maximum temporary disk file size.

Definition at line 723 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize.

template<typename TemplateElementType >
Matrix< TemplateElementType >::MemoryPolicy te::rp::Matrix< TemplateElementType >::getMemPolicy ( ) const

Returns the current memory policy.

Returns
The current memory policy.

Definition at line 717 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_memoryPolicy.

template<typename TemplateElementType >
TemplateElementType * te::rp::Matrix< TemplateElementType >::getScanLine ( const unsigned int &  line) const
protected
template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::isEmpty ( ) const

Empty Matrix verification.

Returns
true if the matrix is empty.

Definition at line 685 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_totalLines.

template<typename TemplateElementType>
TemplateElementType& te::rp::Matrix< TemplateElementType >::operator() ( const unsigned int &  line,
const unsigned int &  column 
)
inline

Operator () overload.

Parameters
lineLine number.
columnColumn number.
Returns
A reference to the required element.

Definition at line 203 of file Matrix.h.

template<typename TemplateElementType>
const TemplateElementType& te::rp::Matrix< TemplateElementType >::operator() ( const unsigned int &  line,
const unsigned int &  column 
) const
inline

Operator () overload.

Parameters
lineLine number.
columnColumn number.
Returns
A const reference to the required element.

Definition at line 220 of file Matrix.h.

template<typename TemplateElementType>
const Matrix< TemplateElementType > & te::rp::Matrix< TemplateElementType >::operator= ( const Matrix< TemplateElementType > &  external)
template<typename TemplateElementType>
TemplateElementType* te::rp::Matrix< TemplateElementType >::operator[] ( const unsigned int &  line)
inline

Operator [] overload.

Parameters
lineLine number.
columnColumn number.
Returns
A pointer to the required line.
Note
The returned pointer is garanteed to be valid until an acess to another line occurs.
Concurrent thread access to this method is guaranteed if RAMMemPol policy method is used.

Definition at line 241 of file Matrix.h.

template<typename TemplateElementType>
TemplateElementType const* te::rp::Matrix< TemplateElementType >::operator[] ( const unsigned int &  line) const
inline

Operator [] overload.

Parameters
lineLine number.
columnColumn number.
Returns
A pointer to the required line.
Note
The returned pointer is garanteed to be valid until an acess to another line occurs.
Concurrent thread access to this method is guaranteed if RAMMemPol policy method is used.

Definition at line 258 of file Matrix.h.

template<typename TemplateElementType >
void te::rp::Matrix< TemplateElementType >::reset ( )

Reset (clear) the active instance data.

Note
Other parameters will not be changed.
Parameters
memoryPolicyMemory policy.

Definition at line 480 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::clear().

Referenced by te::rp::Skeleton::applyMeanSmooth(), te::rp::Skeleton::getMagnitude(), te::rp::Matrix< TemplateElementType >::operator=(), and te::rp::Matrix< TemplateElementType >::reset().

template<typename TemplateElementType >
void te::rp::Matrix< TemplateElementType >::reset ( MemoryPolicy  memoryPolicy)

Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters.

Note
Other parameters will not be changed.
Parameters
memoryPolicyMemory policy.

Definition at line 486 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, and te::rp::Matrix< TemplateElementType >::reset().

template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::reset ( unsigned int  lines,
unsigned int  columns 
)

Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters.

Note
Other parameters will not be changed.
Parameters
linesNumber of lines.
columnsNumber of columns.
Returns
true if OK, false on error.

Definition at line 492 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, te::rp::Matrix< TemplateElementType >::m_memoryPolicy, and te::rp::Matrix< TemplateElementType >::reset().

template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::reset ( unsigned int  lines,
unsigned int  columns,
MemoryPolicy  memoryPolicy 
)

Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters.

Note
Other parameters will not be changed.
Parameters
linesNumber of lines.
columnsNumber of columns.
memoryPolicyMemory policy.
Returns
true if OK, false on error.

Definition at line 500 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, and te::rp::Matrix< TemplateElementType >::reset().

template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::reset ( unsigned int  lines,
unsigned int  columns,
MemoryPolicy  memoryPolicy,
unsigned char  maxMemPercentUsage 
)

Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters.

Note
Other parameters will not be changed.
Parameters
linesNumber of lines.
columnsNumber of columns.
memoryPolicyMemory policy.
maxMemPercentUsageThe max amount of free memory to use when necessary (suggested default:40).
Returns
true if OK, false on error.

Definition at line 508 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, and te::rp::Matrix< TemplateElementType >::reset().

template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::reset ( unsigned int  lines,
unsigned int  columns,
MemoryPolicy  memoryPolicy,
unsigned long int  maxTmpFileSize,
unsigned char  maxMemPercentUsage 
)

Member Data Documentation

template<typename TemplateElementType>
std::vector< TemplateElementType* > te::rp::Matrix< TemplateElementType >::m_allLinesPtrsVec
mutableprotected
template<typename TemplateElementType>
TemplateElementType* te::rp::Matrix< TemplateElementType >::m_currentSwapTilePtr
mutableprotected
template<typename TemplateElementType>
std::vector< DiskLineInfo > te::rp::Matrix< TemplateElementType >::m_diskLinesInfoVec
mutableprotected
template<typename TemplateElementType>
unsigned char te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage
protected
template<typename TemplateElementType>
unsigned long int te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize
protected
template<typename TemplateElementType>
std::vector< TemplateElementType* > te::rp::Matrix< TemplateElementType >::m_memoryblocksHandler
protected
template<typename TemplateElementType>
MemoryPolicy te::rp::Matrix< TemplateElementType >::m_memoryPolicy
protected
template<typename TemplateElementType>
unsigned int te::rp::Matrix< TemplateElementType >::m_nextSwapLineRamLinesIndexesVecIdx
mutableprotected

The index inside ramLinesIndexesVec_ of the next RAM line index that will be swapped to disk when a disk line is required.

Definition at line 346 of file Matrix.h.

Referenced by te::rp::Matrix< TemplateElementType >::getScanLine(), and te::rp::Matrix< TemplateElementType >::init().

template<typename TemplateElementType>
std::vector< OpenDiskFileHandler > te::rp::Matrix< TemplateElementType >::m_openDiskFilesHandler
protected

A vector with open disk files handler.

Definition at line 363 of file Matrix.h.

Referenced by te::rp::Matrix< TemplateElementType >::allocateDiskLines(), and te::rp::Matrix< TemplateElementType >::clear().

template<typename TemplateElementType>
std::vector< unsigned int > te::rp::Matrix< TemplateElementType >::m_ramLinesIndexesVec
mutableprotected
template<typename TemplateElementType>
boost::scoped_array< TemplateElementType > te::rp::Matrix< TemplateElementType >::m_swapMemoryBlockHandler
mutableprotected

An auxiliar line used when swapping data to/from disk.

Definition at line 379 of file Matrix.h.

Referenced by te::rp::Matrix< TemplateElementType >::clear(), and te::rp::Matrix< TemplateElementType >::reset().


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