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. | |
enum | MemoryPolicy { AutoMemPol , RAMMemPol , DiskMemPol } |
Memory polycy. More... | |
Public Member Functions | |
unsigned int | getColumnsNumber () const |
The number of current matrix columns. | |
unsigned int | getLinesNumber () const |
The number of current matrix lines. | |
unsigned int | getMaxRAMLines () const |
Returns the allowed maximum amount of RAM lines. | |
unsigned long int | getMaxTmpFileSize () const |
Returns the current maximum temporary disk file size. | |
MemoryPolicy | getMemPolicy () const |
Returns the current memory policy. | |
bool | isEmpty () const |
Empty Matrix verification. | |
Matrix () | |
Matrix (const Matrix< TemplateElementType > &external) | |
TemplateElementType & | operator() (const unsigned int &line, const unsigned int &column) |
Operator () overload. | |
const TemplateElementType & | operator() (const unsigned int &line, const unsigned int &column) const |
Operator () overload. | |
const Matrix< TemplateElementType > & | operator= (const Matrix< TemplateElementType > &external) |
Operator = overload. | |
TemplateElementType * | operator[] (const unsigned int &line) |
Operator [] overload. | |
TemplateElementType const * | operator[] (const unsigned int &line) const |
Operator [] overload. | |
void | reset () |
Reset (clear) the active instance data. | |
void | reset (MemoryPolicy memoryPolicy) |
Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters. | |
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. | |
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. | |
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. | |
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. | |
virtual | ~Matrix () |
Protected Member Functions | |
void | clear () |
Clear all allocated resources but keep the current parameters. | |
TemplateElementType * | getScanLine (const unsigned int &line) const |
Returns a pointer to the required line. | |
void | init () |
Reset the internal variables to the default state. | |
Protected Attributes | |
std::vector< TemplateElementType * > | m_allLinesPtrsVec |
A vector with pointers to all lines. | |
TemplateElementType * | m_currentSwapTilePtr |
A pointer to the current swap tile. | |
std::vector< DiskLineInfo > | m_diskLinesInfoVec |
Info of all lines, used when a line is on disk. | |
unsigned int | m_maxRAMLines |
the max amount of RAM lines. | |
unsigned long int | m_maxTmpFileSize |
Max bytes per temp file (for swapped tiles only, default: 2GB). | |
std::vector< TemplateElementType * > | m_memoryblocksHandler |
MemoryPolicy | m_memoryPolicy |
The used memory policy (default:RAMMemPol). | |
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. | |
std::vector< OpenDiskFileHandler > | m_openDiskFilesHandler |
A vector with open disk files handler. | |
std::vector< unsigned int > | m_ramLinesIndexesVec |
The indexes of all lines loaded into RAM. | |
boost::scoped_array< TemplateElementType > | m_swapMemoryBlockHandler |
An auxiliar line used when swapping data to/from disk. | |
unsigned int | m_totalColumns |
The total columns number (default:0). | |
unsigned int | m_totalLines |
The total lines number (default:0). | |
A generic template matrix.
typedef TemplateElementType te::rp::Matrix< TemplateElementType >::ElementTypeT |
enum te::rp::Matrix::MemoryPolicy |
te::rp::Matrix< TemplateElementType >::Matrix |
Definition at line 471 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::init().
te::rp::Matrix< TemplateElementType >::Matrix | ( | const Matrix< TemplateElementType > & | external | ) |
Definition at line 477 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::init(), and te::rp::Matrix< TemplateElementType >::operator=().
|
virtual |
Definition at line 486 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::clear().
|
protected |
Clear all allocated resources but keep the current parameters.
Definition at line 747 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_allLinesPtrsVec, te::rp::Matrix< TemplateElementType >::m_currentSwapTilePtr, te::rp::Matrix< TemplateElementType >::m_diskLinesInfoVec, te::rp::Matrix< TemplateElementType >::m_memoryblocksHandler, te::rp::Matrix< TemplateElementType >::m_nextSwapLineRamLinesIndexesVecIdx, te::rp::Matrix< TemplateElementType >::m_openDiskFilesHandler, te::rp::Matrix< TemplateElementType >::m_ramLinesIndexesVec, te::rp::Matrix< TemplateElementType >::m_swapMemoryBlockHandler, te::rp::Matrix< TemplateElementType >::m_totalColumns, and te::rp::Matrix< TemplateElementType >::m_totalLines.
Referenced by te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), and te::rp::Matrix< TemplateElementType >::~Matrix().
unsigned int te::rp::Matrix< TemplateElementType >::getColumnsNumber |
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().
unsigned int te::rp::Matrix< TemplateElementType >::getLinesNumber |
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().
unsigned int te::rp::Matrix< TemplateElementType >::getMaxRAMLines |
Returns the allowed maximum amount of RAM lines.
Definition at line 840 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_maxRAMLines.
unsigned long int te::rp::Matrix< TemplateElementType >::getMaxTmpFileSize |
Returns the current maximum temporary disk file size.
Definition at line 834 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize.
Matrix< TemplateElementType >::MemoryPolicy te::rp::Matrix< TemplateElementType >::getMemPolicy |
Returns the current memory policy.
Definition at line 828 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_memoryPolicy.
|
protected |
Returns a pointer to the required line.
line | Line number. |
column | Column number. |
Definition at line 847 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_allLinesPtrsVec, te::rp::Matrix< TemplateElementType >::m_currentSwapTilePtr, te::rp::Matrix< TemplateElementType >::m_diskLinesInfoVec, te::rp::Matrix< TemplateElementType >::DiskLineInfo::m_fileOff, te::rp::Matrix< TemplateElementType >::DiskLineInfo::m_filePtr, te::rp::Matrix< TemplateElementType >::m_nextSwapLineRamLinesIndexesVecIdx, te::rp::Matrix< TemplateElementType >::m_ramLinesIndexesVec, te::rp::Matrix< TemplateElementType >::m_totalColumns, te::rp::Matrix< TemplateElementType >::m_totalLines, TERP_DEBUG_TRUE_OR_THROW, and TERP_TRUE_OR_THROW.
Referenced by te::rp::Matrix< TemplateElementType >::operator()(), te::rp::Matrix< TemplateElementType >::operator()(), te::rp::Matrix< TemplateElementType >::operator=(), te::rp::Matrix< TemplateElementType >::operator[](), and te::rp::Matrix< TemplateElementType >::operator[]().
|
protected |
Reset the internal variables to the default state.
Definition at line 459 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_currentSwapTilePtr, te::rp::Matrix< TemplateElementType >::m_maxRAMLines, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, te::rp::Matrix< TemplateElementType >::m_memoryPolicy, te::rp::Matrix< TemplateElementType >::m_nextSwapLineRamLinesIndexesVecIdx, te::rp::Matrix< TemplateElementType >::m_totalColumns, te::rp::Matrix< TemplateElementType >::m_totalLines, and te::rp::Matrix< TemplateElementType >::RAMMemPol.
Referenced by te::rp::Matrix< TemplateElementType >::Matrix(), and te::rp::Matrix< TemplateElementType >::Matrix().
bool te::rp::Matrix< TemplateElementType >::isEmpty |
Empty Matrix verification.
Definition at line 796 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_totalLines.
|
inline |
Operator () overload.
line | Line number. |
column | Column number. |
Definition at line 227 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::Matrix< TemplateElementType >::m_totalColumns, and TERP_DEBUG_TRUE_OR_THROW.
|
inline |
Operator () overload.
line | Line number. |
column | Column number. |
Definition at line 244 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::Matrix< TemplateElementType >::m_totalColumns, and TERP_DEBUG_TRUE_OR_THROW.
const Matrix< TemplateElementType > & te::rp::Matrix< TemplateElementType >::operator= | ( | const Matrix< TemplateElementType > & | external | ) |
Operator = overload.
external | External instance reference. |
Definition at line 802 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::Matrix< TemplateElementType >::m_maxRAMLines, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, te::rp::Matrix< TemplateElementType >::m_memoryPolicy, te::rp::Matrix< TemplateElementType >::m_totalColumns, te::rp::Matrix< TemplateElementType >::m_totalLines, te::rp::Matrix< TemplateElementType >::reset(), and TERP_TRUE_OR_THROW.
Referenced by te::rp::Matrix< TemplateElementType >::Matrix().
|
inline |
Operator [] overload.
line | Line number. |
column | Column number. |
Definition at line 265 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::getScanLine().
|
inline |
Operator [] overload.
line | Line number. |
column | Column number. |
Definition at line 282 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::getScanLine().
void te::rp::Matrix< TemplateElementType >::reset |
Reset (clear) the active instance data.
memoryPolicy | Memory 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=(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), and te::rp::Matrix< TemplateElementType >::reset().
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.
memoryPolicy | Memory policy. |
Definition at line 498 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::clear(), and te::rp::Matrix< TemplateElementType >::m_memoryPolicy.
bool te::rp::Matrix< TemplateElementType >::reset | ( | MemoryPolicy | memoryPolicy, |
unsigned int | lines, | ||
unsigned int | columns, | ||
unsigned int | maxRAMLines | ||
) |
lines | Number of lines. |
columns | Number of columns. |
memoryPolicy | Memory policy. |
maxRAMLines | The max amount of RAM memory lines to allocate (when using AutoMemPol). |
Definition at line 564 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, and te::rp::Matrix< TemplateElementType >::reset().
bool te::rp::Matrix< TemplateElementType >::reset | ( | MemoryPolicy | memoryPolicy, |
unsigned int | lines, | ||
unsigned int | columns, | ||
unsigned long int | maxTmpFileSize, | ||
unsigned int | maxRAMLines | ||
) |
lines | Number of lines. |
columns | Number of columns. |
memoryPolicy | Memory policy. |
maxTmpFileSize | Max temp file size. |
maxRAMLines | The max amount of RAM memory lines to allocate (when using AutoMemPol). |
Definition at line 572 of file Matrix.h.
References te::core::FileSystem::allocateTmpDiskFile(), te::rp::Matrix< TemplateElementType >::clear(), te::rp::Matrix< TemplateElementType >::DiskMemPol, te::rp::Matrix< TemplateElementType >::m_allLinesPtrsVec, te::rp::Matrix< TemplateElementType >::m_currentSwapTilePtr, te::rp::Matrix< TemplateElementType >::m_diskLinesInfoVec, te::rp::Matrix< TemplateElementType >::m_maxRAMLines, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, te::rp::Matrix< TemplateElementType >::m_memoryblocksHandler, te::rp::Matrix< TemplateElementType >::m_memoryPolicy, te::rp::Matrix< TemplateElementType >::m_openDiskFilesHandler, te::rp::Matrix< TemplateElementType >::m_ramLinesIndexesVec, te::rp::Matrix< TemplateElementType >::m_swapMemoryBlockHandler, te::rp::Matrix< TemplateElementType >::m_totalColumns, te::rp::Matrix< TemplateElementType >::m_totalLines, te::rp::Matrix< TemplateElementType >::RAMMemPol, and TERP_LOG_AND_RETURN_FALSE.
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.
lines | Number of lines. |
columns | Number of columns. |
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().
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.
lines | Number of lines. |
columns | Number of columns. |
memoryPolicy | Memory policy. |
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().
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.
lines | Number of lines. |
columns | Number of columns. |
memoryPolicy | Memory policy. |
maxMemPercentUsage | The max amount of free memory to use when necessary (suggested default:40). |
Definition at line 519 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, and te::rp::Matrix< TemplateElementType >::reset().
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.
lines | Number of lines. |
columns | Number of columns. |
memoryPolicy | Memory policy. |
maxTmpFileSize | Max temp file size. |
maxMemPercentUsage | The max amount of free memory to use when necessary (suggested default:40). |
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().
|
mutableprotected |
A vector with pointers to all lines.
Definition at line 382 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::clear(), te::rp::Matrix< TemplateElementType >::getScanLine(), and te::rp::Matrix< TemplateElementType >::reset().
|
mutableprotected |
A pointer to the current swap tile.
Definition at line 375 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::clear(), te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::Matrix< TemplateElementType >::init(), and te::rp::Matrix< TemplateElementType >::reset().
|
mutableprotected |
Info of all lines, used when a line is on disk.
Definition at line 392 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::clear(), te::rp::Matrix< TemplateElementType >::getScanLine(), and te::rp::Matrix< TemplateElementType >::reset().
|
protected |
the max amount of RAM lines.
Definition at line 348 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::getMaxRAMLines(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::operator=(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), and te::rp::Matrix< TemplateElementType >::reset().
|
protected |
Max bytes per temp file (for swapped tiles only, default: 2GB).
Definition at line 343 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::getMaxTmpFileSize(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::operator=(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), and te::rp::Matrix< TemplateElementType >::reset().
|
protected |
Definition at line 377 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::clear(), and te::rp::Matrix< TemplateElementType >::reset().
|
protected |
The used memory policy (default:RAMMemPol).
Definition at line 363 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::getMemPolicy(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::operator=(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), te::rp::Matrix< TemplateElementType >::reset(), and te::rp::Matrix< TemplateElementType >::reset().
|
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().
|
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().
|
mutableprotected |
The indexes of all lines loaded into RAM.
Definition at line 397 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::clear(), te::rp::Matrix< TemplateElementType >::getScanLine(), and te::rp::Matrix< TemplateElementType >::reset().
|
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().
|
protected |
The total columns number (default:0).
Definition at line 358 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::clear(), te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::operator()(), te::rp::Matrix< TemplateElementType >::operator()(), te::rp::Matrix< TemplateElementType >::operator=(), and te::rp::Matrix< TemplateElementType >::reset().
|
protected |
The total lines number (default:0).
Definition at line 353 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::clear(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::isEmpty(), te::rp::Matrix< TemplateElementType >::operator=(), and te::rp::Matrix< TemplateElementType >::reset().