Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JBaseClass.hh
Go to the documentation of this file.
1#ifndef __JLANG__JBASECLASS__
2#define __JLANG__JBASECLASS__
3
5#include "JLang/JTypeList.hh"
6
7/**
8 * \file
9 *
10 * Auxiliary class to identify common base class in type list.
11 * \author mdejong
12 */
13namespace JLANG {}
14namespace JPP { using namespace JLANG; }
15
16namespace JLANG {
17
18 /**
19 * Template class to test for polymorphism.
20 */
21 template<class JBase_t, class JDerived_t>
22 struct JBaseType_t {
23 static const bool is_base = (JConversion<JDerived_t, JBase_t>::is_derived); //!< true if JBase_t is a base class of JDerived_t; else false
24 };
25
26
27 /**
28 * Template class to test for polymorphism.
29 *
30 * The class recursively tests whether both
31 * - JBaseType<JBase_t, JHead_t>::is_base; and
32 * - JBaseType<JBase_t, JTail_t>::is_base
33 * evaluate to true.
34 */
35 template<class JBase_t, class JHead_t, class JTail_t>
36 struct JBaseType_t< JBase_t, JTypeList<JHead_t, JTail_t> >
37 {
40 };
41
42
43 /**
44 * Terminator class of recursive JBaseType_t class.
45 */
46 template<class JBase_t, class JHead_t>
47 struct JBaseType_t< JBase_t, JTypeList<JHead_t, JNullType> >
48 {
50 };
51
52
53 /**
54 * Template class to identify common base class.
55 *
56 * The parameter data_type corresponds to the common base class.
57 */
58 template<class JBase_t, // assumed base class
59 class JHead_t, // upstream type list
60 class JTail_t, // downstream type list
63 struct JBaseType
64 {
65 typedef JBase_t data_type;
66 };
67
68
69 /**
70 * Resursive scan for base class.
71 */
72 template<class JBase_t, // assumed base class
73 class JTypelist_t, // upstream type list
74 class JHead_t, // upstream data type of downstream type list
75 class JTail_t> // downstream data type of downstream type list
76 struct JBaseType<JBase_t, JTypelist_t, JTypeList<JHead_t, JTail_t>, false>
77 {
79 };
80
81
82 /**
83 * Terminination class of resursive JBaseType class.
84 */
85 template<class JBase_t, // assumed base class
86 class JTypelist_t, // upstream type list
87 class JHead_t> // upstream data type of downstream type list
88 struct JBaseType<JBase_t, JTypelist_t, JTypeList<JHead_t, JNullType>, false>
89 {
91 };
92
93
94 /**
95 * Template definition of class to look for base class in type list.
96 *
97 * The type of the base class is defined as data_type.
98 */
99 template<class T>
100 struct JBaseClass {
101 typedef T data_type;
102 };
103
104
105 /**
106 * Template specialisation of class to look for base class in type list.
107 */
108 template<class JHead_t, class JTail_t>
109 struct JBaseClass< JTypeList<JHead_t, JTail_t> >
110 {
112 };
113}
114
115#endif
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JBaseType< JHead_t, JHead_t, JTail_t >::data_type data_type
Template definition of class to look for base class in type list.
JBaseType< JHead_t, JTypelist_t, JHead_t >::data_type data_type
Definition JBaseClass.hh:90
JBaseType< JHead_t, JTypeList< JTypelist_t, JHead_t >, JTail_t >::data_type data_type
Definition JBaseClass.hh:78
Template class to test for polymorphism.
Definition JBaseClass.hh:22
static const bool is_base
true if JBase_t is a base class of JDerived_t; else false
Definition JBaseClass.hh:23
Template class to identify common base class.
Definition JBaseClass.hh:64
Template class test for polymorphism.
Auxiliary class for no type definition.
Definition JNullType.hh:19
Type list.
Definition JTypeList.hh:23