Jpp
18.0.0-rc.2
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JBaseClass.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JLang/JBaseClass.hh
"
6
#include "
JLang/JTypeList.hh
"
7
8
#include "
Jeep/JParser.hh
"
9
#include "
Jeep/JMessage.hh
"
10
11
12
namespace
{
13
14
struct
__A__ {
15
static
char
get
() {
return
'A'
; }
16
};
17
18
struct
__B__ :
public
__A__ {
19
static
char
get
() {
return
'B'
; }
20
};
21
22
struct
__C__ :
public
__A__ {
23
static
char
get
() {
return
'C'
; }
24
};
25
26
struct
__D__ :
public
__A__ {
27
static
char
get
() {
return
'D'
; }
28
};
29
}
30
31
32
/**
33
* \file
34
*
35
* Example program to test JLANG::JBaseClass class.
36
* \author mdejong
37
*/
38
int
main
(
int
argc,
char
**argv)
39
{
40
using namespace
std;
41
42
int
debug
;
43
44
try
{
45
46
JParser<>
zap(
"Example program to test selection of base class."
);
47
48
zap[
'd'
] =
make_field
(
debug
) = 3;
49
50
zap(argc, argv);
51
}
52
catch
(
const
exception &error) {
53
FATAL
(error.what() << endl);
54
}
55
56
using namespace
JPP;
57
58
typedef
JTYPELIST<__A__,
59
__B__,
60
__C__,
61
__D__>::typelist typelistABCD;
62
63
typedef
JTYPELIST<__B__,
64
__A__,
65
__C__,
66
__D__>::typelist typelistBACD;
67
68
typedef
JTYPELIST<__B__,
69
__C__,
70
__A__,
71
__D__>::typelist typelistBCAD;
72
73
typedef
JTYPELIST<__B__,
74
__C__,
75
__D__,
76
__A__>::typelist typelistBCDA;
77
78
DEBUG
(
"A,B,C,D <- A? "
<< (JBaseType_t<__A__, typelistABCD>::is_base) << endl);
79
DEBUG
(
"A,B,C,D <- B? "
<< (JBaseType_t<__B__, typelistABCD>::is_base) << endl);
80
81
DEBUG
(
"A,B,C,D -> "
<<
JBaseClass<typelistABCD>::data_type::get
() << endl);
82
DEBUG
(
"B,A,C,D -> "
<<
JBaseClass<typelistBACD>::data_type::get
() << endl);
83
DEBUG
(
"B,C,A,D -> "
<<
JBaseClass<typelistBCAD>::data_type::get
() << endl);
84
DEBUG
(
"B,C,D,A -> "
<<
JBaseClass<typelistBCDA>::data_type::get
() << endl);
85
DEBUG
(
"B -> "
<< JBaseClass< JTypeList<__B__> >::
data_type::get
() << endl);
86
87
ASSERT
(
JBaseClass<typelistABCD>::data_type::get
() ==
__A__::get
());
88
ASSERT
(
JBaseClass<typelistBACD>::data_type::get
() ==
__A__::get
());
89
ASSERT
(
JBaseClass<typelistBCAD>::data_type::get
() ==
__A__::get
());
90
ASSERT
(
JBaseClass<typelistBCDA>::data_type::get
() ==
__A__::get
());
91
ASSERT
(JBaseClass< JTypeList<__B__> >::
data_type::get
() ==
__B__::get
());
92
/*
93
typedef JTYPELIST<__B__,
94
__C__,
95
__D__>::typelist typelist;
96
97
typedef JBaseClass<typelist>::data_type data_type; // will give compiler error (as should be)
98
*/
99
100
return
0;
101
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JAANET::get
T get(const JHead &header)
Get object from header.
Definition:
JHeadToolkit.hh:260
JBaseClass.hh
Auxiliary class to identify common base class in type list.
JTypeList.hh
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
Generated by
1.8.5