te::mem::ExpansibleBandBlocksManager Class Reference

RAM cached and tiled raster band blocks manager. More...

#include <ExpansibleBandBlocksManager.h>

Inheritance diagram for te::mem::ExpansibleBandBlocksManager:

Classes

class  BlockIndex3D
 3D Block index. More...
 
class  DiskBlockInfo
 Disk block info. More...
 
class  OpenDiskFileHandler
 Open disk file handler. More...
 

Public Member Functions

bool addBottomBands (const unsigned int &expansionSize, std::vector< BlockIndex3D > &addedBlocksCoords)
 New bands will be added at the bottom of the raster (after de the last band). More...
 
bool addBottomBlocks (const unsigned int &expansionSize, const unsigned int &band, std::vector< BlockIndex3D > &addedBlocksCoords)
 New blocks will be added at the bottom of the raster. More...
 
bool addLeftBlocks (const unsigned int &expansionSize, const unsigned int &band, std::vector< BlockIndex3D > &addedBlocksCoords)
 New blocks will be added at the left of the raster. More...
 
bool addRightBlocks (const unsigned int &expansionSize, const unsigned int &band, std::vector< BlockIndex3D > &addedBlocksCoords)
 New blocks will be added at the right of the raster. More...
 
bool addTopBands (const unsigned int &expansionSize, std::vector< BlockIndex3D > &addedBlocksCoords)
 New bands will be added at the top of the raster (before the first band). More...
 
bool addTopBlocks (const unsigned int &expansionSize, const unsigned int &band, std::vector< BlockIndex3D > &addedBlocksCoords)
 New blocks will be added at the top of the raster. More...
 
 ExpansibleBandBlocksManager ()
 
void free ()
 Free all allocated internal resources and go back to the initial state. More...
 
void * getBlockPointer (unsigned int band, unsigned int x, unsigned int y)
 Returns a pointer to the required data block. More...
 
unsigned long int getBlockSizeBytes ()
 Returns the internal size( bytes ) used for all internal blocks. More...
 
unsigned int getMaxNumberOfRAMBlocks () const
 The maximum number of cache blocks. More...
 
unsigned int getNumberOfBands () const
 Returns the number of bands. More...
 
unsigned int getNumberOfBlocksX (const unsigned int band) const
 Returns the number of blocks along the X directon for the required band. More...
 
unsigned int getNumberOfBlocksY (const unsigned int band) const
 Returns the number of blocks along the Y directon for the required band. More...
 
bool initialize (const unsigned int maxNumberRAMBlocks, const std::vector< unsigned int > &numbersOfBlocksX, const std::vector< unsigned int > &numbersOfBlocksY, const std::vector< unsigned int > &blocksSizesBytes, const unsigned long int maxDiskFilesSize)
 Initialize this instance to an initial state. More...
 
bool isInitialized () const
 Returns true if this instance is initialized. More...
 
 ~ExpansibleBandBlocksManager ()
 

Protected Types

typedef std::vector< std::vector< std::vector< DiskBlockInfo > > > ActiveDiskBlocksInfoT
 Active disk blocks info type;. More...
 
typedef BlockElementTBlockelementPtrT
 Block element pointer type. More...
 
typedef unsigned char BlockElementT
 Block element type. More...
 
typedef std::list< DiskBlockInfoInactiveDiskBlocksInfoT
 Inactive disk blocks info type. More...
 
typedef boost::shared_ptr< OpenDiskFileHandlerOpenDiskFileHandlerPtrT
 Open disk file pointer type. More...
 
typedef std::list< OpenDiskFileHandlerPtrTOpenDiskFilesHandlerT
 Open dis files handler type. More...
 
typedef boost::shared_array< BlockElementTRAMBlockHandlerT
 RAM Block handler type;. More...
 
typedef std::list< RAMBlockHandlerTRAMBlocksHandlerT
 Blocks handler type;. More...
 
typedef std::vector< std::vector< std::vector< BlockelementPtrT > > > RAMBlocksPointersContainerT
 RAM blocks pointers container type. More...
 
typedef std::vector< BlockIndex3DSwapFifoT
 Swap fifo type. More...
 

Protected Member Functions

bool allocateAndActivateDiskBlocks (const std::vector< BlockIndex3D > &blocksIndxes)
 Allocate and activate disk blocks. More...
 
bool allocateDiskBlocks (const unsigned int blocksNumber, std::vector< DiskBlockInfo > &diskBlocksInfos, OpenDiskFilesHandlerT &diskFilesHandler) const
 Allocate disk blocks. More...
 
bool createNewDiskFile (unsigned long int size, FILE **fileptr, std::string &fullFileName) const
 Create a new disk file. More...
 
void initState ()
 Initialize this instance to an initial state. More...
 
