26 #ifndef __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBANDBLOCKSMANAGER_H
27 #define __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBANDBLOCKSMANAGER_H
30 #include "../raster/Raster.h"
39 #include <boost/noncopyable.hpp>
40 #include <boost/shared_ptr.hpp>
41 #include <boost/shared_array.hpp>
71 BlockIndex3D() : m_dim0Index( 0 ), m_dim1Index( 0 ), m_dim2Index( 0 ) {};
75 m_dim1Index( dim1Index ), m_dim2Index( dim2Index ) {};
99 bool initialize(
const unsigned int maxNumberRAMBlocks,
100 const std::vector< unsigned int>& numbersOfBlocksX,
101 const std::vector< unsigned int>& numbersOfBlocksY,
102 const std::vector< unsigned int>& blocksSizesBytes,
103 const unsigned long int maxDiskFilesSize );
112 return m_isInitialized;
124 assert( m_ramBlocksPointers.size() > band );
125 assert( m_ramBlocksPointers[ band ].size() > 0 );
126 return (
unsigned int)m_ramBlocksPointers[ band ][ 0 ].size();
137 const unsigned int band )
const
139 assert( m_ramBlocksPointers.size() > band );
140 return (
unsigned int)m_ramBlocksPointers[ band ].size();
150 return (
unsigned int)m_ramBlocksPointers.size();
160 return m_maxBlockSizeBytes;
175 void* getBlockPointer(
unsigned int band,
unsigned int x,
unsigned int y );
180 return m_maxNumberRAMBlocks;
194 bool addTopBlocks(
const unsigned int& expansionSize,
195 const unsigned int& band,
196 std::vector< BlockIndex3D >& addedBlocksCoords );
209 bool addBottomBlocks(
const unsigned int& expansionSize,
210 const unsigned int& band,
211 std::vector< BlockIndex3D >& addedBlocksCoords );
222 bool addLeftBlocks(
const unsigned int& expansionSize,
223 const unsigned int& band,
224 std::vector< BlockIndex3D >& addedBlocksCoords );
235 bool addRightBlocks(
const unsigned int& expansionSize,
const unsigned int& band,
236 std::vector< BlockIndex3D >& addedBlocksCoords );
247 bool addTopBands(
const unsigned int& expansionSize,
248 std::vector< BlockIndex3D >& addedBlocksCoords );
258 bool addBottomBands(
const unsigned int& expansionSize,
259 std::vector< BlockIndex3D >& addedBlocksCoords );
314 bool allocateDiskBlocks(
const unsigned int blocksNumber,
315 std::vector< DiskBlockInfo >& diskBlocksInfos,
325 bool allocateAndActivateDiskBlocks(
const std::vector< BlockIndex3D >& blocksIndxes );
336 bool createNewDiskFile(
unsigned long int size, FILE** fileptr )
const;
349 template<
typename ContainerType >
351 ContainerType& inputContainer,
352 const unsigned int dim0index,
const int dim1Shift,
const int dim2Shift )
const
354 typename ContainerType::iterator it = inputContainer.begin();
355 const typename ContainerType::iterator itE = inputContainer.end();
360 if( it->m_dim0Index == dim0index )
362 assert( ( dim1Shift < 0 ) ? ( ((
int)it->m_dim1Index) > dim1Shift ) :
true );
364 ( ((
int)it->m_dim1Index) + dim1Shift );
366 assert( ( dim2Shift < 0 ) ? ( ((
int)it->m_dim2Index) > dim2Shift ) :
true );
368 ( ((
int)it->m_dim2Index) + dim2Shift );
386 template<
typename ContainerType >
388 ContainerType& inputContainer,
389 const int& dim0Shift,
const int& dim1Shift,
const int& dim2Shift )
const
391 typename ContainerType::iterator it = inputContainer.begin();
392 const typename ContainerType::iterator itE = inputContainer.end();
397 assert( ( dim0Shift < 0 ) ? ( ((
int)it->m_dim0Index) > dim0Shift ) :
true );
399 ( ((
int)it->m_dim0Index) + dim0Shift );
401 assert( ( dim1Shift < 0 ) ? ( ((
int)it->m_dim1Index) > dim1Shift ) :
true );
403 ( ((
int)it->m_dim1Index) + dim1Shift );
405 assert( ( dim2Shift < 0 ) ? ( ((
int)it->m_dim2Index) > dim2Shift ) :
true );
407 ( ((
int)it->m_dim2Index) + dim2Shift );
415 typedef unsigned char BlockElementT;
464 #endif // __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBANDBLOCKSMANAGER_H
SwapFifoT::size_type m_nextFIFOPositionOverSwapFifo
The next position where a block swap will occur over m_swapFifo;.
unsigned int getMaxNumberOfRAMBlocks() const
The maximum number of cache blocks.
std::list< OpenDiskFileHandlerPtrT > OpenDiskFilesHandlerT
Open dis files handler type.
std::list< RAMBlockHandlerT > RAMBlocksHandlerT
Blocks handler type;.
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
unsigned int CoordDataType
Coords data type.
Configuration flags for the TerraLib In-memory Data Access driver.
RAM cached and tiled raster band blocks manager.
CoordDataType m_dim0Index
Block Z (band) index.
unsigned int getNumberOfBlocksY(const unsigned int band) const
Returns the number of blocks along the Y directon for the required band.
BlockIndex3D(const CoordDataType &dim0Index, const CoordDataType &dim1Index, const CoordDataType &dim2Index)
unsigned int m_maxNumberRAMBlocks
The maximum number of RAM blocks;.
std::list< DiskBlockInfo > InactiveDiskBlocksInfoT
Inactive disk blocks info type.
unsigned int getNumberOfBands() const
Returns the number of bands.
BlockElementT * BlockelementPtrT
Block element pointer type.
boost::shared_array< BlockElementT > RAMBlockHandlerT
RAM Block handler type;.
unsigned long int getBlockSizeBytes()
Returns the internal size( bytes ) used for all internal blocks.
unsigned long int m_fileOff
std::vector< std::vector< std::vector< BlockelementPtrT > > > RAMBlocksPointersContainerT
RAM blocks pointers container type.
bool m_isInitialized
Is this instance initialized ?
boost::shared_ptr< OpenDiskFileHandler > OpenDiskFileHandlerPtrT
Open disk file pointer type.
OpenDiskFilesHandlerT m_diskFilesHandler
The disk files handler;.
RAMBlocksPointersContainerT m_ramBlocksPointers
3D Matrix of active RAM blocks pointers indexed in the form [band][blockYIndex][blockXIndex].
RAMBlocksHandlerT m_activeRAMBlocksHandler
The active RAM blocks handler.
std::vector< BlockIndex3D > SwapFifoT
Swap fifo type.
CoordDataType m_dim2Index
Block X index.
unsigned long int m_maxBlockSizeBytes
The maximum global used block size in bytes.
unsigned char * m_currSwapBlockPtr
A pointer to the current block where disk data swap will be done.
RAMBlockHandlerT m_swapBlockHandler
An extra block for disk swap purposes.
unsigned long int m_maxDiskFilesSize
The maximum temporary disk file size (bytes).
unsigned int getNumberOfBlocksX(const unsigned int band) const
Returns the number of blocks along the X directon for the required band.
unsigned char * m_getBlockPointer_returnValue
unsigned char BlockElementT
Block element type.
ActiveDiskBlocksInfoT m_activeDiskBlocksInfo
3D Matrix of active disk block info indexed as [band][blockYIndex][blockXIndex].
CoordDataType m_dim1Index
Block Y index.
SwapFifoT m_swapFifo
Disk swapping FIFO.
bool isInitialized() const
Returns true if this instance is initialized.
void shiftDim03DCoords(ContainerType &inputContainer, const unsigned int dim0index, const int dim1Shift, const int dim2Shift) const
Shift coords given a fixed dimention 0 index.
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.