TerraLib 4.1
TePDIMatrix< ElementType > Class Template Reference

A generic matrix template class. More...

#include <TePDIMatrix.hpp>

List of all members.

Classes

class  DiskLinesInfoNode
 Disk lines info node. More...
class  OpenDiskFilesInfoNode
 Openend disk files info node. More...

Public Types

enum  MemoryPolicy { AutoMemPol, RAMMemPol, DiskMemPol }
 Memory polycy. More...
typedef TeSharedPtr
< TePDIMatrix< ElementType > > 
pointer

Public Member Functions

 TePDIMatrix ()
 TePDIMatrix (const TePDIMatrix< ElementType > &external)
virtual ~TePDIMatrix ()
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 (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 long int maxTmpFileSize, unsigned char maxMemPercentUsage)
 Reset (clear) the active instance data and update its internal parameters folowing the the new supplied parameters.
void clear ()
 Clear all allocated resources and go back to the initial default parameters.
unsigned int GetLines () const
 The number of current matrix lines.
unsigned int GetColumns () const
 The number of current matrix columns.
bool IsEmpty () const
 Empty Matrix verification.
const TePDIMatrix< ElementType > & operator= (const TePDIMatrix< ElementType > &external)
 Operator = overload.
ElementType & operator() (const unsigned int &line, const unsigned int &column)
 Operator () overload.
const ElementType & operator() (const unsigned int &line, const unsigned int &column) const
 Operator () overload.
ElementType * operator[] (const unsigned int &line)
 Operator [] overload.
ElementType const * operator[] (const unsigned int &line) const
 Operator [] overload.
MemoryPolicy getMemPolicy () const
 Returns the current memory policy.
unsigned long int getMaxTmpFileSize () const
 Returns the current maximum temporary disk file size.

Protected Member Functions

void init ()
 Reset the internal variables to the initial state.
bool allocateDiskLines (unsigned int startingLineIdx)
 Allocate disk lines.
ElementType * getScanLine (const unsigned int &line) const
 Returns a pointer to the required line.
bool createNewDiskFile (unsigned long int size, const std::string &filename, FILE **fileptr) const
 Create a new disk file.

Protected Attributes

unsigned long int maxTmpFileSize_
 Max bytes per temp file (for swapped tiles only, default: 2GB).
unsigned char maxMemPercentUsage_
 the max amount of free memory to use when necessary (default:50).
unsigned int totalLines_
 The total lines number (default:0).
unsigned int totalColumns_
 The total columns number (default:0).
MemoryPolicy memoryPolicy_
 The used memory policy (default:RAMMemPol).
unsigned int lineSize_
 The line size (bytes, default:0).
ElementType ** allLinesPtrsVec_
 A vector with pointers to all lines (size 0 or totalLines_).
OpenDiskFilesInfoNodeopenDiskFilesVec_
 A vector with open disk files info (size 0 or openDiskFilesVecSize_).
unsigned int openDiskFilesVecSize_
 A vector with open disk files info.
DiskLinesInfoNodediskLinesVec_
 Disk lines vector (size 0 or totalLines_).
unsigned int * ramLinesIndexesVec_
 The indexes inside allTilesPtrsVec_ of all RAM lines (size 0 or ramLinesIndexesVecSize_).
unsigned int ramLinesIndexesVecSize_
 The size of ramLinesIndexesVec_;.
unsigned int nextSwapLineRamLinesIndexesVecIdx_
 The index inside ramLinesIndexesVec_ of the next RAM line index that will be swapped to disk when a disk line is required.
ElementType * swapLinePtr_
 A pointer to the auxiliar line used when swapping data to/from disk.

Detailed Description

template<class ElementType>
class TePDIMatrix< ElementType >

A generic matrix template class.

Author:
Emiliano F. Castejon <castejon@dpi.inpe.br>
Examples:

TePDIMatrix_test.cpp.


Member Typedef Documentation

template<class ElementType>
TeSharedPtr< TePDIMatrix< ElementType > > TePDIMatrix< ElementType >::pointer

Type definition for a instance pointer


Member Enumeration Documentation

template<class ElementType>
enum TePDIMatrix::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 !

Reimplemented in TePDIMtxDoubleAdpt< T >.


Constructor & Destructor Documentation

template<class ElementType >
TePDIMatrix< ElementType >::TePDIMatrix ( )
template<class ElementType>
TePDIMatrix< ElementType >::TePDIMatrix ( const TePDIMatrix< ElementType > &  external)
template<class ElementType >
TePDIMatrix< ElementType >::~TePDIMatrix ( ) [virtual]

Member Function Documentation

template<class ElementType >
bool TePDIMatrix< ElementType >::allocateDiskLines ( unsigned int  startingLineIdx) [protected]

Allocate disk lines.

Parameters:
startingLineIdxStarting line index.
Returns:
true if OK, false on errors.
template<class ElementType >
void TePDIMatrix< ElementType >::clear ( )

Clear all allocated resources and go back to the initial default parameters.

template<class ElementType >
bool TePDIMatrix< ElementType >::createNewDiskFile ( unsigned long int  size,
const std::string filename,
FILE **  fileptr 
) const [protected]

