Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JClass.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <vector>
4
5#include "JLang/JClass.hh"
6
7#include "Jeep/JParser.hh"
8#include "Jeep/JMessage.hh"
9
10
11namespace {
12
13 struct __A__ {};
14
15 /**
16 * Print class parameters.
17 *
18 * \param out output stream
19 * \param name name of class
20 */
21 template<class T>
22 inline void print(std::ostream& out, const char* name)
23 {
24 using namespace std;
25 using namespace JPP;
26
27 out << setw(36) << left << name;
28 out << setw(4) << '.' << setw(8) << left << JClass<T>::is_primitive;
29 out << setw(4) << '.' << setw(8) << left << JClass<T>::is_pointer;
30 out << setw(4) << '.' << setw(8) << left << JClass<T>::is_reference;
31 out << setw(4) << '.' << setw(8) << left << JClass<T>::is_constant;
32 out << endl;
33 }
34}
35
36
37/**
38 * Print class parameters.
39 *
40 * \param OUT output stream
41 * \param T class
42 */
43#define PRINT(OUT, T) print<T>(OUT, #T)
44
45
46/**
47 * \file
48 *
49 * Example program to test JLANG::JClass class.
50 * \author mdejong
51 */
52int main(int argc, char **argv)
53{
54 using namespace std;
55 using namespace JPP;
56
57 int debug;
58
59 try {
60
61 JParser<> zap("Example program to test class inspection.");
62
63 zap['d'] = make_field(debug) = 3;
64
65 zap(argc, argv);
66 }
67 catch(const exception &error) {
68 FATAL(error.what() << endl);
69 }
70
71 if (debug >= debug_t) {
72
73 cout << setw(36) << left << "name";
74 cout << setw(12) << "primitive";
75 cout << setw(12) << " pointer";
76 cout << setw(12) << "reference";
77 cout << setw(12) << "constant";
78 cout << endl;
79
80 cout << setfill('.');
81
82 PRINT(cout, int);
83 PRINT(cout, int&);
84 PRINT(cout, const int*);
85 PRINT(cout, __A__);
86
89 }
90
95
100
105
110
113
117
119 ASSERT(is_iterator<vector<__A__>::const_iterator>::value == true);
121 ASSERT(is_iterator<vector<__A__>::const_reverse_iterator>::value == true);
122
123 return 0;
124}
int main(int argc, char **argv)
Definition JClass.cc:52
#define PRINT(OUT, T)
Print class parameters.
Definition JClass.cc:43
General purpose messaging.
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Template for generic class types.
Definition JClass.hh:80
JArgument< T >::argument_type argument_type
Definition JClass.hh:82
Data structure to check whether given data type is an iterator.
Definition JClass.hh:62