Loading...
Searching...
No Matches
CachedBand.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/CachedBand.h
22
23 \brief RAM cached and tiled raster band.
24*/
25
26#ifndef __TERRALIB_MEMORY_INTERNAL_CACHEDBAND_H
27#define __TERRALIB_MEMORY_INTERNAL_CACHEDBAND_H
28
29// TerraLib
30#include "../raster/Band.h"
31#include "../raster/BlockUtils.h"
32#include "Config.h"
34
35// STL
36#include <cassert>
37#include <cstddef>
38
39// Boost
40#include <boost/noncopyable.hpp>
41
42namespace te
43{
44 namespace mem
45 {
46 /*!
47 \class CachedBand
48
49 \brief RAM cached and tiled raster band.
50
51 \details A cache adaptor to an external existent raster band that must always be avaliable.
52 */
53 class TEMEMORYEXPORT CachedBand : public te::rst::Band, public boost::noncopyable
54 {
55 public:
56
57 /*!
58 \brief Constructor.
59
60 \param blocksManager The blocks manager where to read/write data.
61 \param idx The band index.
62 */
63 CachedBand( CachedBandBlocksManager& blocksManager, std::size_t idx );
64
66
67 inline te::rst::Raster* getRaster() const
68 {
69 return m_blocksManager.getRaster();
70 };
71
72 void getValue(unsigned int c, unsigned int r, double& value) const;
73
74 void setValue(unsigned int c, unsigned int r, const double value);
75
76 void getIValue(unsigned int c, unsigned int r, double& value) const;
77
78 void setIValue(unsigned int c, unsigned int r, const double value);
79
80 void read(int x, int y, void* buffer) const;
81
82 void* read(int x, int y)
83 {
84 assert( m_blocksManager.isInitialized() );
85 return m_blocksManager.getBlockPointer( (unsigned int)m_idx,
86 (unsigned int)x, (unsigned int)y );
87 };
88
89 void write(int x, int y, void* buffer);
90
91 private:
92
94
95 protected :
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 CachedBandBlocksManager& m_blocksManager; //!< The external blocks manager reference.
113
114 static CachedBandBlocksManager dummyBlocksManager; //!< A global static dummy blocks manager.
115 };
116
117 } // end namespace mem
118} // end namespace te
119
120#endif // __TERRALIB_MEMORY_INTERNAL_CACHEDBAND_H
RAM cached and tiled raster band blocks manager.
RAM cached and tiled raster band blocks manager.
RAM cached and tiled raster band.
Definition: CachedBand.h:54
unsigned int m_setGetPos
Definition: CachedBand.h:109
void read(int x, int y, void *buffer) const
It reads a data block to the specified buffer.
unsigned int m_blkSizeBytes
The blocks size (bytes);.
Definition: CachedBand.h:99
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: CachedBand.h:104
void setValue(unsigned int c, unsigned int r, const double value)
Sets the cell attribute value.
static CachedBandBlocksManager dummyBlocksManager
A global static dummy blocks manager.
Definition: CachedBand.h:114
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: CachedBand.h:103
CachedBandBlocksManager & m_blocksManager
The external blocks manager reference.
Definition: CachedBand.h:112
void write(int x, int y, void *buffer)
It writes a data block from the specified buffer.
CachedBand(CachedBandBlocksManager &blocksManager, std::size_t idx)
Constructor.
void getValue(unsigned int c, unsigned int r, double &value) const
Returns the cell attribute value.
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::Raster * getRaster() const
Returns the associated raster.
Definition: CachedBand.h:67
void * read(int x, int y)
It reads and returns a data block.
Definition: CachedBand.h:82
unsigned int m_blkHeight
The current band blocks height.
Definition: CachedBand.h:98
unsigned int m_setGetBlkY
Definition: CachedBand.h:108
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
The current band blocks width.
Definition: CachedBand.h:97
unsigned int m_setGetBlkX
Definition: CachedBand.h:107
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: CachedBand.h:101
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: CachedBand.h:102
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).