Jpp
17.1.0
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
JEnumeration.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
6
#include "
JLang/JTypeList.hh
"
7
#include "
JLang/JTypeID.hh
"
8
#include "
JLang/JEnumeration.hh
"
9
#include "
JROOT/JRootLabel.hh
"
10
11
#include "
JDAQ/JDAQTimesliceIO.hh
"
12
13
#include "
Jeep/JParser.hh
"
14
#include "
Jeep/JMessage.hh
"
15
16
17
template
<>
struct
JTypeID
<int> :
public
JLabel
<1> {};
18
template
<>
struct
JTypeID
<long int> :
public
JLabel
<1> {};
// will give compile error if also included in type list
19
template
<>
struct
JTypeID
<std::string> :
public
JLabel
<2> {};
20
template
<>
struct
JTypeID
<double> :
public
JLabel
<3> {};
21
22
23
struct
__A__;
// user class without ID; requires specialisation of class JTypeID.
24
25
template
<>
struct
JTypeID
<__A__> :
public
JLabel
<4> {};
26
27
28
struct
__B__ {
// user class with ID; does not require specialisation of class JTypeID.
29
30
static
const
int
ID
= 9;
31
32
static
const
char
*
getName
() {
return
"__B__"
; }
// optional name
33
static
int
getVersion
() {
return
123; }
// optional version
34
};
35
36
37
template
<>
// template specialisation for class with ROOT dictionary
38
struct
JTypeID
<KM3NETDAQ::
JDAQTimeslice
> :
39
public
JROOT::JRootLabel
<11, KM3NETDAQ::JDAQTimeslice>
40
{};
41
42
43
#define PRINT(OUT, ENUMERATION, CLASS) \
44
OUT << setw(10) << left << #CLASS << " --> " << ENUMERATION.getLabel(JLANG::JType<CLASS>()).getID() << endl;
45
46
47
/**
48
* \file
49
*
50
* Example program to test JLANG::JEnumeration class.
51
* \author mdejong
52
*/
53
int
main
(
int
argc,
char
**argv)
54
{
55
using namespace
std;
56
57
int
debug
;
58
59
try
{
60
61
JParser<>
zap(
"Example program to test class enumeration."
);
62
63
zap[
'd'
] =
make_field
(
debug
) = 0;
64
65
zap(argc, argv);
66
}
67
catch
(
const
exception &error) {
68
FATAL
(error.what() << endl);
69
}
70
71
72
using namespace
JPP;
73
74
75
typedef
76
JTypeList
<int,
77
JTypeList
<__A__,
78
JTypeList
<__B__,
79
JTypeList
<
KM3NETDAQ::JDAQTimeslice
,
80
JTypeList
<std::string,
81
JTypeList<double>
> > > > > JTypelist_t;
82
83
84
const
JEnumeration<JTypelist_t>
enumeration;
85
86
87
enumeration.
print
(cout);
88
89
PRINT
(cout, enumeration,
int
);
90
PRINT
(cout, enumeration, __B__);
91
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JEnumeration.hh
JTypeID
Template definition of policy class to label data types in a type list.
Definition:
JTypeID.hh:194
__B__::getName
static const char * getName()
Definition:
JEnumeration.cc:32
JLANG::JEnumeration
Enumeration of single data type.
Definition:
JEnumeration.hh:46
JTypeID.hh
JTypeList.hh
JROOT::JRootLabel
Replica of structure JLANG::JLabel for data types with ROOT I/O.
Definition:
JRootLabel.hh:20
JLANG::JTypeList
Type list.
Definition:
JTypeList.hh:22
JLabel
Auxiliary data structure to label data types within a type list.
Definition:
JTypeID.hh:141
__B__::getVersion
static int getVersion()
Definition:
JEnumeration.cc:33
JRootLabel.hh
ID
Definition:
raw_data_converter.cpp:43
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
KM3NETDAQ::JDAQTimeslice
Data time slice.
Definition:
JDAQTimeslice.hh:30
debug
int debug
debug level
Definition:
JSirene.cc:67
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
JLANG::JEnumeration::print
static std::ostream & print(std::ostream &out)
Print enumeration.
Definition:
JEnumeration.hh:80
JDAQTimesliceIO.hh
PRINT
#define PRINT(OUT, ENUMERATION, CLASS)
Definition:
JEnumeration.cc:43
Generated by
1.8.5