OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
index.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 /*
22  value holder index
23 
24  Author: Ansgar Philippsen
25 */
26 
27 #ifndef IMG_INDEX_H
28 #define IMG_INDEX_H
29 
30 #include <iosfwd>
31 
32 #include <ost/base.hh>
33 #include <ost/img/size.hh>
34 
35 namespace ost { namespace img { namespace image_state {
36 
37 // encapsulated unsigned integer triplet
38 /*
39  provides a compact mean to adress values in a ValueHolder
40 */
42  Index(unsigned int uu,unsigned int vv, unsigned int ww);
43 
44  bool equal(const Index& i) const;
45 
46  unsigned int u,v,w;
47 };
48 
49 DLLEXPORT_OST_IMG_BASE bool operator==(const Index& i1, const Index& i2);
50 DLLEXPORT_OST_IMG_BASE bool operator!=(const Index& i1, const Index& i2);
51 
52 DLLEXPORT_OST_IMG_BASE std::ostream& operator<<(std::ostream& out, const Index& i);
53 
55 public:
56  IndexIterator(int w, int h, int d);
57  IndexIterator(const Size& s);
58 
59  bool AtStart() const;
60  bool AtEnd() const;
61 
62  IndexIterator& ToStart();
63  IndexIterator& ToEnd();
64 
65  // prefix
66  IndexIterator& operator++();
67  // postfix
68  IndexIterator operator++(int);
69  // prefix
70  IndexIterator& operator--();
71  // postfix
72  IndexIterator operator--(int);
73 
74  operator Index() const;
75 private:
76  unsigned int w_,h_,d_;
77  Index indx_;
78  bool at_end_;
79 
80  void increment();
81  void decrement();
82 };
83 
84 }}} // namespaces
85 
86 #endif