Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
core/other/var.cc
1 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 
31 
32 
33 #include <mln/core/image/image2d.hh>
34 #include <mln/core/alias/window2d.hh>
35 #include <mln/core/alias/neighb2d.hh>
36 #include <mln/histo/array.hh>
37 #include <mln/util/array.hh>
38 
39 #include <mln/core/var.hh>
40 
41 
42 
43 // mln_VAR is known not to work with old gcc versions. This test does
44 // nothing for these compilers.
45 //
46 #if (defined(__GNUC__) && __GNUC__ >= 4)
47 
48 template <typename T>
49 void test_template()
50 {
51  using namespace mln;
52 
53  image2d<T> ima(1,1);
55  window2d win;
56  {
57  mln_PITER(p, ima.domain());
58  mln_NITER(n, neighb, p);
59  mln_QITER(q, win, p);
60  }
61  {
62  mln_FWD_PITER(p, ima.domain());
63  mln_FWD_NITER(n, neighb, p);
64  mln_FWD_QITER(q, win, p);
65  }
66  {
67  mln_BKD_PITER(p, ima.domain());
68  mln_BKD_NITER(n, neighb, p);
69  mln_BKD_QITER(q, win, p);
70  }
71 
73  {
74  mln_EITER(e, arr);
75  }
76  {
77  mln_FWD_EITER(e, arr);
78  }
79  {
80  mln_BKD_EITER(e, arr);
81  }
82 
84  {
85  mln_VITER(v, d.vset());
86  }
87  {
88  mln_FWD_VITER(v, d.vset());
89  }
90  {
91  mln_BKD_VITER(v, d.vset());
92  }
93 
94 }
95 
96 void test()
97 {
98  using namespace mln;
99 
100  image2d<int> ima(1,1);
102  window2d win;
103  {
104  mln_PITER_(p, ima.domain());
105  mln_NITER_(n, neighb, p);
106  mln_QITER_(q, win, p);
107  }
108  {
109  mln_FWD_PITER_(p, ima.domain());
110  mln_FWD_NITER_(n, neighb, p);
111  mln_FWD_QITER_(q, win, p);
112  }
113  {
114  mln_BKD_PITER_(p, ima.domain());
115  mln_BKD_NITER_(n, neighb, p);
116  mln_BKD_QITER_(q, win, p);
117  }
118 
120  {
121  mln_EITER_(e, arr);
122  }
123  {
124  mln_FWD_EITER_(e, arr);
125  }
126  {
127  mln_BKD_EITER_(e, arr);
128  }
129 
131  {
132  mln_VITER_(v, d.vset());
133  }
134  {
135  mln_FWD_VITER_(v, d.vset());
136  }
137  {
138  mln_BKD_VITER_(v, d.vset());
139  }
140 }
141 
142 #endif
143 
144 int main()
145 {
146 
147 #if (defined(__GNUC__) && __GNUC__ >= 4)
148  test();
149  test_template<int>();
150 #endif
151 
152 }