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  */
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 
89 
90  protected :
91 
92  static SynchronizedBandBlocksManager dummyBlocksManager; //!< A global static dummy blocks manager.
93 
94  SynchronizedBandBlocksManager& m_blocksManager; //!< The external blocks manager.
95 
96  SynchronizedRaster* m_syncRasterPtr; //!< The synchronized raster instance (parent raster).
97 
98  unsigned int m_blkWidth; //!< The current band blocks width
99  unsigned int m_blkHeight; //!< The current band blocks height
100  unsigned int m_blkSizeBytes; //!< The blocks size (bytes);
101 
102  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, ...).
103  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).
104  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, ...).
105  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).
106 
107  // Variable used by setValue/getValue methods
108  mutable unsigned int m_setGetBlkX;
109  mutable unsigned int m_setGetBlkY;
110  mutable unsigned int m_setGetPos;
111  mutable void* m_setGetBufPtr;
112  };
113 
114  } // end namespace rst
115 } // end namespace te
116 
117 #endif // __TERRALIB_RASTER_INTERNAL_SYNCHRONIZEDBAND_H
te::rst::SynchronizedBand::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: SynchronizedBand.h:103
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rst::Band
A raster band description.
Definition: Band.h:64
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::rst::SynchronizedBand::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: SynchronizedBand.h:102
te::rst::SynchronizedBand::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: SynchronizedBand.h:105
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::rst::SynchronizedBand
Syncrhonized raster band.
Definition: SynchronizedBand.h:52
te::rst::SynchronizedBand::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: SynchronizedBand.h:104
Band.h
Band implementation for TerraLib 4.x.
te::rst::SynchronizedBand::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::SynchronizedBand::read
void * read(int x, int y)
It reads and returns a data block.
TERASTEREXPORT
#define TERASTEREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
te::rst::SynchronizedBand::m_blkHeight
unsigned int m_blkHeight
The current band blocks height.
Definition: SynchronizedBand.h:99
te::rst::SynchronizedBand::write
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
te::rst::SynchronizedBand::m_blkWidth
unsigned int m_blkWidth
The current band blocks width.
Definition: SynchronizedBand.h:98
SynchronizedBandBlocksManager.h
Synchronized raster raster band blocks manager.
te::rst::SynchronizedBand::setValue
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
te::rst::SynchronizedBand::getValue
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
te::rst::SynchronizedBand::SynchronizedBand
SynchronizedBand()
te::rst::SynchronizedBand::m_setGetBufPtr
void * m_setGetBufPtr
Definition: SynchronizedBand.h:111
te::rst::SynchronizedBand::~SynchronizedBand
~SynchronizedBand()
te::rst::SynchronizedBand::m_blkSizeBytes
unsigned int m_blkSizeBytes
The blocks size (bytes);.
Definition: SynchronizedBand.h:100
te::rst::SynchronizedBand::m_setGetPos
unsigned int m_setGetPos
Definition: SynchronizedBand.h:110
te::rst::SynchronizedBand::SynchronizedBand
SynchronizedBand(const SynchronizedBand &other)
te::rst::SynchronizedBand::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::rst::SynchronizedRaster
An adapter class to allow concurrent access to raster data by multiple threads.
Definition: SynchronizedRaster.h:52
te::rst::SynchronizedBandBlocksManager
Synchronized raster raster band blocks manager.
Definition: SynchronizedBandBlocksManager.h:48
te::rst::SynchronizedBand::dummyBlocksManager
static SynchronizedBandBlocksManager dummyBlocksManager
A global static dummy blocks manager.
Definition: SynchronizedBand.h:92
te::rst::SynchronizedBand::m_syncRasterPtr
SynchronizedRaster * m_syncRasterPtr
The synchronized raster instance (parent raster).
Definition: SynchronizedBand.h:96
te::rst::SynchronizedBand::m_blocksManager
SynchronizedBandBlocksManager & m_blocksManager
The external blocks manager.
Definition: SynchronizedBand.h:94
te::rst::SynchronizedBand::read
void read(int x, int y, void *buffer) const
It reads a data block to 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::rst::SynchronizedBand::getRaster
te::rst::Raster * getRaster() const
Returns the associated raster.
Definition: SynchronizedBand.h:66
te::rst::SynchronizedBand::m_setGetBlkX
unsigned int m_setGetBlkX
Definition: SynchronizedBand.h:108
BlockUtils.h
Utility functions for dealing with raster data blocks.
te::rst::SynchronizedBand::m_setGetBlkY
unsigned int m_setGetBlkY
Definition: SynchronizedBand.h:109
te::rst::SynchronizedBand::SynchronizedBand
SynchronizedBand(SynchronizedBandBlocksManager &blocksManager, SynchronizedRaster &raster, std::size_t idx)
Constructor.