Jpp
examples
JLang
JSingleton.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JLang/JSingleton.hh
"
6
7
#include "
Jeep/JParser.hh
"
8
#include "
Jeep/JMessage.hh
"
9
10
11
namespace
{
12
13
struct
__A__ :
14
public
JLANG::JSingleton
<__A__>
15
{
16
__A__()
17
{
18
std::cout <<
"__A__()"
;
19
++count;
20
}
21
22
~__A__()
23
{
24
std::cout <<
"~__A__()"
<< std::endl;
25
}
26
27
static
int
count;
28
};
29
30
int
__A__::count = 0;
31
}
32
33
34
/**
35
* \file
36
*
37
* Example program to test JLANG::JSingleton class.
38
* \author mdejong
39
*/
40
int
main
(
int
argc,
char
**argv)
41
{
42
using namespace
std
;
43
44
int
debug
;
45
46
try
{
47
48
JParser<>
zap(
"Example program to test singleton."
);
49
50
zap[
'd'
] =
make_field
(
debug
) = 3;
51
52
zap(argc, argv);
53
}
54
catch
(
const
exception &error) {
55
FATAL
(error.what() << endl);
56
}
57
58
59
using namespace
JPP
;
60
61
cout <<
"Test of getInstance()"
<< endl;
62
63
for
(
int
i = 0; i != 5; ++i) {
64
65
cout <<
"["
<< i <<
"]"
<<
' '
<< flush;
66
67
__A__& a =
__A__::getInstance
();
68
69
cout <<
' '
<< a.count;
70
71
cout << endl;
72
}
73
74
cout <<
"Test of constructor()"
<< endl;
75
76
for
(
int
i = 0; i != 5; ++i) {
77
78
cout <<
"["
<< i <<
"]"
<<
' '
<< flush;
79
80
__A__ a;
81
82
cout <<
' '
<< a.count <<
' '
;
83
}
84
85
cout <<
"end of main"
<< endl;
86
}
JMessage.hh
JLANG::getInstance
T & getInstance(const T &object)
Get static instance from temporary object.
Definition:
JObject.hh:75
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
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1954
std
Definition:
jaanetDictionary.h:36
JLANG::JSingleton
Simple singleton class.
Definition:
JSingleton.hh:18
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
main
int main(int argc, char **argv)
Definition:
JSingleton.cc:40
JSingleton.hh
Generated by
1.8.16