template<typename ContainerType >
void shift3DCoords (ContainerType &inputContainer, const int &dim0Shift, const int &dim1Shift, const int &dim2Shift) const
 Shift 3D coords. More...
 
template<typename ContainerType >
void shiftDim03DCoords (ContainerType &inputContainer, const unsigned int dim0index, const int dim1Shift, const int dim2Shift) const
 Shift coords given a fixed dimention 0 index. More...
 

Protected Attributes

ActiveDiskBlocksInfoT m_activeDiskBlocksInfo
 3D Matrix of active disk block info indexed as [band][blockYIndex][blockXIndex]. More...
 
RAMBlocksHandlerT m_activeRAMBlocksHandler
 The active RAM blocks handler. More...
 
unsigned char * m_currSwapBlockPtr
 A pointer to the current block where disk data swap will be done. More...
 
OpenDiskFilesHandlerT m_diskFilesHandler
 The disk files handler;. More...
 
bool m_isInitialized
 Is this instance initialized ? More...
 
unsigned long int m_maxBlockSizeBytes
 The maximum global used block size in bytes. More...
 
unsigned long int m_maxDiskFilesSize
 The maximum temporary disk file size (bytes). More...
 
unsigned int m_maxNumberRAMBlocks
 The maximum number of RAM blocks;. More...
 
SwapFifoT::size_type m_nextFIFOPositionOverSwapFifo
 The next position where a block swap will occur over m_swapFifo;. More...
 
RAMBlocksPointersContainerT m_ramBlocksPointers
 3D Matrix of active RAM blocks pointers indexed in the form [band][blockYIndex][blockXIndex]. More...
 
RAMBlockHandlerT m_swapBlockHandler
 An extra block for disk swap purposes. More...
 
SwapFifoT m_swapFifo
 Disk swapping FIFO. More...
 

Private Attributes

unsigned char * m_getBlockPointer_returnValue
 

Detailed Description

RAM cached and tiled raster band blocks manager.

Definition at line 53 of file ExpansibleBandBlocksManager.h.

Member Typedef Documentation

typedef std::vector< std::vector< std::vector< DiskBlockInfo > > > te::mem::ExpansibleBandBlocksManager::ActiveDiskBlocksInfoT
protected

Active disk blocks info type;.

Definition at line 431 of file ExpansibleBandBlocksManager.h.

Block element pointer type.

Definition at line 423 of file ExpansibleBandBlocksManager.h.

typedef unsigned char te::mem::ExpansibleBandBlocksManager::BlockElementT
protected

Block element type.

Definition at line 421 of file ExpansibleBandBlocksManager.h.

Inactive disk blocks info type.

Definition at line 433 of file ExpansibleBandBlocksManager.h.

Open disk file pointer type.

Definition at line 296 of file ExpansibleBandBlocksManager.h.

Open dis files handler type.

Definition at line 298 of file ExpansibleBandBlocksManager.h.

RAM Block handler type;.

Definition at line 425 of file ExpansibleBandBlocksManager.h.

Blocks handler type;.

Definition at line 429 of file ExpansibleBandBlocksManager.h.

typedef std::vector< std::vector< std::vector< BlockelementPtrT > > > te::mem::ExpansibleBandBlocksManager::RAMBlocksPointersContainerT
protected

RAM blocks pointers container type.

Definition at line 427 of file ExpansibleBandBlocksManager.h.

Swap fifo type.

Definition at line 435 of file ExpansibleBandBlocksManager.h.

Constructor & Destructor Documentation

te::mem::ExpansibleBandBlocksManager::ExpansibleBandBlocksManager ( )
te::mem::ExpansibleBandBlocksManager::~ExpansibleBandBlocksManager ( )

Member Function Documentation

bool te::mem::ExpansibleBandBlocksManager::addBottomBands ( const unsigned int &  expansionSize,
std::vector< BlockIndex3D > &  addedBlocksCoords 
)

New bands will be added at the bottom of the raster (after de the last band).

Parameters
expansionSizeThe number of bands to add.
addedBlocksCoordsThe added blocks coords.
Returns
true if OK, false on errors.
bool te::mem::ExpansibleBandBlocksManager::addBottomBlocks ( const unsigned int &  expansionSize,
const unsigned int &  band,
std::vector< BlockIndex3D > &  addedBlocksCoords 
)

New blocks will be added at the bottom of the raster.

Parameters
expansionSizeThe expansion size over the Y direction.
bandThe band where the operation will be performed.
addedBlocksCoordsThe added blocks coords.
Returns
true if OK, false on errors.
bool te::mem::ExpansibleBandBlocksManager::addLeftBlocks ( const unsigned int &  expansionSize,
const unsigned int &  band,
std::vector< BlockIndex3D > &  addedBlocksCoords 
)

New blocks will be added at the left of the raster.

