$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
yes.hh
1 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena 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 GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef MLN_UTIL_YES_HH
27 # define MLN_UTIL_YES_HH
28 
32 
33 
34 # include <mln/core/concept/object.hh>
35 # include <mln/core/routine/ops.hh>
36 
37 
38 namespace mln
39 {
40 
41  // Forward declaration.
42  namespace util { struct yes; }
43 
44 
45  namespace trait
46  {
47 
48  template <>
49  struct set_precise_unary_< op::not_, util::yes >
50  {
51  typedef util::yes ret;
52  };
53 
54  template <template<class, class> class Op>
55  struct set_precise_binary_< Op, util::yes, bool >
56  {
57  typedef util::yes ret;
58  };
59 
60  template <template<class, class> class Op>
61  struct set_precise_binary_< Op, util::yes, util::yes >
62  {
63  typedef util::yes ret;
64  };
65 
66  } // end of namespace mln::trait
67 
68 
69  namespace util
70  {
71 
75  //
76  struct yes : public Object< yes >
77  {
78  yes();
79  explicit yes(bool);
80  operator bool() const;
81  };
82 
83  } // end of namespace mln::util
84 
85 
86  // Negate.
88 
89  // Equal.
90  util::yes operator == (const util::yes&, bool);
91  util::yes operator == (const util::yes&, const util::yes&);
92 
93  // Not equal.
94  util::yes operator != (const util::yes&, bool);
95  util::yes operator != (const util::yes&, const util::yes&);
96 
97  // And.
98  util::yes operator && (const util::yes&, bool);
99 
100  // Or.
101  util::yes operator || (const util::yes&, bool);
102 
103 
104  // FIXME: Is-it suffisiant?
105 
106 
107 # ifndef MLN_INCLUDE_ONLY
108 
109  namespace util
110  {
111 
112  // yes
113 
114  inline
115  yes::yes()
116  {
117  }
118 
119  inline
120  yes::yes(bool)
121  {
122  }
123 
124  inline
125  yes::operator bool() const
126  {
127  return true;
128  }
129 
130  } // end of namespace mln::util
131 
132  inline
133  util::yes
134  operator ! (const util::yes& y)
135  {
136  return y;
137  }
138 
139  inline
140  util::yes operator == (const util::yes&, bool)
141  {
142  return util::yes(true);
143  }
144 
145  inline
146  util::yes operator == (const util::yes&, const util::yes&)
147  {
148  return util::yes(true);
149  }
150 
151  inline
152  util::yes operator != (const util::yes&, bool)
153  {
154  return util::yes(true);
155  }
156 
157  inline
158  util::yes operator != (const util::yes&, const util::yes&)
159  {
160  return util::yes(true);
161  }
162 
163  inline
164  util::yes operator && (const util::yes&, bool)
165  {
166  return util::yes(true);
167  }
168 
169  inline
170  util::yes operator || (const util::yes&, bool)
171  {
172  return util::yes(true);
173  }
174 
175 # endif // ! MLN_INCLUDE_ONLY
176 
177 } // end of namespace mln
178 
179 
180 #endif // ! MLN_UTIL_YES_HH