TsExpansibleBandBlocksManager.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file TsExpansibleBandBlocksManager.h
22 
23  \brief A test suit for the Expansible Band Blocks Manager Class.
24  */
25 
26 #ifndef __TERRALIB_UNITTEST_MEMORY_EXPANSIBLEBANDBLOCKSMANAGER_INTERNAL_H
27 #define __TERRALIB_UNITTEST_MEMORY_EXPANSIBLEBANDBLOCKSMANAGER_INTERNAL_H
28 
29 // cppUnit
30 #include <cppunit/extensions/HelperMacros.h>
31 
32 #include <terralib/memory.h>
33 
34 /*!
35  \class TsExpansibleBandBlocksManager
36 
37  \brief A test suit for the Expansible Band Blocks Manager Class.
38  */
39 class TsExpansibleBandBlocksManager : public CPPUNIT_NS::TestFixture
40 {
42 
44 
46 
48 
49  protected :
50 
51  template< typename DataType >
53  {
54  DataType counter = 0;
55  const unsigned int bandsNumber = manager.getNumberOfBands();
56 
57  for( unsigned int bandIdx = 0 ; bandIdx < bandsNumber ; ++bandIdx )
58  {
59  const unsigned int numberOfBlocksX = manager.getNumberOfBlocksX( bandIdx );
60  const unsigned int numberOfBlocksY = manager.getNumberOfBlocksY( bandIdx );
61  const unsigned int blocksSizesBytes = manager.getBlockSizeBytes();
62  const unsigned int elementsNumber = blocksSizesBytes /
63  ((unsigned int)sizeof( DataType ));
64 
65  for( unsigned int blockX = 0 ; blockX < numberOfBlocksX ; ++blockX )
66  for( unsigned int blockY = 0 ; blockY < numberOfBlocksY ; ++blockY )
67  {
68  DataType* dataPtr = (DataType*)manager.getBlockPointer( bandIdx, blockX, blockY );
69  assert( dataPtr != 0 );
70 
71  for( unsigned int elemIdx = 0 ; elemIdx < elementsNumber ; ++elemIdx )
72  {
73  dataPtr[ elemIdx ] = counter;
74  ++counter;
75  }
76  }
77  }
78  }
79 
80  template< typename DataType >
82  {
83  DataType counter = 0;
84  const unsigned int bandsNumber = manager.getNumberOfBands();
85 
86  for( unsigned int bandIdx = 0 ; bandIdx < bandsNumber ; ++bandIdx )
87  {
88  const unsigned int numberOfBlocksX = manager.getNumberOfBlocksX( bandIdx );
89  const unsigned int numberOfBlocksY = manager.getNumberOfBlocksY( bandIdx );
90  const unsigned int blocksSizesBytes = manager.getBlockSizeBytes();
91  const unsigned int elementsNumber = blocksSizesBytes /
92  ((unsigned int)sizeof( DataType ));
93 
94  for( unsigned int blockX = 0 ; blockX < numberOfBlocksX ; ++blockX )
95  for( unsigned int blockY = 0 ; blockY < numberOfBlocksY ; ++blockY )
96  {
97  DataType* dataPtr = (DataType*)manager.getBlockPointer( bandIdx, blockX, blockY );
98  assert( dataPtr != 0 );
99 
100  for( unsigned int elemIdx = 0 ; elemIdx < elementsNumber ; ++elemIdx )
101  {
102  CPPUNIT_ASSERT( dataPtr[ elemIdx ] == counter );
103  ++counter;
104  }
105  }
106  }
107  }
108 
109  void ReadWriteTest();
110 
111  void addBlocksTest();
112 };
113 
114 #endif // __TERRALIB_UNITTEST_MEMORY_EXPANSIBLEBANDBLOCKSMANAGER_INTERNAL_H
115 
void FillBlocks(te::mem::ExpansibleBandBlocksManager &manager)
This file contains include headers for the memory data source of TerraLib.
void * getBlockPointer(unsigned int band, unsigned int x, unsigned int y)
Returns a pointer to the required data block.
unsigned int getNumberOfBands() const
Returns the number of bands.
CPPUNIT_TEST_SUITE(TsExpansibleBandBlocksManager)
RAM cached and tiled raster band blocks manager.
unsigned int getNumberOfBlocksY(const unsigned int band) const
Returns the number of blocks along the Y directon for the required band.
A test suit for the Expansible Band Blocks Manager Class.
unsigned long int getBlockSizeBytes()
Returns the internal size( bytes ) used for all internal blocks.
unsigned int getNumberOfBlocksX(const unsigned int band) const
Returns the number of blocks along the X directon for the required band.
void CheckValues(te::mem::ExpansibleBandBlocksManager &manager)