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 ) {};
74 BlockIndex3D(
const CoordDataType& dim0Index,
const CoordDataType& dim1Index,
75 const CoordDataType& dim2Index ) : m_dim0Index( dim0Index ),
76 m_dim1Index( dim1Index ), m_dim2Index( dim2Index ) {};
100 bool initialize(
const unsigned int maxNumberRAMBlocks,
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;
176 void* getBlockPointer(
unsigned int band,
unsigned int x,
unsigned int y );
181 return m_maxNumberRAMBlocks;
195 bool addTopBlocks(
const unsigned int& expansionSize,
196 const unsigned int& band,
197 std::vector< BlockIndex3D >& addedBlocksCoords );
210 bool addBottomBlocks(
const unsigned int& expansionSize,
211 const unsigned int& band,
212 std::vector< BlockIndex3D >& addedBlocksCoords );
223 bool addLeftBlocks(
const unsigned int& expansionSize,
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 );
248 bool addTopBands(
const unsigned int& expansionSize,
249 std::vector< BlockIndex3D >& addedBlocksCoords );
259 bool addBottomBands(
const unsigned int& expansionSize,
260 std::vector< BlockIndex3D >& addedBlocksCoords );
317 bool allocateDiskBlocks(
const unsigned int blocksNumber,
318 std::vector< DiskBlockInfo >& diskBlocksInfos,
319 OpenDiskFilesHandlerT& diskFilesHandler )
const;
328 bool allocateAndActivateDiskBlocks(
const std::vector< BlockIndex3D >& blocksIndxes );
341 bool createNewDiskFile(
unsigned long int size, FILE** fileptr,
342 std::string& fullFileName )
const;
355 template<
typename ContainerType >
357 ContainerType& inputContainer,
358 const unsigned int dim0index,
const int dim1Shift,
const int dim2Shift )
const
360 typename ContainerType::iterator it = inputContainer.begin();
361 const typename ContainerType::iterator itE = inputContainer.end();
366 if( it->m_dim0Index == dim0index )
368 assert( ( dim1Shift < 0 ) ? ( ((
int)it->m_dim1Index) > dim1Shift ) :
true );
370 ( ((
int)it->m_dim1Index) + dim1Shift );
372 assert( ( dim2Shift < 0 ) ? ( ((
int)it->m_dim2Index) > dim2Shift ) :
true );
374 ( ((
int)it->m_dim2Index) + dim2Shift );
392 template<
typename ContainerType >
394 ContainerType& inputContainer,
395 const int& dim0Shift,
const int& dim1Shift,
const int& dim2Shift )
const
397 typename ContainerType::iterator it = inputContainer.begin();
398 const typename ContainerType::iterator itE = inputContainer.end();
403 assert( ( dim0Shift < 0 ) ? ( ((
int)it->m_dim0Index) > dim0Shift ) :
true );
405 ( ((
int)it->m_dim0Index) + dim0Shift );
407 assert( ( dim1Shift < 0 ) ? ( ((
int)it->m_dim1Index) > dim1Shift ) :
true );
409 ( ((
int)it->m_dim1Index) + dim1Shift );
411 assert( ( dim2Shift < 0 ) ? ( ((
int)it->m_dim2Index) > dim2Shift ) :
true );
413 ( ((
int)it->m_dim2Index) + dim2Shift );
470 #endif // __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBANDBLOCKSMANAGER_H
unsigned char * m_currSwapBlockPtr
A pointer to the current block where disk data swap will be done.
unsigned char * m_getBlockPointer_returnValue
RAMBlocksPointersContainerT m_ramBlocksPointers
3D Matrix of active RAM blocks pointers indexed in the form [band][blockYIndex][blockXIndex].
std::string m_fullFileName
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
void shift3DCoords(ContainerType &inputContainer, const int &dim0Shift, const int &dim1Shift, const int &dim2Shift) const
Shift 3D coords.
std::list< OpenDiskFileHandlerPtrT > OpenDiskFilesHandlerT
Open dis files handler type.
std::vector< std::vector< std::vector< DiskBlockInfo > > > ActiveDiskBlocksInfoT
Active disk blocks info type;.
std::vector< std::vector< std::vector< BlockelementPtrT > > > RAMBlocksPointersContainerT
RAM blocks pointers container type.
BlockIndex3D(const CoordDataType &dim0Index, const CoordDataType &dim1Index, const CoordDataType &dim2Index)
std::vector< BlockIndex3D > SwapFifoT
Swap fifo type.
unsigned int getNumberOfBands() const
Returns the number of bands.
Configuration flags for the TerraLib In-memory Data Access driver.
ActiveDiskBlocksInfoT m_activeDiskBlocksInfo
3D Matrix of active disk block info indexed as [band][blockYIndex][blockXIndex].
std::list< DiskBlockInfo > InactiveDiskBlocksInfoT
Inactive disk blocks info type.
unsigned long int m_maxBlockSizeBytes
The maximum global used block size in bytes.
RAMBlocksHandlerT m_activeRAMBlocksHandler
The active RAM blocks handler.
void shiftDim03DCoords(ContainerType &inputContainer, const unsigned int dim0index, const int dim1Shift, const int dim2Shift) const
Shift coords given a fixed dimention 0 index.
RAM cached and tiled raster band blocks manager.
CoordDataType m_dim0Index
Block Z (band) index.
CoordDataType m_dim2Index
Block X index.
unsigned int getNumberOfBlocksY(const unsigned int band) const
Returns the number of blocks along the Y directon for the required band.
unsigned long int m_maxDiskFilesSize
The maximum temporary disk file size (bytes).
unsigned long int getBlockSizeBytes()
Returns the internal size( bytes ) used for all internal blocks.
bool isInitialized() const
Returns true if this instance is initialized.
unsigned long int m_fileOff
SwapFifoT::size_type m_nextFIFOPositionOverSwapFifo
The next position where a block swap will occur over m_swapFifo;.
BlockElementT * BlockelementPtrT
Block element pointer type.
boost::shared_ptr< OpenDiskFileHandler > OpenDiskFileHandlerPtrT
Open disk file pointer type.
unsigned int getNumberOfBlocksX(const unsigned int band) const
Returns the number of blocks along the X directon for the required band.
boost::shared_array< BlockElementT > RAMBlockHandlerT
RAM Block handler type;.
unsigned int CoordDataType
Coords data type.
bool m_isInitialized
Is this instance initialized ?
OpenDiskFilesHandlerT m_diskFilesHandler
The disk files handler;.
unsigned int m_maxNumberRAMBlocks
The maximum number of RAM blocks;.
CoordDataType m_dim1Index
Block Y index.
unsigned int getMaxNumberOfRAMBlocks() const
The maximum number of cache blocks.
std::list< RAMBlockHandlerT > RAMBlocksHandlerT
Blocks handler type;.
SwapFifoT m_swapFifo
Disk swapping FIFO.
unsigned char BlockElementT
Block element type.
RAMBlockHandlerT m_swapBlockHandler
An extra block for disk swap purposes.