rasdaman client API 10.6.3
The Array Analytics Engine: Datacubes at Your Fingertips
banditerator.hh
Go to the documentation of this file.
1/*
2* This file is part of rasdaman community.
3*
4* Rasdaman community is free software: you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation, either version 3 of the License, or
7* (at your option) any later version.
8*
9* Rasdaman community is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16*
17* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18rasdaman GmbH.
19*
20* For more information please see <http://www.rasdaman.org>
21* or contact Peter Baumann via <baumann@rasdaman.com>.
22*/
23
24#ifndef _BAND_ITERATOR_
25#define _BAND_ITERATOR_
26
27#include "raslib/mddtypes.hh"
28#include <assert.h>
29
30class r_Base_Type;
31
32//@ManMemo: Module: {\bf raslib}
33
47{
48public:
54 r_Band_Iterator(const char *_data, const r_Base_Type *_type, r_Bytes _size,
55 unsigned int _band, r_Band_Linearization _bandLinearization);
56
58 virtual ~r_Band_Iterator() = default;
59
62 bool done() const
63 {
64 return currCell == dataEnd;
65 }
66
69 void advance()
70 {
71 assert(currCell != dataEnd);
73 }
74
77 void advance(r_Bytes cellCount)
78 {
79 assert(currCell + (cellSize * cellCount) <= dataEnd);
80 currCell += (cellSize * cellCount);
81 }
82
86 const char *get()
87 {
88 assert(currCell != dataEnd);
89 return currCell;
90 }
91
95 const char *get(r_Bytes targetCell)
96 {
97 assert(targetCell < size);
98 return (data + bandOffset) + (targetCell * cellSize);
99 }
100
101 void reset()
102 {
104 }
105
108 void copyBand(char *__restrict__ dst);
109
112
113protected:
115 const char *data{NULL};
116
118 const char *currCell{NULL};
119
121 const char *dataEnd{NULL};
122
124 const r_Base_Type *type{NULL};
125
128
131
133 unsigned int band{};
134
136 unsigned int cellBandSize{};
137
139 unsigned int cellSize{1};
140
143};
144
145#endif
This class abstracts away iteration over the cells of a (multi-band) array.
Definition banditerator.hh:47
r_Band_Iterator(const char *_data, const r_Base_Type *_type, r_Bytes _size, unsigned int _band, r_Band_Linearization _bandLinearization)
virtual ~r_Band_Iterator()=default
destructor
const char * data
array data
Definition banditerator.hh:115
const char * currCell
current cell in the array to be returned by dereferencing the iterator
Definition banditerator.hh:118
const r_Base_Type * type
array cell type
Definition banditerator.hh:124
void advance()
Move to the next band cell.
Definition banditerator.hh:69
r_Bytes size
array size in number of cells
Definition banditerator.hh:127
void advance(r_Bytes cellCount)
Move by cellCount cells in the band.
Definition banditerator.hh:77
const char * dataEnd
end of data = data + (size * cellSize)
Definition banditerator.hh:121
unsigned int band
the band to be iterated
Definition banditerator.hh:133
const char * get()
Definition banditerator.hh:86
unsigned int cellSize
full cell size in bytes
Definition banditerator.hh:139
void reset()
Definition banditerator.hh:101
r_Bytes bandOffset
offset in bytes to the first cell in data of the iterated band
Definition banditerator.hh:130
void copyBand(char *__restrict__ dst)
Copy the band data to the given dst pointer; dst must not be null, and must be sufficiently large (us...
bool done() const
Definition banditerator.hh:62
r_Band_Linearization bandLinearization
band linearization (pixel/channel)
Definition banditerator.hh:142
r_Bytes getBandSize() const
Return the size of band data in bytes.
const char * get(r_Bytes targetCell)
Definition banditerator.hh:95
unsigned int cellBandSize
size of the band component of one cell in bytes
Definition banditerator.hh:136
This class is the superclass of the types r_Structure_Type and r_Primitive_Type in the representation...
Definition basetype.hh:40
r_Band_Linearization
Indicate how multiband data is linearized in 1D space.
Definition mddtypes.hh:398
@ PixelInterleaved
The components of each pixel are layed out one after another, e.g.
size_t r_Bytes
number of bytes in an tile or mdd or type.
Definition mddtypes.hh:43