Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
solve.hh
1 // Copyright (C) 2006, 2007, 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_TRAIT_SOLVE_HH
27 # define MLN_TRAIT_SOLVE_HH
28 
37 # include <mln/core/category.hh>
38 # include <mln/metal/equal.hh>
39 # include <mln/metal/if.hh>
40 # include <mln/metal/ret.hh>
41 
42 
43 // FIXME: Just for the record (use it...)
44 
45 # ifndef MLN_DEBUG_TRAITS
46 # endif // ! MLN_DEBUG_TRAITS
47 
48 
49 # define mln_trait_unary(Name, T) typename mln::trait::solve_unary< Name, T >::ret
50 # define mln_trait_unary_(Name, T) mln::trait::solve_unary< Name, T >::ret
51 
52 # define mln_trait_binary(Name, T1, T2) typename mln::trait::solve_binary< Name, T1, T2 >::ret
53 # define mln_trait_binary_(Name, T1, T2) mln::trait::solve_binary< Name, T1, T2 >::ret
54 
55 
56 
57 namespace mln
58 {
59 
60  namespace trait
61  {
62 
64  struct not_found {};
65 
67  struct undefined {};
68 
70  struct multiply_defined {};
71 
72 
73 
74  // Unary case.
75 
76 
77  template < template <class> class Name,
78  typename T >
79  struct set_precise_unary_
80  {
81  typedef undefined ret;
82  };
83 
84 
85  template < template <class> class Name,
86  template <class> class Category_T, typename T >
87  struct set_unary_
88  {
89  typedef undefined ret;
90  };
91 
92  template < template <class> class Name,
93  typename T >
94  struct set_unary_< Name, Unknown, T > // Blocker; top of inheritance.
95  {
96  typedef not_found ret;
97  };
98 
99 
100 
101 
102  // Binary case.
103 
104 
105  template < template <class, class> class Name,
106  typename L,
107  typename R >
108  struct set_precise_binary_
109  {
110  typedef undefined ret;
111  };
112 
113 
114  template < template <class, class> class Name,
115  template <class> class Category_L, typename L,
116  template <class> class Category_R, typename R >
117  struct set_binary_
118  {
119  typedef undefined ret;
120  };
121 
122  template < template <class, class> class Name,
123  typename L,
124  template <class> class Category_R, typename R >
125  struct set_binary_< Name, Unknown, L, Category_R, R > // Left blocker.
126  {
127  typedef not_found ret;
128  };
129 
130  template < template <class, class> class Name,
131  template <class> class Category_L, typename L,
132  typename R >
133  struct set_binary_< Name, Category_L, L, Unknown, R > // Right blocker.
134  {
135  typedef not_found ret;
136  };
137 
138  template < template <class, class> class Name,
139  typename L,
140  typename R >
141  struct set_binary_< Name, Unknown, L, Unknown, R > // Blocker.
142  {
143  typedef not_found ret;
144  };
145 
146 
147  } // end of namespace mln::trait
148 
149 } // end of namespace mln
150 
151 
152 # include <mln/trait/solve_unary.hh>
153 # include <mln/trait/solve_binary.hh>
154 
155 
156 #endif // ! MLN_TRAIT_SOLVE_HH