Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JMultiEquals.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JLang/JEquals.hh
"
6
#include "
JLang/JMultiEquals.hh
"
7
8
#include "
Jeep/JParser.hh
"
9
#include "
Jeep/JMessage.hh
"
10
11
12
namespace
{
13
14
using namespace
JPP;
15
16
17
struct
__A__ :
18
public
JEquals
<__A__>
19
{
20
__A__() :
21
value(0)
22
{}
23
24
__A__(
int
__value) :
25
value(__value)
26
{}
27
28
bool
equals(
const
__A__&
object
)
const
29
{
30
return
this->value ==
object
.value;
31
}
32
33
friend
std::ostream&
operator<<
(std::ostream& out,
const
__A__&
object
)
34
{
35
return
out <<
object
.value;
36
}
37
38
int
value;
39
};
40
41
42
struct
__B__ :
43
public
JEquals
<__B__>
44
{
45
__B__() :
46
value(0)
47
{}
48
49
__B__(
int
__value) :
50
value(__value)
51
{}
52
53
bool
equals(
const
__B__&
object
)
const
54
{
55
return
this->value ==
object
.value;
56
}
57
58
friend
std::ostream&
operator<<
(std::ostream& out,
const
__B__&
object
)
59
{
60
return
out <<
object
.value;
61
}
62
63
int
value;
64
};
65
66
67
struct
__C__ :
68
public
__A__,
69
public
__B__,
70
public
JMultiEquals
<__C__, JTYPELIST<__A__, __B__>::typelist>
71
{
72
__C__(
const
int
a,
73
const
int
b) :
74
__A__(a),
75
__B__(b)
76
{}
77
78
friend
std::ostream&
operator<<
(std::ostream& out,
const
__C__&
object
)
79
{
80
return
out << static_cast<const __A__&>(object) <<
' '
81
<< static_cast<const __B__&>(
object
);
82
}
83
};
84
85
86
/**
87
* Print.
88
*
89
* \param OUT output stream
90
* \param OP operator
91
* \param A first object
92
* \param B second object
93
*/
94
#define PRINT(OUT,OP,A,B) \
95
OUT << "(" << A << ") " << #OP " (" << B << ") => " << (A OP B) << std::endl;
96
}
97
98
/**
99
* \file
100
*
101
* Example program to test JLANG::JMultiEquals class.
102
* \author mdejong
103
*/
104
int
main
(
int
argc,
char
**argv)
105
{
106
using namespace
std;
107
using namespace
JPP;
108
109
int
debug
;
110
111
try
{
112
113
JParser<>
zap(
"Example program to test object comparisons."
);
114
115
zap[
'd'
] =
make_field
(
debug
) = 3;
116
117
zap(argc, argv);
118
}
119
catch
(
const
exception &error) {
120
FATAL
(error.what() << endl);
121
}
122
123
__C__
c1
(1,1);
124
__C__ c2(1,1);
125
__C__ c3(0,1);
126
__C__ c4(1,0);
127
128
PRINT
(cout, ==, c1, c2);
129
PRINT
(cout, !=, c1, c2);
130
PRINT
(cout, ==, c1, c3);
131
PRINT
(cout, !=, c1, c3);
132
PRINT
(cout, ==, c1, c4);
133
PRINT
(cout, !=, c1, c4);
134
135
ASSERT
(c1 == c2);
136
ASSERT
(c1 != c3);
137
ASSERT
(c1 != c4);
138
139
return
0;
140
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1410
JMultiEquals.hh
JLANG::JMultiEquals
Template definition of auxiliary base class for composite data structures composed of base classes wi...
Definition:
JMultiEquals.hh:31
ASSERT
#define ASSERT(A)
Assert macro.
Definition:
JMessage.hh:72
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1836
JLANG::JEquals
Template definition of auxiliary base class for comparison of data structures.
Definition:
JEquals.hh:24
debug
int debug
debug level
Definition:
JSirene.cc:59
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:65
c1
TCanvas * c1
Global variables to handle mouse events.
Definition:
JDrawModule3D.cc:34
JParser.hh
Utility class to parse command line options.
operator<<
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
Definition:
clb_common_header.hh:71
PRINT
#define PRINT(OUT, OP, A, B)
Print.
Definition:
JMultiEquals.cc:94
JEquals.hh
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5