Jpp
examples
JLang
JSharedPointer.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
#include <vector>
5
6
#include "
JLang/JSharedPointer.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::JSharedPointer class.
33
* \author mdejong
34
*/
35
int
main
(
int
argc,
char
**argv)
36
{
37
using namespace
std
;
38
39
unsigned
int
N;
40
int
debug
;
41
42
try
{
43
44
JParser<>
zap(
"Example program to test shared pointer."
);
45
46
zap[
'n'
] =
make_field
(N) = 4;
47
zap[
'd'
] =
make_field
(
debug
) = 3;
48
49
zap(argc, argv);
50
}
51
catch
(
const
exception &error) {
52
FATAL
(error.what() << endl);
53
}
54
55
56
using namespace
JPP
;
57
58
59
typedef
JSharedPointer<__A__> JSharedPointer_t;
60
61
JSharedPointer_t a;
62
63
cout <<
"JSharedPointer::create()"
<< endl;
64
65
a.create();
66
67
vector<JSharedPointer_t>
buffer;
68
69
for
(
unsigned
int
i = 0; i != N; ++i) {
70
71
cout <<
"buffer.push_back() "
<< i << endl;
72
73
buffer.push_back(a);
74
}
75
76
for
(
unsigned
int
i = 0; i != N; ++i) {
77
cout <<
"buffer["
<< i <<
"] is valid? "
<< buffer[i].is_valid() << endl;
78
}
79
}
JMessage.hh
JSharedPointer.hh
std::vector
Definition:
JSTDTypes.hh:12
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1493
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
debug
int debug
debug level
Definition:
JSirene.cc:59
main
int main(int argc, char **argv)
Definition:
JSharedPointer.cc:35
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1954
std
Definition:
jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
Generated by
1.8.16