Parameters
expansionSizeThe expansion size over the X direction.
bandThe band where the operation will be performed.
addedBlocksCoordsThe added blocks coords.
Returns
true if OK, false on errors.
bool te::mem::ExpansibleBandBlocksManager::addRightBlocks ( const unsigned int &  expansionSize,
const unsigned int &  band,
std::vector< BlockIndex3D > &  addedBlocksCoords 
)

New blocks will be added at the right of the raster.

Parameters
expansionSizeThe expansion size over the X direction.
bandThe band where the operation will be performed.
addedBlocksCoordsThe added blocks coords.
Returns
true if OK, false on errors.
bool te::mem::ExpansibleBandBlocksManager::addTopBands ( const unsigned int &  expansionSize,
std::vector< BlockIndex3D > &  addedBlocksCoords 
)

New bands will be added at the top of the raster (before the first band).

Parameters
expansionSizeThe number of bands to add.
addedBlocksCoordsThe added blocks coords.
Returns
true if OK, false on errors.
bool te::mem::ExpansibleBandBlocksManager::addTopBlocks ( const unsigned int &  expansionSize,
const unsigned int &  band,
std::vector< BlockIndex3D > &  addedBlocksCoords 
)

New blocks will be added at the top of the raster.

Parameters
expansionSizeThe expansion size over the Y direction.
bandThe band where the operation will be performed.
addedBlocksCoordsThe added blocks coords.
Returns
true if OK, false on errors.
bool te::mem::ExpansibleBandBlocksManager::allocateAndActivateDiskBlocks ( const std::vector< BlockIndex3D > &  blocksIndxes)
protected

Allocate and activate disk blocks.

Parameters
blocksIndxesThe blocks indexes inside the internal 3D indexing matrices.
Returns
true if OK. false on errors.
bool te::mem::ExpansibleBandBlocksManager::allocateDiskBlocks ( const unsigned int  blocksNumber,
std::vector< DiskBlockInfo > &  diskBlocksInfos,
OpenDiskFilesHandlerT diskFilesHandler 
) const
protected

Allocate disk blocks.

Parameters
blocksNumberThe number of blocks to allocate.
diskBlocksInfosThe info for the allocated blocks.
diskFilesHandlerThe file handlers for all the allocated blocks.
Returns
true if OK. false on errors.
bool te::mem::ExpansibleBandBlocksManager::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 full created file name.
Returns
true if OK. false on errors.
void te::mem::ExpansibleBandBlocksManager::free ( )

Free all allocated internal resources and go back to the initial state.

void* te::mem::ExpansibleBandBlocksManager::getBlockPointer ( unsigned int  band,
unsigned int  x,
unsigned int  y 
)

Returns a pointer to the required data block.

Parameters
bandThe band index.
xThe block-id in x (or x-offset).
yThe block-id in y (or y-offset).
Returns
Pointer to the required data block.
unsigned long int te::mem::ExpansibleBandBlocksManager::getBlockSizeBytes ( )
inline

Returns the internal size( bytes ) used for all internal blocks.

Returns
Returns the internal size( bytes ) used for all internal blocks

Definition at line 159 of file ExpansibleBandBlocksManager.h.

unsigned int te::mem::ExpansibleBandBlocksManager::getMaxNumberOfRAMBlocks ( ) const
inline

The maximum number of cache blocks.

Definition at line 179 of file ExpansibleBandBlocksManager.h.

unsigned int te::mem::ExpansibleBandBlocksManager::getNumberOfBands ( ) const
inline

Returns the number of bands.

Returns
Returns the number of bands.

Definition at line 149 of file ExpansibleBandBlocksManager.h.

unsigned int te::mem::ExpansibleBandBlocksManager::getNumberOfBlocksX ( const unsigned int  band) const
inline

Returns the number of blocks along the X directon for the required band.

Parameters
bandThe required band.
Returns
Returns the number of blocks along the X directon for the required band.

Definition at line 123 of file ExpansibleBandBlocksManager.h.

unsigned int te::mem::ExpansibleBandBlocksManager::getNumberOfBlocksY ( const unsigned int  band) const
inline

Returns the number of blocks along the Y directon for the required band.

Parameters
bandThe required band.
Returns
Returns the number of blocks along the Y directon for the required band.

Definition at line 137 of file ExpansibleBandBlocksManager.h.

bool te::mem::ExpansibleBandBlocksManager::initialize ( const unsigned int  maxNumberRAMBlocks,
const std::vector< unsigned int > &  numbersOfBlocksX,
const std::vector< unsigned int > &  numbersOfBlocksY,
const std::vector< unsigned int > &  blocksSizesBytes,
const unsigned long int  maxDiskFilesSize 
)

Initialize this instance to an initial state.

