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 
56 class r_MiterDirect
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;
112  r_miter_direct_data* id;
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 
131 class r_miter_direct_data
132 {
133  friend class r_MiterDirect;
134 
135 public:
136 
137  r_miter_direct_data();
138  ~r_miter_direct_data();
139 
142  void *data;
143  r_Range pos;
144  r_Range low;
145  r_Range high;
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
std::ostream & operator<<(std::ostream &os, const std::vector< T > &list)