Jpp
18.1.0
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
JObject.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
#include <vector>
5
#include <iterator>
6
7
#include "
JLang/JObject.hh
"
8
9
#include "
Jeep/JParser.hh
"
10
#include "
Jeep/JMessage.hh
"
11
12
13
namespace
{
14
15
using namespace
JPP;
16
17
typedef
std::vector<int>
buffer_type;
18
19
20
/**
21
* Example worker class which requires static instance to be processed.
22
*/
23
struct
__A__ :
24
public
JObject
<__A__>
25
{
26
__A__(
const
int
N
, buffer_type& buffer) :
27
N(N),
28
buffer(buffer)
29
{}
30
31
void
operator()()
32
{
33
for
(
int
i
= 0;
i
!=
N
; ++
i
) {
34
buffer.push_back(buffer.size());
35
}
36
}
37
38
int
N
;
39
buffer_type& buffer;
40
};
41
42
43
/**
44
* Process object.
45
*/
46
inline
void
process(__A__&
object
)
47
{
48
object();
49
}
50
}
51
52
53
/**
54
* \file
55
*
56
* Example program to test JLANG::JObject class.
57
* \author mdejong
58
*/
59
int
main
(
int
argc,
char
**argv)
60
{
61
using namespace
std;
62
63
int
debug
;
64
65
try
{
66
67
JParser<>
zap(
"Example program to test object."
);
68
69
zap[
'd'
] =
make_field
(
debug
) = 3;
70
71
zap(argc, argv);
72
}
73
catch
(
const
exception &error) {
74
FATAL
(error.what() << endl);
75
}
76
77
78
using namespace
JPP;
79
80
buffer_type buffer;
81
82
process(__A__(3, buffer).
getInstance
());
83
process(
getInstance
(__A__(2, buffer)));
84
//process(__A__(5, buffer)); // compiler error: invalid initialization of non-const reference (as should be)
85
86
for
(buffer_type::const_iterator
i
= buffer.begin();
i
!= buffer.end(); ++
i
) {
87
cout << *
i
<< endl;
88
}
89
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
i
then rm i
Definition:
JEvtReweightGSeaGenParameterScan.sh:337
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
std::vector< int >
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:1989
JLANG::JObject
Auxiliary base class for inline creation of a static value or clone from a temporary object...
Definition:
JObject.hh:18
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
N
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition:
JMuonPostfit.sh:40
JParser.hh
Utility class to parse command line options.
JObject.hh
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
Generated by
1.8.5