ExpansibleBand.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/memory/ExpansibleBand.h
22 
23  \brief Expansible raster band.
24 */
25 
26 #ifndef __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBAND_H
27 #define __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBAND_H
28 
29 // TerraLib
30 #include "../raster/Band.h"
31 #include "../raster/BandProperty.h"
32 #include "../raster/BlockUtils.h"
33 #include "Config.h"
35 
36 // STL
37 #include <cassert>
38 #include <cstddef>
39 
40 // Boost
41 #include <boost/noncopyable.hpp>
42 
43 namespace te
44 {
45  namespace mem
46  {
47  /*!
48  \class ExpansibleBand
49 
50  \brief Expansible raster band.
51 
52  \details A cache adaptor to an external existent raster band that must always be avaliable.
53  */
54  class TEMEMORYEXPORT ExpansibleBand : public te::rst::Band, public boost::noncopyable
55  {
56  public:
57 
58  /*!
59  \brief Constructor.
60 
61  \param blocksManager The blocks manager where to read/write data.
62  \param parentRaster The parent raster pointer.
63  \param idx The band index.
64  */
66  te::rst::Raster& parentRaster,
67  const te::rst::BandProperty& bandProperty, std::size_t idx );
68 
70 
72  {
73  return m_parentRasterPtr;
74  };
75 
76  void getValue(unsigned int c, unsigned int r, double& value) const;
77 
78  void setValue(unsigned int c, unsigned int r, const double value);
79 
80  void getIValue(unsigned int c, unsigned int r, double& value) const;
81 
82  void setIValue(unsigned int c, unsigned int r, const double value);
83 
84  void read(int x, int y, void* buffer) const;
85 
86  void* read(int x, int y)
87  {
88  return m_blocksManager.getBlockPointer(static_cast<unsigned int>(m_idx), static_cast<unsigned int>(x), static_cast<unsigned int>(y));
89  };
90 
91  void write(int x, int y, void* buffer);
92 
93  private :
94 
96 
97  protected :
98 
99  static ExpansibleBandBlocksManager dummyBlocksManager; //!< A global static dummy blocks manager.
100 
101  ExpansibleBandBlocksManager& m_blocksManager; //!< The external blocks manager reference.
102 
103  te::rst::Raster* m_parentRasterPtr; //!< The parent raster ponter.
104 
105  unsigned int m_blkWidth; //!< Block width in pixels(for pixel access optimization purposes).
106 
107  unsigned int m_blkHeight; //!< Block width in pixels (for pixel access optimization purposes).
108 
109  unsigned int m_blkSizeBytes; //!< Blosk size bytes (for pixel access optimization purposes).
110 
111  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, ...).
112  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).
113  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, ...).
114  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).
115 
116 // Variable used by setValue/getValue methods
117  mutable unsigned int m_setGetBlkX;
118  mutable unsigned int m_setGetBlkY;
119  mutable unsigned int m_setGetPos;
120  mutable void* m_setGetBufPtr;
121  };
122 
123  } // end namespace mem
124 } // end namespace te
125 
126 #endif // __TERRALIB_MEMORY_INTERNAL_EXPANSIBLEBAND_H
RAM cached and tiled raster band blocks manager.
RAM cached and tiled raster band blocks manager.
Expansible raster band.
te::rst::Raster * m_parentRasterPtr
The parent raster ponter.
te::rst::Raster * getRaster() const
Returns the associated raster.
void setIValue(unsigned int c, unsigned int r, const double value)
Sets the imaginary attribute value in a complex band of a cell.
static ExpansibleBandBlocksManager dummyBlocksManager
A global static dummy blocks manager.
te::rst::GetBufferValueFPtr m_getBuffI
A pointer to a function that helps to extract the imaginary part value from a specific buffer data ty...
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...
void getIValue(unsigned int c, unsigned int r, double &value) const
Returns the imaginary attribute value in a complex band of a cell.
unsigned int m_blkWidth
Block width in pixels(for pixel access optimization purposes).
te::rst::SetBufferValueFPtr m_setBuffI
A pointer to a function that helps to insert the imaginary part value into a specific buffer data typ...
unsigned int m_blkSizeBytes
Blosk size bytes (for pixel access optimization purposes).
ExpansibleBand(ExpansibleBandBlocksManager &blocksManager, te::rst::Raster &parentRaster, const te::rst::BandProperty &bandProperty, std::size_t idx)
Constructor.
void read(int x, int y, void *buffer) const
It reads a data block to the specified buffer.
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
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...
ExpansibleBandBlocksManager & m_blocksManager
The external blocks manager reference.
void * read(int x, int y)
It reads and returns a data block.
unsigned int m_blkHeight
Block width in pixels (for pixel access optimization purposes).
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
A raster band description.
Definition: BandProperty.h:62
A raster band description.
Definition: Band.h:64
An abstract class for raster data strucutures.
Definition: Raster.h:72
void(* SetBufferValueFPtr)(int index, void *buffer, const double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:40
void(* GetBufferValueFPtr)(int index, void *buffer, double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:37
TerraLib.
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:84
Proxy configuration file for TerraView (see terraview_config.h).