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 (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...
 
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)
 
virtual ~Matrix ()
 

Protected Member Functions

void clear ()
 Clear all allocated resources but keep the current parameters. 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 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 481 of file Matrix.h.

◆ Matrix() [2/2]

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

Definition at line 487 of file Matrix.h.

◆ ~Matrix()

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

Definition at line 496 of file Matrix.h.

Member Function Documentation

◆ clear()

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

Clear all allocated resources but keep the current parameters.

Definition at line 756 of file Matrix.h.

Referenced by te::rp::Matrix< rg::BaatzFeatureType >::reset(), and te::rp::Matrix< rg::BaatzFeatureType >::~Matrix().

◆ createNewDiskFile()

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

Referenced by te::rp::Matrix< rg::BaatzFeatureType >::reset().

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

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

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

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

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

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

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

◆ init()

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

Reset the internal variables to the default state.

Definition at line 469 of file Matrix.h.

Referenced by te::rp::Matrix< rg::BaatzFeatureType >::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 805 of file Matrix.h.

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

Referenced by te::rp::Matrix< rg::BaatzFeatureType >::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 502 of file Matrix.h.

Referenced by te::rp::Skeleton::applyMeanSmooth(), te::rp::Skeleton::getMagnitude(), te::rp::Matrix< rg::BaatzFeatureType >::operator=(), and te::rp::Matrix< rg::BaatzFeatureType >::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 508 of file Matrix.h.

◆ reset() [3/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 515 of file Matrix.h.

◆ reset() [4/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 522 of file Matrix.h.

◆ reset() [5/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 529 of file Matrix.h.

◆ reset() [6/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 538 of file Matrix.h.

◆ reset() [7/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 574 of file Matrix.h.

◆ reset() [8/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 582 of file Matrix.h.

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< rg::BaatzFeatureType >::clear(), te::rp::Matrix< rg::BaatzFeatureType >::getScanLine(), and te::rp::Matrix< rg::BaatzFeatureType >::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< rg::BaatzFeatureType >::clear(), and te::rp::Matrix< rg::BaatzFeatureType >::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< rg::BaatzFeatureType >::clear(), and te::rp::Matrix< rg::BaatzFeatureType >::reset().

◆ m_totalColumns

◆ m_totalLines


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