Create a new disk file.

Parameters:
filenameThe file name.
sizeThe file size.
fileptrThe file pointer.
Returns:
true if OK. false on errors.
template<class ElementType >
unsigned int TePDIMatrix< ElementType >::GetColumns ( ) const

The number of current matrix columns.

Returns:
The number of current matrix columns
template<class ElementType >
unsigned int TePDIMatrix< ElementType >::GetLines ( ) const

The number of current matrix lines.

Returns:
The number of current matrix lines.
template<class ElementType >
unsigned long int TePDIMatrix< ElementType >::getMaxTmpFileSize ( ) const

Returns the current maximum temporary disk file size.

Returns:
Returns the current maximum temporary disk file size.
template<class ElementType >
TePDIMatrix< ElementType >::MemoryPolicy TePDIMatrix< ElementType >::getMemPolicy ( ) const

Returns the current memory policy.

Returns:
The current memory policy.
template<class ElementType >
ElementType * TePDIMatrix< ElementType >::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.
template<class ElementType >
void TePDIMatrix< ElementType >::init ( ) [protected]

Reset the internal variables to the initial state.

template<class ElementType >
bool TePDIMatrix< ElementType >::IsEmpty ( ) const

Empty Matrix verification.

Returns:
true if the matrix is empty.
template<class ElementType>
ElementType& TePDIMatrix< ElementType >::operator() ( const unsigned int &  line,
const unsigned int &  column 
) [inline]

Operator () overload.

Parameters:
lineLine number.
columnColumn number.
Returns:
A reference to the required element.
template<class ElementType>
const ElementType& TePDIMatrix< ElementType >::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.
template<class ElementType>
const TePDIMatrix< ElementType > & TePDIMatrix< ElementType >::operator= ( const TePDIMatrix< ElementType > &  external)

Operator = overload.

Note:
The external memory policy will be used as reference.
Parameters:
externalExternal instance reference.
Returns:
A reference to the current matrix.
template<class ElementType>
ElementType* TePDIMatrix< ElementType >::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.
template<class ElementType>
ElementType const* TePDIMatrix< ElementType >::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.
template<class ElementType >
bool TePDIMatrix< ElementType >::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.
template<class ElementType >
void TePDIMatrix< ElementType >::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.
template<class ElementType >
void TePDIMatrix< ElementType >::Reset ( )

Reset (clear) the active instance data.

Note:
Other parameters will not be changed.
Parameters:
memoryPolicyMemory policy.
template<class ElementType >
bool TePDIMatrix< ElementType >::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.
template<class ElementType >
bool TePDIMatrix< ElementType >::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.

Member Data Documentation

template<class ElementType>
ElementType** TePDIMatrix< ElementType >::allLinesPtrsVec_ [protected]

A vector with pointers to all lines (size 0 or totalLines_).

template<class ElementType>
DiskLinesInfoNode* TePDIMatrix< ElementType >::diskLinesVec_ [protected]

Disk lines vector (size 0 or totalLines_).

template<class ElementType>
unsigned int TePDIMatrix< ElementType >::lineSize_ [protected]

The line size (bytes, default:0).

template<class ElementType>
unsigned char TePDIMatrix< ElementType >::maxMemPercentUsage_ [protected]

the max amount of free memory to use when necessary (default:50).

template<class ElementType>
unsigned long int TePDIMatrix< ElementType >::maxTmpFileSize_ [protected]

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

template<class ElementType>
MemoryPolicy TePDIMatrix< ElementType >::memoryPolicy_ [protected]

The used memory policy (default:RAMMemPol).

template<class ElementType>
unsigned int TePDIMatrix< ElementType >::nextSwapLineRamLinesIndexesVecIdx_ [mutable, protected]

The index inside ramLinesIndexesVec_ of the next RAM line index that will be swapped to disk when a disk line is required.

template<class ElementType>
OpenDiskFilesInfoNode* TePDIMatrix< ElementType >::openDiskFilesVec_ [protected]

A vector with open disk files info (size 0 or openDiskFilesVecSize_).

template<class ElementType>
unsigned int TePDIMatrix< ElementType >::openDiskFilesVecSize_ [protected]

A vector with open disk files info.

template<class ElementType>
unsigned int* TePDIMatrix< ElementType >::ramLinesIndexesVec_ [protected]

The indexes inside allTilesPtrsVec_ of all RAM lines (size 0 or ramLinesIndexesVecSize_).

template<class ElementType>
unsigned int TePDIMatrix< ElementType >::ramLinesIndexesVecSize_ [protected]

The size of ramLinesIndexesVec_;.

template<class ElementType>
ElementType* TePDIMatrix< ElementType >::swapLinePtr_ [mutable, protected]

A pointer to the auxiliar line used when swapping data to/from disk.

template<class ElementType>
unsigned int TePDIMatrix< ElementType >::totalColumns_ [protected]

The total columns number (default:0).

template<class ElementType>
unsigned int TePDIMatrix< ElementType >::totalLines_ [protected]

The total lines number (default:0).


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines