SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
method_check.hpp
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2008,2009,2010,2011,2012 Stephan Ossowski, Korbinian Schneeberger,
4  * Felix Ott, Joerg Hagmann, Alf Scotland, Sebastian Bender
5  *
6  * This file is part of SHORE.
7  *
8  * SHORE is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * SHORE is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with SHORE. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
26 
27 #ifndef SHORE_PROCESSING_METHODCHECK_HPP__
28 #define SHORE_PROCESSING_METHODCHECK_HPP__
29 
30 namespace shore {
31 
32 class member_check_defs
33 {
34  private:
35 
36  class cannot_mix
37  {
38  char m;
39  };
40 
41  class can_mix
42  {
43  cannot_mix m[2];
44  };
45 
46  template<typename U, U t>
47  class instantiate_test
48  {};
49 
50  member_check_defs();
51 };
52 
54 
55 template<typename T>
56 class has_next
57 :member_check_defs
58 {
59  private:
60 
61  struct interference
62  {
63  void next()
64  {}
65  };
66 
67  struct mixed
68  :public T,public interference
69  {};
70 
71  template<typename U>
72  static can_mix deduce(U *,instantiate_test<void (interference::*)(),&U::next> * =0);
73 
74  static cannot_mix deduce(...);
75 
76  public:
77 
78  static const bool value = sizeof(cannot_mix) == sizeof(deduce((mixed*)(0)));
79 };
80 
81 template<typename T>
82 const bool has_next<T>::value;
83 
85 
86 template<typename T>
87 class has_prepare
88 :member_check_defs
89 {
90  private:
91 
92  struct interference
93  {
94  void prepare()
95  {}
96  };
97 
98  struct mixed
99  :public T,public interference
100  {};
101 
102  template<typename U>
103  static can_mix deduce(U *,instantiate_test<void (interference::*)(),&U::prepare> * =0);
104 
105  static cannot_mix deduce(...);
106 
107  public:
108 
109  static const bool value = sizeof(cannot_mix) == sizeof(deduce((mixed*)(0)));
110 };
111 
112 template<typename T>
113 const bool has_prepare<T>::value;
114 
116 
117 template<typename T>
118 class has_flush
119 :member_check_defs
120 {
121  private:
122 
123  struct interference
124  {
125  void flush()
126  {}
127  };
128 
129  struct mixed
130  :public T,public interference
131  {};
132 
133  template<typename U>
134  static can_mix deduce(U *,instantiate_test<void (interference::*)(),&U::flush> * =0);
135 
136  static cannot_mix deduce(...);
137 
138  public:
139 
140  static const bool value = sizeof(cannot_mix) == sizeof(deduce((mixed*)(0)));
141 };
142 
143 template<typename T>
144 const bool has_flush<T>::value;
145 
147 
148 template<typename T>
149 class has_get_name
150 :member_check_defs
151 {
152  private:
153 
154  struct interference
155  {
156  void get_name()
157  {}
158  };
159 
160  struct mixed
161  :public T,public interference
162  {};
163 
164  template<typename U>
165  static can_mix deduce(U *,instantiate_test<void (interference::*)(),&U::get_name> * =0);
166 
167  static cannot_mix deduce(...);
168 
169  public:
170 
171  static const bool value = sizeof(cannot_mix) == sizeof(deduce((mixed*)(0)));
172 };
173 
174 template<typename T>
175 const bool has_get_name<T>::value;
176 
178 
179 template<typename T>
180 class has_dump
181 :member_check_defs
182 {
183  private:
184 
185  struct interference
186  {
187  void dump()
188  {}
189  };
190 
191  struct mixed
192  :public T,public interference
193  {};
194 
195  template<typename U>
196  static can_mix deduce(U *,instantiate_test<void (interference::*)(),&U::dump> * =0);
197 
198  static cannot_mix deduce(...);
199 
200  public:
201 
202  static const bool value = sizeof(cannot_mix) == sizeof(deduce((mixed*)(0)));
203 };
204 
205 template<typename T>
206 const bool has_dump<T>::value;
207 
208 } // namespace shore
209 
210 #endif // SHORE_PROCESSING_METHODCHECK_HPP__
211