Jpp
15.0.3
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
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
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
JSingleton.hh
JLANG::JSingleton
Simple singleton class.
Definition:
JSingleton.hh:18
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JLANG::getInstance
T & getInstance(const T &object)
Get static instance from temporary object.
Definition:
JObject.hh:75
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
debug
int debug
debug level
Definition:
JSirene.cc:63
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JTRIGGER::count
std::vector< int > count
Definition:
JAlgorithm.hh:180
a
then JCalibrateToT a
Definition:
JTuneHV.sh:116
JParser.hh
Utility class to parse command line options.
Generated by
1.8.5