31 #include "../common/Translator.h"
37 : m_policy( policy ), m_raster( raster )
58 const unsigned int blockXIndex,
const unsigned int blockYIndex,
63 if( bandIdx >= m_blocksUseCounters.size() )
66 throw Exception(
TE_TR(
"Inalid band index") );
68 if( blockYIndex >= m_blocksUseCounters[ bandIdx ].size() )
71 throw Exception(
TE_TR(
"Inalid block Y index") );
73 if( blockXIndex >= m_blocksUseCounters[ bandIdx ][ blockYIndex ].size() )
76 throw Exception(
TE_TR(
"Inalid block X index") );
83 while( m_blocksUseCounters[ bandIdx ][ blockYIndex ][ blockXIndex ] )
85 m_condVar.wait( m_mutex );
88 assert( m_blocksUseCounters[ bandIdx ][ blockYIndex ][ blockXIndex ] == 0 );
90 m_blocksUseCounters[ bandIdx ][ blockYIndex ][ blockXIndex ] = 1;
92 m_raster.getBand( bandIdx )->read( blockXIndex, blockYIndex, blkDataPtr );
100 ++( m_blocksUseCounters[ bandIdx ][ blockYIndex ][ blockXIndex ] );
102 m_raster.getBand( bandIdx )->read( blockXIndex, blockYIndex, blkDataPtr );
111 const unsigned int blockXIndex,
const unsigned int blockYIndex,
116 if( bandIdx >= m_blocksUseCounters.size() )
119 throw Exception(
TE_TR(
"Inalid band index") );
121 if( blockYIndex >= m_blocksUseCounters[ bandIdx ].size() )
124 throw Exception(
TE_TR(
"Inalid block Y index") );
126 if( blockXIndex >= m_blocksUseCounters[ bandIdx ][ blockYIndex ].size() )
129 throw Exception(
TE_TR(
"Inalid block X index") );
132 if( m_blocksUseCounters[ bandIdx ][ blockYIndex ][ blockXIndex ] )
137 m_raster.getBand( bandIdx )->write( blockXIndex, blockYIndex, blkDataPtr );
140 --( m_blocksUseCounters[ bandIdx ][ blockYIndex ][ blockXIndex ] );
145 m_condVar.notify_all();
It describes one band (or dimension) of a raster.
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.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
int m_nblocksy
The number of blocks in y.
#define TE_TR(message)
It marks a string in order to get translated.
AccessPolicy
Supported data access policies (can be used as bitfield).
An exception class for the Raster module.
RasterSynchronizer(Raster &raster, const te::common::AccessPolicy policy)
Constructor.
An abstract class for raster data strucutures.
BandProperty * getProperty()
Returns the band property.
An access synchronizer to be used in SynchronizedRaster raster instances.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
It gives access to values in one band (dimension) of a raster.
BlocksUseCounterT m_blocksUseCounters
blocks use counter.
bool releaseBlock(const unsigned int bandIdx, const unsigned int blockXIndex, const unsigned int blockYIndex, void *blkDataPtr)
Release a raster data block.