uLib-0.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
StaticInterface.h
Go to the documentation of this file.
1 /*//////////////////////////////////////////////////////////////////////////////
2 // CMT Cosmic Muon Tomography project //////////////////////////////////////////
4 
5  Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
6  All rights reserved
7 
8  Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
9 
10  ------------------------------------------------------------------
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library.
23 
25 
26 
27 
28 #ifndef U_CORE_STATICINTERFACE_H
29 #define U_CORE_STATICINTERFACE_H
30 
31 namespace uLib {
32 
33 #define MAKE_TRAITS ; // TODO
34 
35 #define uLibCheckFunction(class_name,name,out, ... ) \
36 { out (class_name::*x)(__VA_ARGS__) = &class_name::name; (void) x; }
37 
38 #define uLibCheckConstFunction(class_name,name,out,...) \
39 { out (class_name::*x)(__VA_ARGS__) const = &class_name::name; (void) x; }
40 
41 #define uLibCheckMember(class_name,name,type) \
42 { class_name x; type *y = &x.name; (void) y; }
43 
44 
45 namespace Interface {
46 
47 // EXAMPLE :
48 //template <class T> struct Voxel {
49 // MAKE_TRAITS;
50 // template<class Self> void check_structural() {
51 // { float & (Self::*x)() = &Self::Density; (void) x; }
52 // { int & (Self::*x)() = &Self::TrackCount; (void) x; }
53 // }
54 //protected:
55 // ~Voxel() {}
56 //};
57 
58 template <class T, class SI>
59 static inline void IsA() {
60  (void) ((void (SI::*)()) &SI::template check_structural<T>);
61 }
62 
63 // not working
64 //template <class T, class SI>
65 //struct StaticIsA {
66 // void test() {
67 // static const void (SI::*x)() = SI::template check_structural<T>;
68 // }
69 //};
70 
71 }
72 
73 
74 
75 }
76 
77 #endif // STATICINTERFACE_H