Jpp
18.5.2
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
JMath
JZero.cc
Go to the documentation of this file.
1
#include <iostream>
2
#include <iomanip>
3
4
#include "
JMath/JZero.hh
"
5
6
#include "
Jeep/JParser.hh
"
7
#include "
Jeep/JMessage.hh
"
8
9
10
namespace
{
11
12
struct
__A__ {
13
/**
14
* Default constructor.
15
*/
16
__A__() :
17
a
(0)
18
{}
19
20
/**
21
* Constructor.
22
*
23
* \param a value
24
*/
25
__A__(
double
a
)
26
{
27
this->a =
a
;
28
}
29
30
/**
31
* Equals operator.
32
*
33
* \param first first value
34
* \param second second value
35
* \return true if first and second value are equal; else false
36
*/
37
friend
inline
bool
operator==
(
const
__A__&
first
,
const
__A__& second)
38
{
39
return
first.a == second.a;
40
}
41
42
/**
43
* Write object to output.
44
*
45
* \param out output stream
46
* \param object object
47
* \return output stream
48
*/
49
friend
inline
std::ostream&
operator<<
(std::ostream& out,
const
__A__&
object
)
50
{
51
return
out <<
object
.a;
52
}
53
54
double
a
;
55
};
56
57
/**
58
* Test equaliilty.
59
*
60
* \param zero zero value
61
* \return true if JMath::zero equals given zero value; else false
62
*/
63
template
<
class
T>
64
bool
inline
is_equal(
const
T
&
zero
)
65
{
66
T
value =
JMATH::zero
;
67
68
return
value ==
zero
;
69
}
70
71
/**
72
* Print class and zero value.
73
*
74
* \param out output stream
75
* \param name class name
76
*/
77
template
<
class
T>
78
inline
void
print
(std::ostream& out,
const
char
*
name
)
79
{
80
using namespace
std;
81
82
T
value =
JMATH::zero
;
83
84
out << setw(12) << left << name <<
' '
<< value << endl;
85
}
86
87
#define PRINT(OUT, CLASS) print<CLASS>(OUT, #CLASS)
88
}
89
90
91
/**
92
* \file
93
*
94
* Example program to test zero values (JMATH::zero).
95
* \author mdejong
96
*/
97
int
main
(
int
argc,
char
**argv)
98
{
99
using namespace
std;
100
101
int
debug
;
102
103
try
{
104
105
JParser<>
zap(
"Example program to test zero values of non-primitive data types."
);
106
107
zap[
'd'
] =
make_field
(
debug
) = 3;
108
109
zap(argc, argv);
110
}
111
catch
(
const
exception &error) {
112
FATAL
(error.what() << endl);
113
}
114
115
using namespace
JPP;
116
117
PRINT
(cout,
int
);
118
PRINT
(cout,
float
);
119
PRINT
(cout,
double
);
120
PRINT
(cout, __A__);
121
122
ASSERT
(is_equal<int> (0));
123
ASSERT
(is_equal<float> (0.0));
124
ASSERT
(is_equal<double>(0.0));
125
ASSERT
(is_equal<__A__> (__A__(0)));
126
127
return
0;
128
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
name
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition:
JCookie.sh:42
JMATH::zero
static const JZero zero
Function object to assign zero value.
Definition:
JZero.hh:105
JZero.hh
Definition of zero value for any class.
first
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
Definition:
JDOMDAQDriver.sh:57
PRINT
#define PRINT(OUT, CLASS)
Definition:
JZero.cc:87
operator==
bool operator==(Packet const &p, ID const &id)
Definition:
raw_data_converter.cpp:48
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
a
then JCalibrateToT a
Definition:
JTuneHV.sh:113
T
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Definition:
JCalibrateHeight.sh:61
print
print
Definition:
JConvertDusj.sh:44
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
operator<<
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
Definition:
clb_common_header.hh:72
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
Generated by
1.8.5