rasdaman API
miterd.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 /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
31 #ifndef _R_MITERD_
32 #define _R_MITERD_
33 
34 #include "raslib/mddtypes.hh"
35 #include "raslib/odmgtypes.hh"
36 
37 #include <iosfwd>
38 
39 class r_Minterval;
40 
41 class r_miter_direct_data;
42 
43 //@ManMemo: Module {\bf raslib}
44 
45 /*@Doc:
46  r_MiterDirect is similar to r_Miter, but allows stepping by more
47  than one cell in each direction, arbitrary order of dimensions in
48  the iteration and has a lot of its internal state variables as public
49  members.
50  It should be used in low-level, very time-critical code like
51  folding operations which would otherwise require construction
52  of a new iterator for each cell when only position and base
53  address need to change.
54 */
55 
57 {
58 public:
60  r_MiterDirect(void *data, const r_Minterval &total, const r_Minterval &iter,
61  r_Bytes tlen, unsigned int step=1);
68  ~r_MiterDirect(void);
70 
72  inline r_MiterDirect &operator++(void);
74  inline r_MiterDirect &iterateUserOrder(const r_Dimension *order, const unsigned int *step);
82  inline r_MiterDirect &iterateUserOrder(const unsigned int *order, const int *step);
88  inline bool isDone(void) const;
91  inline void* getData(void);
93  inline void* getData(unsigned int *order);
98  inline r_Range getDimStep(r_Dimension d) const;
101  inline r_Bytes getDimBaseStep(r_Dimension d) const;
103  inline r_Range getExtent(r_Dimension d) const;
105  inline void posChanged( void );
107  void reset(void);
109  void print_pos(std::ostream &str) const;
110 
111  bool done;
113  void* baseAddress;
114 
115 private:
116 
119  r_Dimension dim;
120  r_ULong length;
121 };
122 
123 
124 
125 /*@Doc:
126  r_miter_direct_data encapsulates data for each dimension.
127  It's an auxiliary class for r_MiterDirect. The only reason
128  not to make it a simple struct was data protection.
129  */
130 
132 {
133  friend class r_MiterDirect;
134 
135 public:
136 
139 
142  void *data;
146 
147 private:
148 
151  r_Range step;
152  r_Range baseStep;
153  r_Range extent;
154  r_Range origin;
155 };
156 
157 
159 extern std::ostream &operator<<(std::ostream &str, const r_MiterDirect &iter);
160 
161 
162 
163 #include "raslib/miterd.icc"
164 
165 #endif
r_MiterDirect & operator++(void)
increment the iterator in the default order, i.e. last dimension first
Definition: miterd.hh:56
r_Bytes getDimBaseStep(r_Dimension d) const
returns number of bytes to step in dimension d when pos changes by 1.
r_Range getDimStep(r_Dimension d) const
returns number of bytes to step in dimension d in one iteration
unsigned int r_ULong
Definition: odmgtypes.hh:114
void * baseAddress
Definition: miterd.hh:113
int r_Range
Definition: mddtypes.hh:100
void * data
Data concerning the iteration position and domain. May be changed by the user.
Definition: miterd.hh:142
unsigned int r_Dimension
Definition: mddtypes.hh:118
r_MiterDirect & iterateUserOrder(const r_Dimension *order, const unsigned int *step)
increment in user-specified order
Definition: miterd.hh:131
void * getData(void)
returns pointer to data during normal iteration.
std::ostream & operator<<(std::ostream &str, const r_MiterDirect &iter)
overloaded stream operator
void reset(void)
reset the iterator (pos to low and data to baseAddress + offset)
r_Range low
Definition: miterd.hh:144
bool isDone(void) const
returns != 0 if iteration is finished.
r_MiterDirect(void *data, const r_Minterval &total, const r_Minterval &iter, r_Bytes tlen, unsigned int step=1)
constructor
unsigned int r_Bytes
Definition: mddtypes.hh:56
~r_MiterDirect(void)
destructor
r_Range high
Definition: miterd.hh:145
r_miter_direct_data * id
Definition: miterd.hh:112
void posChanged(void)
notify that the position was changed and internal variables need to be recalculated ...
bool done
Definition: miterd.hh:111
r_Range pos
Definition: miterd.hh:143
void print_pos(std::ostream &str) const
print the position
Definition: minterval.hh:249
r_Range getExtent(r_Dimension d) const
returns extent in dimension d