Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JSinglePointer.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
#include <vector>
5
6
#include "
JLang/JSinglePointer.hh
"
7
8
#include "
Jeep/JParser.hh
"
9
#include "
Jeep/JMessage.hh
"
10
11
12
namespace
{
13
14
struct
__A__
15
{
16
__A__()
17
{
18
std::cout <<
"__A__()"
<< std::endl;
19
}
20
21
~__A__()
22
{
23
std::cout <<
"~__A__()"
<< std::endl;
24
}
25
};
26
}
27
28
29
/**
30
* \file
31
*
32
* Example program to test JLANG::JSinglePointer class.
33
* \author mdejong
34
*/
35
int
main
(
int
argc,
char
**argv)
36
{
37
using namespace
std;
38
39
int
debug
;
40
41
try
{
42
43
JParser<>
zap(
"Example program to test single pointer."
);
44
45
zap[
'd'
] =
make_field
(
debug
) = 3;
46
47
zap(argc, argv);
48
}
49
catch
(
const
exception &error) {
50
FATAL
(error.what() << endl);
51
}
52
53
54
using namespace
JPP;
55
56
const
int
N
= 4;
57
58
typedef
JSinglePointer<__A__> JSinglePointer_t;
59
60
JSinglePointer_t
a
;
61
62
DEBUG
(
"JSinglePointer::create()"
<< endl);
63
64
a
.create();
65
66
vector<JSinglePointer_t>
buffer;
67
68
for
(
int
i = 0; i !=
N
; ++i) {
69
70
DEBUG
(
"buffer.push_back() "
<< i << endl);
71
72
buffer.push_back(
a
);
73
}
74
75
for
(
int
i = 0; i !=
N
; ++i) {
76
DEBUG
(
"buffer["
<< i <<
"] is valid? "
<< buffer[i].
is_valid
() << endl);
77
}
78
79
for
(
int
i = 0; i !=
N
; ++i) {
80
ASSERT
(i == 0 ? buffer[i].
is_valid
() : !buffer[i].
is_valid
());
81
}
82
83
return
0;
84
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1493
a
fi JEventTimesliceWriter a
Definition:
JEventProcessor.sh:71
std::vector
Definition:
JSTDTypes.hh:12
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:1954
JDETECTOR::is_valid
bool is_valid(const json &js)
Check validity of JSon data.
Definition:
JDetectorCalibration.hh:101
debug
int debug
debug level
Definition:
JSirene.cc:61
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
JSinglePointer.hh
N
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition:
JMuonPostfit.sh:37
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5