Parameters
maxNumberRAMBlocksThe maximum number of RAM blocks.
numbersOfBlocksXThe number of blocks along the X directon (for each band).
numbersOfBlocksYThe number of blocks along the Y directon (for each band).
blocksSizesBytesThe blocks sizes in bytes (for each band).
maxDiskFilesSizeThe maximum temporary disk file size (if required).
Returns
true if OK, false on errors.
void te::mem::ExpansibleBandBlocksManager::initState ( )
protected

Initialize this instance to an initial state.

bool te::mem::ExpansibleBandBlocksManager::isInitialized ( ) const
inline

Returns true if this instance is initialized.

Returns
true if this instance is initialized.

Definition at line 111 of file ExpansibleBandBlocksManager.h.

template<typename ContainerType >
void te::mem::ExpansibleBandBlocksManager::shift3DCoords ( ContainerType &  inputContainer,
const int &  dim0Shift,
const int &  dim1Shift,
const int &  dim2Shift 
) const
inlineprotected

Shift 3D coords.

Parameters
inputContainerThe input coords container.
dim0ShiftThe shift to be done over the dimension 0.
dim1ShiftThe shift to be done over the dimension 1.
dim2ShiftThe shift to be done over the dimension 2.

Definition at line 393 of file ExpansibleBandBlocksManager.h.

template<typename ContainerType >
void te::mem::ExpansibleBandBlocksManager::shiftDim03DCoords ( ContainerType &  inputContainer,
const unsigned int  dim0index,
const int  dim1Shift,
const int  dim2Shift 
) const
inlineprotected

Shift coords given a fixed dimention 0 index.

Parameters
inputContainerThe input coords container.
dim0indexThe dimension 0 fixed index.
dim1ShiftThe shift to be done over the dimension 1.
dim2ShiftThe shift to be done over the dimension 2.

Definition at line 356 of file ExpansibleBandBlocksManager.h.

Member Data Documentation

ActiveDiskBlocksInfoT te::mem::ExpansibleBandBlocksManager::m_activeDiskBlocksInfo
protected

3D Matrix of active disk block info indexed as [band][blockYIndex][blockXIndex].

Definition at line 455 of file ExpansibleBandBlocksManager.h.

RAMBlocksHandlerT te::mem::ExpansibleBandBlocksManager::m_activeRAMBlocksHandler
protected

The active RAM blocks handler.

Definition at line 449 of file ExpansibleBandBlocksManager.h.

unsigned char* te::mem::ExpansibleBandBlocksManager::m_currSwapBlockPtr
protected

A pointer to the current block where disk data swap will be done.

Definition at line 445 of file ExpansibleBandBlocksManager.h.

OpenDiskFilesHandlerT te::mem::ExpansibleBandBlocksManager::m_diskFilesHandler
protected

The disk files handler;.

Definition at line 457 of file ExpansibleBandBlocksManager.h.

unsigned char* te::mem::ExpansibleBandBlocksManager::m_getBlockPointer_returnValue
private

Definition at line 464 of file ExpansibleBandBlocksManager.h.

bool te::mem::ExpansibleBandBlocksManager::m_isInitialized
protected

Is this instance initialized ?

Definition at line 437 of file ExpansibleBandBlocksManager.h.

unsigned long int te::mem::ExpansibleBandBlocksManager::m_maxBlockSizeBytes
protected

The maximum global used block size in bytes.

Definition at line 443 of file ExpansibleBandBlocksManager.h.

unsigned long int te::mem::ExpansibleBandBlocksManager::m_maxDiskFilesSize
protected

The maximum temporary disk file size (bytes).

Definition at line 441 of file ExpansibleBandBlocksManager.h.

unsigned int te::mem::ExpansibleBandBlocksManager::m_maxNumberRAMBlocks
protected

The maximum number of RAM blocks;.

Definition at line 439 of file ExpansibleBandBlocksManager.h.

SwapFifoT::size_type te::mem::ExpansibleBandBlocksManager::m_nextFIFOPositionOverSwapFifo
protected

The next position where a block swap will occur over m_swapFifo;.

Definition at line 447 of file ExpansibleBandBlocksManager.h.

RAMBlocksPointersContainerT te::mem::ExpansibleBandBlocksManager::m_ramBlocksPointers
protected

3D Matrix of active RAM blocks pointers indexed in the form [band][blockYIndex][blockXIndex].

Definition at line 451 of file ExpansibleBandBlocksManager.h.

RAMBlockHandlerT te::mem::ExpansibleBandBlocksManager::m_swapBlockHandler
protected

An extra block for disk swap purposes.

Definition at line 459 of file ExpansibleBandBlocksManager.h.

SwapFifoT te::mem::ExpansibleBandBlocksManager::m_swapFifo
protected

Disk swapping FIFO.

Definition at line 453 of file ExpansibleBandBlocksManager.h.


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