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  u(uu),v(vv),w(ww)
44  {}
45 
46  bool equal(const Index& i) const;
47 
48  unsigned int u,v,w;
49 };
50 
51 DLLEXPORT_OST_IMG_BASE bool operator==(const Index& i1, const Index& i2);
52 DLLEXPORT_OST_IMG_BASE bool operator!=(const Index& i1, const Index& i2);
53 
54 DLLEXPORT_OST_IMG_BASE std::ostream& operator<<(std::ostream& out, const Index& i);
55 
57 public:
58  IndexIterator(int w, int h, int d);
59  IndexIterator(const Size& s);
60 
61  bool AtStart() const;
62  bool AtEnd() const;
63 
64  IndexIterator& ToStart();
65  IndexIterator& ToEnd();
66 
67  // prefix
68  IndexIterator& operator++();
69  // postfix
70  IndexIterator operator++(int);
71  // prefix
72  IndexIterator& operator--();
73  // postfix
74  IndexIterator operator--(int);
75 
76  operator Index() const;
77 private:
78  unsigned int w_,h_,d_;
79  Index indx_;
80  bool at_end_;
81 
82  void increment();
83  void decrement();
84 };
85 
86 }}} // namespaces
87 
88 #endif