Jpp  master_rocky-43-ge265d140c
the software that should make you happy
JConversion.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JLang/JConversion.hh"
6 
7 #include "Jeep/JParser.hh"
8 #include "Jeep/JMessage.hh"
9 
10 
11 namespace {
12 
13  struct __A__ {};
14 
15  struct __B__ : public __A__ {};
16 
17  /**
18  * Print class parameters.
19  *
20  * \param out output stream
21  * \param uname name of class
22  * \param vname name of class
23  */
24  template<class U, class V>
25  inline void print(std::ostream& out, const char* uname, const char* vname)
26  {
27  using namespace std;
28  using namespace JPP;
29 
30  out << setw(36) << left << string("<") + string(uname) + string(",") + string(vname) + string(">");
31  out << setw(4) << '.' << setw(8) << left << JConversion<U, V>::is_same;
32  out << setw(4) << '.' << setw(8) << left << JConversion<U, V>::is_derived;
33  out << endl;
34  }
35 }
36 
37 
38 /**
39  * Print class parameters.
40  *
41  * \param OUT output stream
42  * \param U class
43  * \param V class
44  */
45 #define PRINT(OUT, U, V) print<U,V>(OUT, #U, #V)
46 
47 
48 /**
49  * \file
50  *
51  * Example program to test JLANG::JConversion class.
52  * \author mdejong
53  */
54 int main(int argc, char **argv)
55 {
56  using namespace std;
57  using namespace JPP;
58 
59  int debug;
60 
61  try {
62 
63  JParser<> zap("Example program to test class inspection.");
64 
65  zap['d'] = make_field(debug) = 3;
66 
67  zap(argc, argv);
68  }
69  catch(const exception &error) {
70  FATAL(error.what() << endl);
71  }
72 
73  if (debug >= debug_t) {
74 
75  cout << setw(36) << left << "name";
76  cout << setw(12) << " same ";
77  cout << setw(12) << " derived";
78  cout << endl;
79 
80  cout << setfill('.');
81 
82  PRINT(cout, __A__, __A__);
83  PRINT(cout, __B__, __A__);
84  PRINT(cout, __A__, __B__);
85  PRINT(cout, __A__, __B__);
86  }
87 
92 }
#define PRINT(OUT, U, V)
Print class parameters.
Definition: JConversion.cc:45
int main(int argc, char **argv)
Definition: JConversion.cc:54
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:69
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Utility class to parse command line options.
Definition: JParser.hh:1698
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
@ debug_t
debug
Definition: JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Template class test for polymorphism.
Definition: JConversion.hh:22