Loading...
Searching...
No Matches
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.
 
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< DiskLineInfom_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< OpenDiskFileHandlerm_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).
 

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

Referenced by Matrix(), and operator=().

◆ Matrix() [2/2]

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

Definition at line 477 of file Matrix.h.

References init(), Matrix(), and operator=().

◆ ~Matrix()

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

Definition at line 486 of file Matrix.h.

References clear().

Member Function Documentation

◆ clear()

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

◆ getColumnsNumber()

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

References 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 ( ) const

The number of current matrix lines.

Returns
The number of current matrix lines.

Definition at line 782 of file Matrix.h.

References 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 ( ) const

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 m_maxRAMLines.

◆ getMaxTmpFileSize()

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

References m_maxTmpFileSize.

◆ getMemPolicy()

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

References m_memoryPolicy.

◆ getScanLine()

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

Returns a pointer to the required line.

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

References m_allLinesPtrsVec, m_currentSwapTilePtr, m_diskLinesInfoVec, te::rp::Matrix< TemplateElementType >::DiskLineInfo::m_fileOff, te::rp::Matrix< TemplateElementType >::DiskLineInfo::m_filePtr, m_nextSwapLineRamLinesIndexesVecIdx, m_ramLinesIndexesVec, m_totalColumns, m_totalLines, TERP_DEBUG_TRUE_OR_THROW, and TERP_TRUE_OR_THROW.

Referenced by te::rp::Matrix< SegmenterSegmentsBlock >::operator()(), te::rp::Matrix< SegmenterSegmentsBlock >::operator()(), operator=(), te::rp::Matrix< SegmenterSegmentsBlock >::operator[](), and te::rp::Matrix< SegmenterSegmentsBlock >::operator[]().

◆ init()

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

Reset the internal variables to the default state.

Definition at line 459 of file Matrix.h.

References m_currentSwapTilePtr, m_maxRAMLines, m_maxTmpFileSize, m_memoryPolicy, m_nextSwapLineRamLinesIndexesVecIdx, m_totalColumns, m_totalLines, and RAMMemPol.

Referenced by Matrix(), and Matrix().

◆ isEmpty()

template<typename TemplateElementType>
bool te::rp::Matrix< TemplateElementType >::isEmpty ( ) const

Empty Matrix verification.

Returns
true if the matrix is empty.

Definition at line 796 of file Matrix.h.

References 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 = overload.

Note
The external memory policy will be used as reference.
Parameters
externalExternal instance reference.
Returns
A reference to the current matrix.

Definition at line 802 of file Matrix.h.

References getScanLine(), m_maxRAMLines, m_maxTmpFileSize, m_memoryPolicy, m_totalColumns, m_totalLines, Matrix(), reset(), and TERP_TRUE_OR_THROW.

Referenced by Matrix().

◆ 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 clear().

Referenced by te::rp::Skeleton::applyMeanSmooth(), te::rp::Skeleton::getMagnitude(), operator=(), reset(), reset(), reset(), reset(), and 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 clear(), and 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 m_maxTmpFileSize, and reset().

◆ reset() [4/8]

template<typename TemplateElementType>
bool te::rp::Matrix< TemplateElementType >::reset ( MemoryPolicy memoryPolicy,
unsigned int lines,
unsigned int columns,
unsigned long int maxTmpFileSize,
unsigned int maxRAMLines )
Parameters
linesNumber of lines.
columnsNumber of columns.
memoryPolicyMemory policy.
maxTmpFileSizeMax temp file size.
maxRAMLinesThe max amount of RAM memory lines to allocate (when using AutoMemPol).
Returns
true if OK, false on error.

Definition at line 572 of file Matrix.h.

References te::core::FileSystem::allocateTmpDiskFile(), clear(), DiskMemPol, m_allLinesPtrsVec, m_currentSwapTilePtr, m_diskLinesInfoVec, m_maxRAMLines, m_maxTmpFileSize, m_memoryblocksHandler, m_memoryPolicy, m_openDiskFilesHandler, m_ramLinesIndexesVec, m_swapMemoryBlockHandler, m_totalColumns, m_totalLines, RAMMemPol, and TERP_LOG_AND_RETURN_FALSE.

◆ 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 m_maxRAMLines, m_maxTmpFileSize, m_memoryPolicy, and 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 m_maxRAMLines, m_maxTmpFileSize, and 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 m_maxTmpFileSize, and 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 AutoMemPol, te::common::GetTotalPhysicalMemory(), te::common::GetTotalVirtualMemory(), te::common::GetUsedVirtualMemory(), m_memoryPolicy, and reset().

Member Data Documentation

◆ m_allLinesPtrsVec

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

A vector with pointers to all lines.

Definition at line 382 of file Matrix.h.

Referenced by clear(), getScanLine(), and reset().

◆ m_currentSwapTilePtr

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

A pointer to the current swap tile.

Definition at line 375 of file Matrix.h.

Referenced by clear(), getScanLine(), init(), and reset().

◆ m_diskLinesInfoVec

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

Info of all lines, used when a line is on disk.

Definition at line 392 of file Matrix.h.

Referenced by clear(), getScanLine(), and reset().

◆ m_maxRAMLines

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

the max amount of RAM lines.

Definition at line 348 of file Matrix.h.

Referenced by getMaxRAMLines(), init(), operator=(), reset(), reset(), and reset().

◆ m_maxTmpFileSize

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

Max bytes per temp file (for swapped tiles only, default: 2GB).

Definition at line 343 of file Matrix.h.

Referenced by getMaxTmpFileSize(), init(), operator=(), reset(), reset(), reset(), reset(), and reset().

◆ m_memoryblocksHandler

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

Definition at line 377 of file Matrix.h.

Referenced by clear(), and reset().

◆ m_memoryPolicy

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

The used memory policy (default:RAMMemPol).

Definition at line 363 of file Matrix.h.

Referenced by getMemPolicy(), init(), operator=(), reset(), reset(), reset(), and reset().

◆ 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 clear(), getScanLine(), and 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 clear(), and reset().

◆ m_ramLinesIndexesVec

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

The indexes of all lines loaded into RAM.

Definition at line 397 of file Matrix.h.

Referenced by clear(), getScanLine(), and reset().

◆ 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 clear(), and reset().

◆ m_totalColumns

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

The total columns number (default:0).

Definition at line 358 of file Matrix.h.

Referenced by clear(), getColumnsNumber(), getScanLine(), init(), operator=(), and reset().

◆ m_totalLines

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

The total lines number (default:0).

Definition at line 353 of file Matrix.h.

Referenced by clear(), getLinesNumber(), getScanLine(), init(), isEmpty(), operator=(), and reset().


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