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
te
TerraLib.
Definition: AddressGeocodingOp.h:52
ExpansibleBandBlocksManager.h
RAM cached and tiled raster band blocks manager.
te::rst::Band
A raster band description.
Definition: Band.h:64
te::mem::ExpansibleBand::getRaster
te::rst::Raster * getRaster() const
Returns the associated raster.
Definition: ExpansibleBand.h:71
te::rst::SetBufferValueFPtr
void(* SetBufferValueFPtr)(int index, void *buffer, const double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:40
te::mem::ExpansibleBand::dummyBlocksManager
static ExpansibleBandBlocksManager dummyBlocksManager
A global static dummy blocks manager.
Definition: ExpansibleBand.h:99
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::mem::ExpansibleBand::m_blocksManager
ExpansibleBandBlocksManager & m_blocksManager
The external blocks manager reference.
Definition: ExpansibleBand.h:101
te::mem::ExpansibleBand::m_setBuff
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...
Definition: ExpansibleBand.h:113
te::mem::ExpansibleBand::m_getBuffI
te::rst::GetBufferValueFPtr m_getBuffI
A pointer to a function that helps to extract the imaginary part value from a specific buffer data ty...
Definition: ExpansibleBand.h:112
te::mem::ExpansibleBand::ExpansibleBand
ExpansibleBand()
te::mem::ExpansibleBand::m_blkWidth
unsigned int m_blkWidth
Block width in pixels(for pixel access optimization purposes).
Definition: ExpansibleBand.h:105
te::mem::ExpansibleBand::m_setGetBlkY
unsigned int m_setGetBlkY
Definition: ExpansibleBand.h:118
te::mem::ExpansibleBand::read
void * read(int x, int y)
It reads and returns a data block.
Definition: ExpansibleBand.h:86
te::mem::ExpansibleBand::m_parentRasterPtr
te::rst::Raster * m_parentRasterPtr
The parent raster ponter.
Definition: ExpansibleBand.h:103
te::mem::ExpansibleBand::read
void read(int x, int y, void *buffer) const
It reads a data block to the specified buffer.
te::mem::ExpansibleBand::~ExpansibleBand
~ExpansibleBand()
te::mem::ExpansibleBand::getValue
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
te::mem::ExpansibleBandBlocksManager
RAM cached and tiled raster band blocks manager.
Definition: ExpansibleBandBlocksManager.h:54
te::mem::ExpansibleBand::m_setGetPos
unsigned int m_setGetPos
Definition: ExpansibleBand.h:119
te::mem::ExpansibleBand::m_setGetBufPtr
void * m_setGetBufPtr
Definition: ExpansibleBand.h:120
te::mem::ExpansibleBand::setValue
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
te::mem::ExpansibleBand::getIValue
void getIValue(unsigned int c, unsigned int r, double &value) const
Returns the imaginary attribute value in a complex band of a cell.
te::rst::BandProperty
A raster band description.
Definition: BandProperty.h:62
TEMEMORYEXPORT
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:84
te::mem::ExpansibleBand::setIValue
void setIValue(unsigned int c, unsigned int r, const double value)
Sets the imaginary attribute value in a complex band of a cell.
te::mem::ExpansibleBand
Expansible raster band.
Definition: ExpansibleBand.h:55
te::mem::ExpansibleBand::m_blkSizeBytes
unsigned int m_blkSizeBytes
Blosk size bytes (for pixel access optimization purposes).
Definition: ExpansibleBand.h:109
te::mem::ExpansibleBand::write
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::rst::GetBufferValueFPtr
void(* GetBufferValueFPtr)(int index, void *buffer, double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:37
te::mem::ExpansibleBand::m_setGetBlkX
unsigned int m_setGetBlkX
Definition: ExpansibleBand.h:117
te::mem::ExpansibleBand::m_setBuffI
te::rst::SetBufferValueFPtr m_setBuffI
A pointer to a function that helps to insert the imaginary part value into a specific buffer data typ...
Definition: ExpansibleBand.h:114
te::mem::ExpansibleBand::ExpansibleBand
ExpansibleBand(ExpansibleBandBlocksManager &blocksManager, te::rst::Raster &parentRaster, const te::rst::BandProperty &bandProperty, std::size_t idx)
Constructor.
te::mem::ExpansibleBand::m_getBuff
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...
Definition: ExpansibleBand.h:111
te::mem::ExpansibleBand::m_blkHeight
unsigned int m_blkHeight
Block width in pixels (for pixel access optimization purposes).
Definition: ExpansibleBand.h:107