Jpp
18.0.1-rc.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
Jeep
JProperties-setValue.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JLang/JCategory.hh
"
6
#include "
Jeep/JProperties.hh
"
7
#include "
Jeep/JParser.hh
"
8
#include "
Jeep/JMessage.hh
"
9
10
11
namespace
{
12
13
using namespace
JPP;
14
15
16
/**
17
* Test data structure.
18
*/
19
struct
JABC {
20
/**
21
* Constructor.
22
*
23
* \param a a
24
* \param b b
25
* \param c c
26
*/
27
JABC(
const
double
a
,
28
const
double
b,
29
const
double
c
)
30
{
31
this->a =
a
;
32
this->b = b;
33
this->c =
c
;
34
}
35
36
double
a
;
37
double
b;
38
double
c
;
39
40
/**
41
* Get properties of this class.
42
*
43
* \param object test data
44
* \param equation equation parameters
45
*/
46
template
<
bool
is_const>
47
static
JProperties
getProperties
(
typename
JCategory<JABC, is_const>::reference_type
object
,
48
const
JEquationParameters
& equation =
JEquationParameters
(
"="
,
"\n;"
,
"./"
,
"#"
),
49
const
int
debug
= 0)
50
{
51
JProperties
properties(equation,
debug
);
52
53
properties.insert(
gmake_property
(
object
.
a
));
54
properties.insert(
gmake_property
(
object
.b));
55
properties.insert(
gmake_property
(
object
.
c
));
56
57
return
properties;
58
}
59
};
60
}
61
62
/**
63
* \file
64
* Example program to test JPROPERTIES::JProperties class.
65
* \author mdejong
66
*/
67
int
main
(
int
argc,
char
**argv)
68
{
69
using namespace
std;
70
71
int
debug
;
72
73
try
{
74
75
JParser<>
zap;
76
77
zap[
'd'
] =
make_field
(
debug
) = 3;
78
79
zap(argc, argv);
80
}
81
catch
(
const
exception &error) {
82
FATAL
(error.what() << endl);
83
}
84
85
double
a = 1.0;
86
double
b = 2.0;
87
double
c
= 3.0;
88
89
JABC test(a, b,
c
);
90
91
getProperties
(test).
getValue
<
double
>(
"a"
) *= a;
92
getProperties
(test).
setValue
<
double
>(
"b"
, 111.0);
93
getProperties
(test).
getValue
<
double
>(
"c"
) +=
c
;
94
95
ASSERT
(test.a == a*a);
96
ASSERT
(test.b == 111.0);
97
ASSERT
(test.c == 2*
c
);
98
99
return
0;
100
}
JCategory.hh
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JEEP::getProperties
JProperties & getProperties(T &object, const JEquationParameters ¶meters=JEquationParameters(), const int debug=1)
Get properties of a given object.
Definition:
JProperties.hh:1267
gmake_property
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Definition:
JProperties.hh:1291
JEEP::JProperties
Utility class to parse parameter values.
Definition:
JProperties.hh:496
JLANG::JEquationParameters
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Definition:
JEquationParameters.hh:20
JProperties.hh
Utility class to parse parameter values.
JEEP::JProperties::getValue
const T & getValue(const std::string &key) const
Get value.
Definition:
JProperties.hh:974
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:116
JMessage.hh
General purpose messaging.
JEEP::JProperties::setValue
void setValue(const std::string &key, const T &value)
Set value.
Definition:
JProperties.hh:1010
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
c
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
JParser.hh
Utility class to parse command line options.
JLANG::JCategory
Auxiliary class to define value, reference and pointer types for given data type and category...
Definition:
JCategory.hh:18
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
Generated by
1.8.5