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< DiskLineInfo > | m_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< OpenDiskFileHandler > | m_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... | |
A generic template matrix.
typedef TemplateElementType te::rp::Matrix< TemplateElementType >::ElementTypeT |
enum te::rp::Matrix::MemoryPolicy |
te::rp::Matrix< TemplateElementType >::Matrix | ( | ) |
Definition at line 459 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::init().
te::rp::Matrix< TemplateElementType >::Matrix | ( | const Matrix< TemplateElementType > & | external | ) |
Definition at line 465 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::init(), and te::rp::Matrix< TemplateElementType >::operator=().
|
virtual |
Definition at line 474 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::clear().
|
protected |
Allocate disk lines.
startingLineIdx | Starting line index. |
Definition at line 735 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::createNewDiskFile(), te::rp::Matrix< TemplateElementType >::m_diskLinesInfoVec, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, te::rp::Matrix< TemplateElementType >::m_openDiskFilesHandler, te::rp::Matrix< TemplateElementType >::m_totalColumns, te::rp::Matrix< TemplateElementType >::m_totalLines, and TERP_LOGERR.
Referenced by te::rp::Matrix< TemplateElementType >::reset().
void te::rp::Matrix< TemplateElementType >::clear | ( | ) |
Clear all allocated resources and go back to the initial default parameters.
Definition at line 642 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::m_allLinesPtrsVec, te::rp::Matrix< TemplateElementType >::m_diskLinesInfoVec, te::rp::Matrix< TemplateElementType >::m_memoryblocksHandler, te::rp::Matrix< TemplateElementType >::m_openDiskFilesHandler, te::rp::Matrix< TemplateElementType >::m_ramLinesIndexesVec, and te::rp::Matrix< TemplateElementType >::m_swapMemoryBlockHandler.
Referenced by te::rp::Matrix< TemplateElementType >::reset(), and te::rp::Matrix< TemplateElementType >::~Matrix().
|
protected |
Create a new disk file.
size | The file size. |
fileptr | The file pointer. |
fullFileName | The created full file name. |
Definition at line 891 of file Matrix.h.
References TERP_LOGERR, and TERP_TRUE_OR_RETURN_FALSE.
Referenced by te::rp::Matrix< TemplateElementType >::allocateDiskLines().
unsigned int te::rp::Matrix< TemplateElementType >::getColumnsNumber | ( | ) | const |
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().
unsigned int te::rp::Matrix< TemplateElementType >::getLinesNumber | ( | ) | const |
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().
unsigned char te::rp::Matrix< TemplateElementType >::getMaxMemPercentUsage | ( | ) | const |
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.
unsigned long int te::rp::Matrix< TemplateElementType >::getMaxTmpFileSize | ( | ) | const |
Returns the current maximum temporary disk file size.
Definition at line 723 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize.
Matrix< TemplateElementType >::MemoryPolicy te::rp::Matrix< TemplateElementType >::getMemPolicy | ( | ) | const |
Returns the current memory policy.
Definition at line 717 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 811 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_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< rg::BaatzFeatureType >::operator()(), te::rp::Matrix< TemplateElementType >::operator=(), and te::rp::Matrix< rg::BaatzFeatureType >::operator[]().
|
protected |
Reset the internal variables to the initial state.
Definition at line 447 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_currentSwapTilePtr, te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage, 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 >::clear(), and te::rp::Matrix< TemplateElementType >::Matrix().
bool te::rp::Matrix< TemplateElementType >::isEmpty | ( | ) | const |
Empty Matrix verification.
Definition at line 685 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_totalLines.
|
inline |
|
inline |
const Matrix< TemplateElementType > & te::rp::Matrix< TemplateElementType >::operator= | ( | const Matrix< TemplateElementType > & | external | ) |
Operator = overload.
external | External instance reference. |
Definition at line 691 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage, 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. |
|
inline |
Operator [] overload.
line | Line number. |
column | Column number. |
void te::rp::Matrix< TemplateElementType >::reset | ( | ) |
Reset (clear) the active instance data.
memoryPolicy | Memory 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().
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 486 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, and te::rp::Matrix< TemplateElementType >::reset().
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 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().
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 500 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage, 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 508 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 517 of file Matrix.h.
References te::rp::Matrix< TemplateElementType >::allocateDiskLines(), te::rp::Matrix< TemplateElementType >::AutoMemPol, te::rp::Matrix< TemplateElementType >::clear(), te::common::GetTotalPhysicalMemory(), te::common::GetTotalVirtualMemory(), te::common::GetUsedVirtualMemory(), te::rp::Matrix< TemplateElementType >::m_allLinesPtrsVec, te::rp::Matrix< TemplateElementType >::m_currentSwapTilePtr, te::rp::Matrix< TemplateElementType >::m_maxMemPercentUsage, te::rp::Matrix< TemplateElementType >::m_maxTmpFileSize, te::rp::Matrix< TemplateElementType >::m_memoryblocksHandler, te::rp::Matrix< TemplateElementType >::m_memoryPolicy, te::rp::Matrix< TemplateElementType >::m_ramLinesIndexesVec, te::rp::Matrix< TemplateElementType >::m_swapMemoryBlockHandler, te::rp::Matrix< TemplateElementType >::m_totalColumns, te::rp::Matrix< TemplateElementType >::m_totalLines, MAX, MIN, te::rp::Matrix< TemplateElementType >::RAMMemPol, and TERP_LOG_AND_RETURN_FALSE.
|
mutableprotected |
A vector with pointers to all lines.
Definition at line 358 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 351 of file Matrix.h.
Referenced by 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 368 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::allocateDiskLines(), te::rp::Matrix< TemplateElementType >::clear(), and te::rp::Matrix< TemplateElementType >::getScanLine().
|
protected |
the max amount of free memory to use when necessary.
Definition at line 324 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::getMaxMemPercentUsage(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::operator=(), and te::rp::Matrix< TemplateElementType >::reset().
|
protected |
Max bytes per temp file (for swapped tiles only, default: 2GB).
Definition at line 319 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::allocateDiskLines(), te::rp::Matrix< TemplateElementType >::getMaxTmpFileSize(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::operator=(), and te::rp::Matrix< TemplateElementType >::reset().
|
protected |
Definition at line 353 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 339 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::getMemPolicy(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< TemplateElementType >::operator=(), 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 346 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::getScanLine(), and te::rp::Matrix< TemplateElementType >::init().
|
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().
|
mutableprotected |
The indexes of all lines loaded into RAM.
Definition at line 373 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 379 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 334 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::allocateDiskLines(), te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::Matrix< TemplateElementType >::init(), te::rp::Matrix< rg::BaatzFeatureType >::operator()(), te::rp::Matrix< TemplateElementType >::operator=(), and te::rp::Matrix< TemplateElementType >::reset().
|
protected |
The total lines number (default:0).
Definition at line 329 of file Matrix.h.
Referenced by te::rp::Matrix< TemplateElementType >::allocateDiskLines(), 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().