SynchronizedBand.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 terralib/raster/SynchronizedBand.h
22 
23  \brief Syncrhonized raster band.
24 */
25 
26 #ifndef __TERRALIB_RASTER_INTERNAL_SYNCHRONIZEDBAND_H
27 #define __TERRALIB_RASTER_INTERNAL_SYNCHRONIZEDBAND_H
28 
29 // TerraLib
30 #include "Band.h"
32 #include "BlockUtils.h"
33 #include "Config.h"
34 
35 // Boost
36 #include <boost/noncopyable.hpp>
37 
38 namespace te
39 {
40  namespace rst
41  {
42  class SynchronizedRaster;
43 
44  /*!
45  \class SynchronizedBand
46 
47  \brief Syncrhonized raster band.
48 
49  \note More efficient access can be achieved by following the bands internal blocking scheme.
50  */
51  class TERASTEREXPORT SynchronizedBand : public te::rst::Band, public boost::noncopyable
52  {
53  public:
54 
55  /*!
56  \brief Constructor.
57 
58  \param blocksManager The blocks manager where to read/write data.
59  \param raster The synchonized raster instance (parent raster).
60  \param idx The band index.
61  */
62  SynchronizedBand( SynchronizedBandBlocksManager& blocksManager, SynchronizedRaster& raster, std::size_t idx );
63 
65 
66  inline te::rst::Raster* getRaster() const
67  {
68  return (te::rst::Raster*)(&m_syncRasterPtr);
69  };
70 
71  void getValue(unsigned int c, unsigned int r, double& value) const;
72 
73  void setValue(unsigned int c, unsigned int r, const double value);
74 
75  void getIValue(unsigned int c, unsigned int r, double& value) const;
76 
77  void setIValue(unsigned int c, unsigned int r, const double value);
78 
79  void read(int x, int y, void* buffer) const;
80 
81  void* read(int x, int y);
82 
83  void write(int x, int y, void* buffer);
84 
85  private:
86 
88 
89  protected :
90 
91  static SynchronizedBandBlocksManager dummyBlocksManager; //!< A global static dummy blocks manager.
92 
93  SynchronizedBandBlocksManager& m_blocksManager; //!< The external blocks manager.
94 
95  SynchronizedRaster* m_syncRasterPtr; //!< The synchronized raster instance (parent raster).
96 
97  unsigned int m_blkWidth; //!< The current band blocks width
98  unsigned int m_blkHeight; //!< The current band blocks height
99  unsigned int m_blkSizeBytes; //!< The blocks size (bytes);
100 
101  te::rst::GetBufferValueFPtr m_getBuff; //!< A pointer to a function that helps to extract a double or complex value from a specific buffer data type (char, int16, int32, float, ...).
102  te::rst::GetBufferValueFPtr m_getBuffI; //!< A pointer to a function that helps to extract the imaginary part value from a specific buffer data type (cint16, cint32, cfloat, cdouble).
103  te::rst::SetBufferValueFPtr m_setBuff; //!< A pointer to a function that helps to insert a double or complex value into a specific buffer data type (char, int16, int32, float, ...).
104  te::rst::SetBufferValueFPtr m_setBuffI; //!< A pointer to a function that helps to insert the imaginary part value into a specific buffer data type (cint16, cint32, cfloat, cdouble).
105 
106  // Variable used by setValue/getValue methods
107  mutable unsigned int m_setGetBlkX;
108  mutable unsigned int m_setGetBlkY;
109  mutable unsigned int m_setGetPos;
110  mutable void* m_setGetBufPtr;
111  };
112 
113  } // end namespace rst
114 } // end namespace te
115 
116 #endif // __TERRALIB_RASTER_INTERNAL_SYNCHRONIZEDBAND_H
#define TERASTEREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:62
An adapter class to allow concurrent access to raster data by multiple threads.
te::rst::SetBufferValueFPtr m_setBuff
A pointer to a function that helps to insert a double or complex value into a specific buffer data ty...
te::rst::GetBufferValueFPtr m_getBuff
A pointer to a function that helps to extract a double or complex value from a specific buffer data t...
te::rst::SetBufferValueFPtr m_setBuffI
A pointer to a function that helps to insert the imaginary part value into a specific buffer data typ...
te::rst::GetBufferValueFPtr m_getBuffI
A pointer to a function that helps to extract the imaginary part value from a specific buffer data ty...
unsigned int m_blkHeight
The current band blocks height.
void(* SetBufferValueFPtr)(int index, void *buffer, const double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:40
unsigned int m_blkWidth
The current band blocks width.
Utility functions for dealing with raster data blocks.
static SynchronizedBandBlocksManager dummyBlocksManager
A global static dummy blocks manager.
void(* GetBufferValueFPtr)(int index, void *buffer, double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:37
An abstract class for raster data strucutures.
Definition: Raster.h:71
Syncrhonized raster band.
URI C++ Library.
It gives access to values in one band (dimension) of a raster.
A raster band description.
Definition: Band.h:63
Synchronized raster raster band blocks manager.
Synchronized raster raster band blocks manager.
unsigned int m_blkSizeBytes
The blocks size (bytes);.
SynchronizedRaster * m_syncRasterPtr
The synchronized raster instance (parent raster).
te::rst::Raster * getRaster() const
Returns the associated raster.
Configuration flags for the Raster module of TerraLib.
SynchronizedBandBlocksManager & m_blocksManager
The external blocks manager.