28 #include "../raster/Band.h" 29 #include "../raster/BandProperty.h" 32 #include "../common/PlatformUtils.h" 33 #include "../core/translator/Translator.h" 67 unsigned int maxBlockSizeBytes = 0;
81 const double freeVMem = ( ((double)maxMemPercentUsed) / 100.0 ) *
82 std::min( totalPhysMem, ( totalVMem - usedVMem ) );
83 unsigned int maxNumberOfCacheBlocks = (
unsigned int)
84 std::max( 1.0, std::ceil( freeVMem / ((
double)maxBlockSizeBytes) ) );
86 return initialize( maxNumberOfCacheBlocks, sync );
90 const unsigned int maxNumberOfCacheBlocks,
101 unsigned int numberOfRasterBlocks = 0;
115 numberOfRasterBlocks +=
125 unsigned int blockBIdx = 0;
150 unsigned int blockBIdx = 0;
151 unsigned int blockYIdx = 0;
152 unsigned int blockXIdx = 0;
153 void* blockPtr =
nullptr;
179 unsigned char* blockPtr =
nullptr;
180 for( std::vector< unsigned char* >::size_type blocksHandlerIdx = 0 ;
186 delete[]( blockPtr );
197 unsigned int x,
unsigned int y )
200 assert( band < m_syncPtr->m_raster.getNumberOfBands() );
208 if( m_getBlockPointer_BlkPtr ==
nullptr )
219 newBlockFifoIndex.
m_y = y;
220 newBlockFifoIndex.
m_x = x;
229 choosedSwapBlockIndex.
m_y ][ choosedSwapBlockIndex.
m_x ];
230 assert( m_getBlockPointer_BlkPtr );
232 choosedSwapBlockIndex.
m_y ][ choosedSwapBlockIndex.
m_x ] =
nullptr;
237 choosedSwapBlockIndex.
m_x, choosedSwapBlockIndex.
m_y, m_getBlockPointer_BlkPtr ) )
243 choosedSwapBlockIndex.
m_b =
band;
244 choosedSwapBlockIndex.
m_y = y;
245 choosedSwapBlockIndex.
m_x = x;
An exception class for the Raster module.
std::vector< std::vector< std::vector< unsigned char * > > > m_blocksPointers
3D Matrix of block pointers indexed as [band][blockYIndex][blockXIndex].
TECOMMONEXPORT unsigned long long int GetTotalVirtualMemory()
Returns the amount of total virtual memory (bytes) that can be claimed by the current process (physic...
SynchronizedBandBlocksManager()
RasterSynchronizer * m_syncPtr
A pointer to the synchronizer used by this instance, of null if not initialized.
Base exception class for plugin module.
bool acquireBlock(const unsigned int bandIdx, const unsigned int blockXIndex, const unsigned int blockYIndex, void *blkDataPtr)
Acquire a raster data block.
int m_nblocksx
The number of blocks in x.
int m_nblocksy
The number of blocks in y.
~SynchronizedBandBlocksManager()
An access synchronizer to be used in SynchronizedRaster raster instances.
#define TE_TR(message)
It marks a string in order to get translated.
unsigned int m_blocksFifoNextSwapBlockIndex
The next block swapp index over m_blocksFifo.
std::vector< BlockIndex > m_blocksFifo
blocks swap FIFO.
boost::mutex m_mutex
General sync mutex;.
void initState()
Initialize this instance to an initial state.
std::vector< unsigned char * > m_blocksHandler
Cache blocks handler.
unsigned int m_maxNumberOfCacheBlocks
The maximum number of cache blocks.
Raster & m_raster
The input raster.
An abstract class for raster data strucutures.
unsigned int m_y
Block index over the Y axis.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
BandProperty * getProperty()
Returns the band property.
te::rst::Raster * getRaster() const
Returns the associated raster.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
unsigned char * m_getBlockPointer_BlkPtr
unsigned int m_globalBlockSizeBytes
The maximum block size for all bands.
bool initialize(RasterSynchronizer &sync, const unsigned char maxMemPercentUsed)
Initialize this instance to an initial state.
Synchronized raster raster band blocks manager.
TECOMMONEXPORT unsigned long long int GetTotalPhysicalMemory()
Returns the amount of total physical memory (bytes).
te::common::AccessPolicy m_policy
The access policy used on the given input raster.
unsigned int m_b
Block band index.
TECOMMONEXPORT unsigned long long int GetUsedVirtualMemory()
Returns the amount of used virtual memory (bytes) for the current process (physical + swapped)...
bool releaseBlock(const unsigned int bandIdx, const unsigned int blockXIndex, const unsigned int blockYIndex, void *blkDataPtr)
Release a raster data block.
virtual int getBlockSize() const
It returns the number of bytes ocuppied by a data block.
unsigned int m_globalBlocksNumberY
The maximum number of blocks (Y axis) for all bands.
void * getBlockPointer(unsigned int band, unsigned int x, unsigned int y)
Returns a pointer to the required data block.
unsigned int m_globalBlocksNumberX
The maximum number of blocks (X axis) for all bands.
unsigned int m_x
Block index over the X axis.