26 #ifndef __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBANDBLOCKSMANAGER_H
27 #define __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBANDBLOCKSMANAGER_H
30 #include "../raster/Raster.h"
40 #include <boost/noncopyable.hpp>
41 #include <boost/shared_ptr.hpp>
42 #include <boost/shared_array.hpp>
72 BlockIndex3D() : m_dim0Index( 0 ), m_dim1Index( 0 ), m_dim2Index( 0 ) {};
76 m_dim1Index( dim1Index ), m_dim2Index( dim2Index ) {};
101 const std::vector< unsigned int>& numbersOfBlocksX,
102 const std::vector< unsigned int>& numbersOfBlocksY,
103 const std::vector< unsigned int>& blocksSizesBytes,
104 const unsigned long int maxDiskFilesSize );
113 return m_isInitialized;
125 assert( m_ramBlocksPointers.size() > band );
126 assert( m_ramBlocksPointers[ band ].size() > 0 );
127 return (
unsigned int)m_ramBlocksPointers[ band ][ 0 ].size();
138 const unsigned int band )
const
140 assert( m_ramBlocksPointers.size() > band );
141 return (
unsigned int)m_ramBlocksPointers[ band ].size();
151 return (
unsigned int)m_ramBlocksPointers.size();
161 return m_maxBlockSizeBytes;
181 return m_maxNumberRAMBlocks;
196 const unsigned int& band,
197 std::vector< BlockIndex3D >& addedBlocksCoords );
211 const unsigned int& band,
212 std::vector< BlockIndex3D >& addedBlocksCoords );
224 const unsigned int& band,
225 std::vector< BlockIndex3D >& addedBlocksCoords );
236 bool addRightBlocks(
const unsigned int& expansionSize,
const unsigned int& band,
237 std::vector< BlockIndex3D >& addedBlocksCoords );
249 std::vector< BlockIndex3D >& addedBlocksCoords );
260 std::vector< BlockIndex3D >& addedBlocksCoords );
318 std::vector< DiskBlockInfo >& diskBlocksInfos,
341 template<
typename ContainerType >
343 ContainerType& inputContainer,
344 const unsigned int dim0index,
const int dim1Shift,
const int dim2Shift )
const
346 typename ContainerType::iterator it = inputContainer.begin();
347 const typename ContainerType::iterator itE = inputContainer.end();
352 if( it->m_dim0Index == dim0index )
354 assert( ( dim1Shift < 0 ) ? ( ((
int)it->m_dim1Index) > dim1Shift ) :
true );
356 ( ((
int)it->m_dim1Index) + dim1Shift );
358 assert( ( dim2Shift < 0 ) ? ( ((
int)it->m_dim2Index) > dim2Shift ) :
true );
360 ( ((
int)it->m_dim2Index) + dim2Shift );
378 template<
typename ContainerType >
380 ContainerType& inputContainer,
381 const int& dim0Shift,
const int& dim1Shift,
const int& dim2Shift )
const
383 typename ContainerType::iterator it = inputContainer.begin();
384 const typename ContainerType::iterator itE = inputContainer.end();
389 assert( ( dim0Shift < 0 ) ? ( ((
int)it->m_dim0Index) > dim0Shift ) :
true );
391 ( ((
int)it->m_dim0Index) + dim0Shift );
393 assert( ( dim1Shift < 0 ) ? ( ((
int)it->m_dim1Index) > dim1Shift ) :
true );
395 ( ((
int)it->m_dim1Index) + dim1Shift );
397 assert( ( dim2Shift < 0 ) ? ( ((
int)it->m_dim2Index) > dim2Shift ) :
true );
399 ( ((
int)it->m_dim2Index) + dim2Shift );
CoordDataType m_dim0Index
Block Z (band) index.
BlockIndex3D(const CoordDataType &dim0Index, const CoordDataType &dim1Index, const CoordDataType &dim2Index)
unsigned int CoordDataType
Coords data type.
CoordDataType m_dim2Index
Block X index.
CoordDataType m_dim1Index
Block Y index.
unsigned long int m_fileOff
std::string m_fullFileName
RAM cached and tiled raster band blocks manager.
bool isInitialized() const
Returns true if this instance is initialized.
unsigned long int m_maxBlockSizeBytes
The maximum global used block size in bytes.
std::list< DiskBlockInfo > InactiveDiskBlocksInfoT
Inactive disk blocks info type.
boost::shared_array< BlockElementT > RAMBlockHandlerT
RAM Block handler type;
RAMBlocksHandlerT m_activeRAMBlocksHandler
The active RAM blocks handler.
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.
std::list< RAMBlockHandlerT > RAMBlocksHandlerT
Blocks handler type;.
void initState()
Initialize this instance to an initial state.
ActiveDiskBlocksInfoT m_activeDiskBlocksInfo
3D Matrix of active disk block info indexed as [band][blockYIndex][blockXIndex].
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.
unsigned int m_maxNumberRAMBlocks
The maximum number of RAM blocks;.
bool allocateDiskBlocks(const unsigned int blocksNumber, std::vector< DiskBlockInfo > &diskBlocksInfos, OpenDiskFilesHandlerT &diskFilesHandler) const
Allocate disk blocks.
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.
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.
BlockElementT * BlockelementPtrT
Block element pointer type.
unsigned int getMaxNumberOfRAMBlocks() const
The maximum number of cache blocks.
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.
RAMBlocksPointersContainerT m_ramBlocksPointers
3D Matrix of active RAM blocks pointers indexed in the form [band][blockYIndex][blockXIndex].
SwapFifoT::size_type m_nextFIFOPositionOverSwapFifo
The next position where a block swap will occur over m_swapFifo;.
unsigned long int m_maxDiskFilesSize
The maximum temporary disk file size (bytes).
void * getBlockPointer(unsigned int band, unsigned int x, unsigned int y)
Returns a pointer to the required data block.
boost::shared_ptr< OpenDiskFileHandler > OpenDiskFileHandlerPtrT
Open disk file pointer type.
bool allocateAndActivateDiskBlocks(const std::vector< BlockIndex3D > &blocksIndxes)
Allocate and activate disk blocks.
unsigned int getNumberOfBands() const
Returns the number of bands.
RAMBlockHandlerT m_swapBlockHandler
An extra block for disk swap purposes.
std::list< OpenDiskFileHandlerPtrT > OpenDiskFilesHandlerT
Open dis files handler type.
std::vector< BlockIndex3D > SwapFifoT
Swap fifo type.
void shiftDim03DCoords(ContainerType &inputContainer, const unsigned int dim0index, const int dim1Shift, const int dim2Shift) const
Shift coords given a fixed dimention 0 index.
unsigned char * m_currSwapBlockPtr
A pointer to the current block where disk data swap will be done.
unsigned int getNumberOfBlocksX(const unsigned int band) const
Returns the number of blocks along the X directon for the required band.
OpenDiskFilesHandlerT m_diskFilesHandler
The disk files handler;.
std::vector< std::vector< std::vector< BlockelementPtrT > > > RAMBlocksPointersContainerT
RAM blocks pointers container type.
~ExpansibleBandBlocksManager()
unsigned char BlockElementT
Block element type.
SwapFifoT m_swapFifo
Disk swapping FIFO.
unsigned int getNumberOfBlocksY(const unsigned int band) const
Returns the number of blocks along the Y directon for the required band.
ExpansibleBandBlocksManager()
std::vector< std::vector< std::vector< DiskBlockInfo > > > ActiveDiskBlocksInfoT
Active disk blocks info type;.
void shift3DCoords(ContainerType &inputContainer, const int &dim0Shift, const int &dim1Shift, const int &dim2Shift) const
Shift 3D coords.
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).
unsigned long int getBlockSizeBytes()
Returns the internal size( bytes ) used for all internal blocks.
void free()
Free all allocated internal resources and go back to the initial state.
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).
bool m_isInitialized
Is this instance initialized ?
unsigned char * m_getBlockPointer_returnValue
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Proxy configuration file for TerraView (see terraview_config.h).