All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SynchronizedRaster.h
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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 terralib/raster/SynchronizedRaster.h
22 
23  \brief An adapter class to allow concurrent access to raster data by multiple threads.
24 */
25 
26 #ifndef __TERRALIB_RASTER_INTERNAL_SYNCHRONIZEDRASTER_H
27 #define __TERRALIB_RASTER_INTERNAL_SYNCHRONIZEDRASTER_H
28 
29 // TerraLib
30 #include "Raster.h"
31 #include "RasterSynchronizer.h"
32 #include "SynchronizedBand.h"
34 #include "Config.h"
35 
36 namespace te
37 {
38  namespace rst
39  {
40  /*!
41  \class SynchronizedRaster
42 
43  \brief An adapter class to allow concurrent access to raster data by multiple threads.
44 
45  \note One unique RasterSynchronizer must be instantiated on the main process. That RasterSynchronizer is used by each thread to instantiate multiple SynchronizedRaster instances.
46 
47  \note More efficient access can be achieved by following the bands internal blocking scheme.
48  */
50  {
51  public:
52 
53  /*!
54  \brief Constructor.
55 
56  \param sync The raster synchronizer instance.
57 
58  \param maxMemPercentUsed The maximum free memory percentual to use valid range: [1:100].
59  */
60  SynchronizedRaster( RasterSynchronizer& sync, const unsigned char maxMemPercentUsed );
61 
62  /*!
63  \brief Constructor.
64 
65  \param sync The raster synchronizer instance.
66 
67  \param maxNumberOfCacheBlocks The maximum number of cache blocks.
68  */
69  SynchronizedRaster( const unsigned int maxNumberOfCacheBlocks, RasterSynchronizer& sync );
70 
72 
73  std::map<std::string, std::string> getInfo() const;
74 
75  inline std::size_t getNumberOfBands() const
76  {
77  return m_bands.size();
78  };
79 
80  int getBandDataType(std::size_t i) const;
81 
82  inline const te::rst::Band* getBand(std::size_t i) const
83  {
84  assert( i < m_bands.size() );
85  return m_bands[ i ];
86  };
87 
88  inline te::rst::Band* getBand(std::size_t i)
89  {
90  assert( i < m_bands.size() );
91  return m_bands[ i ];
92  };
93 
94  inline const te::rst::Band& operator[](std::size_t i) const
95  {
96  assert( i < m_bands.size() );
97  return *(m_bands[ i ]);
98  };
99 
100  inline te::rst::Band& operator[](std::size_t i)
101  {
102  assert( i < m_bands.size() );
103  return *(m_bands[ i ]);
104  };
105 
106  te::dt::AbstractData* clone() const;
107 
108  protected:
109 
110  /*! \brief Free all allocated internal resources and go back to the initial state. */
111  void free();
112 
113  private :
114 
116 
118 
119  void open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p = te::common::RAccess);
120 
121  protected :
122 
123  SynchronizedBandBlocksManager m_blocksManager; //!< Internal blocks manager.
124 
125  std::vector< SynchronizedBand* > m_bands; //!< Internal raster bands.
126  };
127 
128  } // end namespace rst
129 } // end namespace te
130 
131 #endif //__TERRALIB_RASTER_INTERNAL_SYNCHRONIZEDRASTER_H
#define TERASTEREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:65
const te::rst::Band & operator[](std::size_t i) const
Access band in i position.
An adapter class to allow concurrent access to raster data by multiple threads.
te::rst::Band & operator[](std::size_t i)
Access band in i position.
SynchronizedBandBlocksManager m_blocksManager
Internal blocks manager.
te::rst::Band * getBand(std::size_t i)
Returns the raster i-th band.
An access synchronizer to be used in SynchronizedRaster raster instances.
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
Syncrhonized raster band.
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
An abstract class for raster data strucutures.
An abstract class for raster data strucutures.
Definition: Raster.h:71
An access synchronizer to be used in SynchronizedRaster raster instances.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
A raster band description.
Definition: Band.h:63
Synchronized raster raster band blocks manager.
Synchronized raster raster band blocks manager.
std::vector< SynchronizedBand * > m_bands
Internal raster bands.
Configuration flags for the Raster module of TerraLib.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68