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

unsigned int getColumnsNumber () const
 The number of current matrix columns. More...
 
unsigned int getLinesNumber () const
 The number of current matrix lines. More...
 
unsigned int getMaxRAMLines () const
 Returns the allowed maximum amount of RAM lines. 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 (MemoryPolicy memoryPolicy, unsigned int lines, unsigned int columns, unsigned int maxRAMLines)
 
bool reset (MemoryPolicy memoryPolicy, unsigned int lines, unsigned int columns, unsigned long int maxTmpFileSize, unsigned int maxRAMLines)
 
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

void clear ()
 Clear all allocated resources but keep the current parameters. More...
 
TemplateElementType * getScanLine (const unsigned int &line) const
 Returns a pointer to the required line. More...
 
void init ()
 Reset the internal variables to the default 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 int m_maxRAMLines
 the max amount of RAM lines. 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 55 of file Matrix.h.

Member Typedef Documentation

◆ ElementTypeT

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

Public matrix element type definition.

Definition at line 61 of file Matrix.h.

Member Enumeration Documentation

◆ MemoryPolicy

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 66 of file Matrix.h.

Constructor & Destructor Documentation

◆ Matrix() [1/2]

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

Definition at line 471 of file Matrix.h.

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

◆ Matrix() [2/2]

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

◆ ~Matrix()

template<typename TemplateElementType >
te::rp::Matrix< TemplateElementType >::~Matrix
virtual

Definition at line 486 of file Matrix.h.

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

Member Function Documentation

◆ clear()

◆ getColumnsNumber()

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

The number of current matrix columns.

Returns
The number of current matrix columns

Definition at line 789 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().

◆ getLinesNumber()

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

The number of current matrix lines.

Returns
The number of current matrix lines.

Definition at line 782 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().

◆ getMaxRAMLines()

template<typename TemplateElementType >
unsigned int te::rp::Matrix< TemplateElementType >::getMaxRAMLines

Returns the allowed maximum amount of RAM lines.

Returns
Returns the allowed maximum amount of RAM lines.

Definition at line 840 of file Matrix.h.

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

◆ getMaxTmpFileSize()

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

Returns the current maximum temporary disk file size.

Returns
Returns the current maximum temporary disk file size.

Definition at line 834 of file Matrix.h.

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

◆ getMemPolicy()

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

Returns the current memory policy.

Returns
The current memory policy.

Definition at line 828 of file Matrix.h.

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

◆ getScanLine()

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

◆ init()

◆ isEmpty()

template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::isEmpty

Empty Matrix verification.

Returns
true if the matrix is empty.

Definition at line 796 of file Matrix.h.

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

◆ operator()() [1/2]

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 227 of file Matrix.h.

◆ operator()() [2/2]

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 244 of file Matrix.h.

◆ operator=()

template<typename TemplateElementType >
const Matrix< TemplateElementType > & te::rp::Matrix< TemplateElementType >::operator= ( const Matrix< TemplateElementType > &  external)

◆ operator[]() [1/2]

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 265 of file Matrix.h.

◆ operator[]() [2/2]

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 282 of file Matrix.h.

◆ reset() [1/8]

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 492 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().

◆ reset() [2/8]

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 498 of file Matrix.h.

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

◆ reset() [3/8]

template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::reset ( MemoryPolicy  memoryPolicy,
unsigned int  lines,
unsigned int  columns,
unsigned int  maxRAMLines 
)
Parameters
linesNumber of lines.
columnsNumber of columns.
memoryPolicyMemory policy.
maxRAMLinesThe max amount of RAM memory lines to allocate (when using AutoMemPol).
Returns
true if OK, false on error.
Note
Other parameters will not be changed.

Definition at line 564 of file Matrix.h.

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

◆ reset() [4/8]

◆ reset() [5/8]

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 505 of file Matrix.h.

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

◆ reset() [6/8]

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.
Note
Other parameters will not be changed.

Definition at line 512 of file Matrix.h.

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

◆ reset() [7/8]

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.
Note
Other parameters will not be changed.

Definition at line 519 of file Matrix.h.

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

◆ reset() [8/8]

template<typename TemplateElementType >
bool te::rp::Matrix< TemplateElementType >::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.

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

Definition at line 528 of file Matrix.h.

References te::rp::Matrix< TemplateElementType >::AutoMemPol, te::common::GetTotalPhysicalMemory(), te::common::GetTotalVirtualMemory(), te::common::GetUsedVirtualMemory(), te::rp::Matrix< TemplateElementType >::m_memoryPolicy, and te::rp::Matrix< TemplateElementType >::reset().

Member Data Documentation

◆ m_allLinesPtrsVec

template<typename TemplateElementType >
std::vector< TemplateElementType* > te::rp::Matrix< TemplateElementType >::m_allLinesPtrsVec
mutableprotected

◆ m_currentSwapTilePtr

template<typename TemplateElementType >
TemplateElementType* te::rp::Matrix< TemplateElementType >::m_currentSwapTilePtr
mutableprotected

◆ m_diskLinesInfoVec

template<typename TemplateElementType >
std::vector< DiskLineInfo > te::rp::Matrix< TemplateElementType >::m_diskLinesInfoVec
mutableprotected

◆ m_maxRAMLines

template<typename TemplateElementType >
unsigned int te::rp::Matrix< TemplateElementType >::m_maxRAMLines
protected

◆ m_maxTmpFileSize

template<typename TemplateElementType >
unsigned long int te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize
protected

◆ m_memoryblocksHandler

template<typename TemplateElementType >
std::vector< TemplateElementType* > te::rp::Matrix< TemplateElementType >::m_memoryblocksHandler
protected

◆ m_memoryPolicy

template<typename TemplateElementType >
MemoryPolicy te::rp::Matrix< TemplateElementType >::m_memoryPolicy
protected

◆ m_nextSwapLineRamLinesIndexesVecIdx

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 370 of file Matrix.h.

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

◆ m_openDiskFilesHandler

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

A vector with open disk files handler.

Definition at line 387 of file Matrix.h.

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

◆ m_ramLinesIndexesVec

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

◆ m_swapMemoryBlockHandler

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 403 of file Matrix.h.

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

◆ m_totalColumns

◆ m_totalLines


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