Go to the documentation of this file.
   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,
 
  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 
  
 
std::vector< std::vector< std::vector< BlockelementPtrT > > > RAMBlocksPointersContainerT
RAM blocks pointers container type.
 
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).
 
RAMBlocksHandlerT m_activeRAMBlocksHandler
The active RAM blocks handler.
 
void free()
Free all allocated internal resources and go back to the initial state.
 
void shift3DCoords(ContainerType &inputContainer, const int &dim0Shift, const int &dim1Shift, const int &dim2Shift) const
Shift 3D coords.
 
std::list< DiskBlockInfo > InactiveDiskBlocksInfoT
Inactive disk blocks info type.
 
unsigned int CoordDataType
Coords data type.
 
unsigned char * m_getBlockPointer_returnValue
 
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.
 
std::vector< std::vector< std::vector< DiskBlockInfo > > > ActiveDiskBlocksInfoT
Active disk blocks info type;.
 
unsigned char BlockElementT
Block element type.
 
bool m_isInitialized
Is this instance initialized ?
 
ExpansibleBandBlocksManager()
 
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.
 
OpenDiskFilesHandlerT m_diskFilesHandler
The disk files handler;.
 
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.
 
std::vector< BlockIndex3D > SwapFifoT
Swap fifo type.
 
ActiveDiskBlocksInfoT m_activeDiskBlocksInfo
3D Matrix of active disk block info indexed as [band][blockYIndex][blockXIndex].
 
unsigned int getNumberOfBlocksX(const unsigned int band) const
Returns the number of blocks along the X directon for the required band.
 
unsigned long int m_fileOff
 
BlockIndex3D(const CoordDataType &dim0Index, const CoordDataType &dim1Index, const CoordDataType &dim2Index)
 
boost::shared_array< BlockElementT > RAMBlockHandlerT
RAM Block handler type;
 
bool createNewDiskFile(unsigned long int size, FILE **fileptr, std::string &fullFileName) const
Create a new disk file.
 
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.
 
BlockElementT * BlockelementPtrT
Block element pointer type.
 
unsigned int getNumberOfBlocksY(const unsigned int band) const
Returns the number of blocks along the Y directon for the required band.
 
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.
 
SwapFifoT::size_type m_nextFIFOPositionOverSwapFifo
The next position where a block swap will occur over m_swapFifo;.
 
std::string m_fullFileName
 
unsigned long int getBlockSizeBytes()
Returns the internal size( bytes ) used for all internal blocks.
 
void * getBlockPointer(unsigned int band, unsigned int x, unsigned int y)
Returns a pointer to the required data block.
 
std::list< RAMBlockHandlerT > RAMBlocksHandlerT
Blocks handler type;.
 
bool isInitialized() const
Returns true if this instance is initialized.
 
RAMBlockHandlerT m_swapBlockHandler
An extra block for disk swap purposes.
 
SwapFifoT m_swapFifo
Disk swapping FIFO.
 
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).
 
RAM cached and tiled raster band blocks manager.
 
CoordDataType m_dim1Index
Block Y index.
 
unsigned int m_maxNumberRAMBlocks
The maximum number of RAM blocks;.
 
bool allocateAndActivateDiskBlocks(const std::vector< BlockIndex3D > &blocksIndxes)
Allocate and activate disk blocks.
 
CoordDataType m_dim2Index
Block X index.
 
void shiftDim03DCoords(ContainerType &inputContainer, const unsigned int dim0index, const int dim1Shift, const int dim2Shift) const
Shift coords given a fixed dimention 0 index.
 
std::list< OpenDiskFileHandlerPtrT > OpenDiskFilesHandlerT
Open dis files handler type.
 
bool allocateDiskBlocks(const unsigned int blocksNumber, std::vector< DiskBlockInfo > &diskBlocksInfos, OpenDiskFilesHandlerT &diskFilesHandler) const
Allocate disk blocks.
 
#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).
 
~ExpansibleBandBlocksManager()
 
void initState()
Initialize this instance to an initial state.
 
RAMBlocksPointersContainerT m_ramBlocksPointers
3D Matrix of active RAM blocks pointers indexed in the form [band][blockYIndex][blockXIndex].
 
CoordDataType m_dim0Index
Block Z (band) index.
 
unsigned long int m_maxDiskFilesSize
The maximum temporary disk file size (bytes).
 
boost::shared_ptr< OpenDiskFileHandler > OpenDiskFileHandlerPtrT
Open disk file pointer type.
 
unsigned int getMaxNumberOfRAMBlocks() const
The maximum number of cache blocks.
 
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 getNumberOfBands() const
Returns the number of bands.