Jpp  debug
the software that should make you happy
JComparisonAvailable.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JLang/JComparable.hh"
6 #include "JLang/JEquals.hh"
7 #include "JLang/JMultiEquals.hh"
9 
10 #include "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 
13 
14 namespace {
15 
16  using namespace JPP;
17 
18 
19  struct __A__ {};
20  struct __B__ {};
21  struct __C__ : public __B__ {};
22 
23  struct __D__ :
24  public JComparable<__D__>
25  {
26  bool less(const __D__& object) const { return true; }
27  };
28 
29  inline bool operator!=(const __A__& first, const __A__& second) { return false; }
30  inline bool operator< (const __B__& first, const __B__& second) { return false; }
31  inline bool operator> (const __B__& first, const __B__& second) { return false; }
32 
33  struct __E__ :
34  public __A__,
35  public __D__,
36  // adddition of this base class solves the ambiguity problem.
37  public JMultiEquals<__E__, JTYPELIST<__A__, __D__>::typelist>
38  {};
39 }
40 
41 /**
42  * Print availabilty of comparison operators.
43  *
44  * \param OUT output stream
45  * \param CLASS class name
46  */
47 #define PRINT(OUT, CLASS) \
48  OUT << std::setw(6) << std::left << #CLASS << ' ' ; \
49  OUT << ' ' << JComparisonAvailable<CLASS>::has_eq << ' '; \
50  OUT << ' ' << JComparisonAvailable<CLASS>::has_ne << ' '; \
51  OUT << ' ' << JComparisonAvailable<CLASS>::has_lt << ' '; \
52  OUT << ' ' << JComparisonAvailable<CLASS>::has_gt << ' '; \
53  OUT << ' ' << JComparisonAvailable<CLASS>::has_le << ' '; \
54  OUT << ' ' << JComparisonAvailable<CLASS>::has_ge << std::endl;
55 
56 
57 /**
58  * \file
59  *
60  * Example program to test JLANG::JComparisonAvailable and JLANG::JComparable classes.
61  * \author mdejong
62  */
63 int main(int argc, char **argv)
64 {
65  using namespace std;
66  using namespace JPP;
67 
68  int debug;
69 
70  try {
71 
72  JParser<> zap("Example program to test availability of object comparisons.");
73 
74  zap['d'] = make_field(debug) = 3;
75 
76  zap(argc, argv);
77  }
78  catch(const exception &error) {
79  FATAL(error.what() << endl);
80  }
81 
82  if (debug >= debug_t) {
83 
84  cout << setw(6) << left << "class" << ' ' << "eq ne lt gt le ge" << endl;
85 
86  PRINT(cout, __A__);
87  PRINT(cout, __B__);
88  PRINT(cout, __C__);
89  PRINT(cout, __D__);
90  PRINT(cout, __E__);
91  }
92 
99 
106 
113 
120 
121  return 0;
122 }
int main(int argc, char **argv)
#define PRINT(OUT, CLASS)
Print availabilty of comparison operators.
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:2158
Template definition of test availability of comparison operators.
Utility class to parse command line options.
Definition: JParser.hh:1714
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1817
@ debug_t
debug
Definition: JMessage.hh:29
bool operator!=(const JTag &first, const JTag &second)
Not equal operator for JTag.
Definition: JTag.hh:291
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool operator>(const JDAQUTCExtended &first, const JDAQUTCExtended &second)
Greater than operator for UTC times.
Definition: JSTDTypes.hh:14
Template definition of auxiliary base class for comparison of data structures.
Definition: JComparable.hh:139
Template definition of auxiliary base class for data structures composed of multiple base classes wit...
Definition: JMultiEquals.hh:32