Jpp
15.0.5
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
JSupport
JMeta.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
#include <vector>
5
6
#include "TFile.h"
7
8
#include "
JSupport/JMeta.hh
"
9
10
#include "
Jeep/JParser.hh
"
11
#include "
Jeep/JMessage.hh
"
12
13
14
/**
15
* \file
16
*
17
* Example program to test JSUPPORT::JMeta class.
18
* \author mdejong
19
*/
20
int
main
(
int
argc,
char
**argv)
21
{
22
using namespace
std;
23
using namespace
JPP;
24
25
string
outputFile
;
26
vector<int>
buffer;
27
int
debug
;
28
29
try
{
30
31
JParser<>
zap(
"Example program to test meta."
);
32
33
zap[
'o'
] =
make_field
(
outputFile
) =
"meta.root"
;
34
zap[
'x'
] =
make_field
(buffer);
35
zap[
'd'
] =
make_field
(
debug
) = 2;
36
37
zap(argc, argv);
38
}
39
catch
(
const
exception &error) {
40
FATAL
(error.what() << endl);
41
}
42
43
argv[0] = (
char
*)
"test"
;
// rename
44
45
const
JMeta meta(argc, argv);
46
47
DEBUG
(meta << endl);
48
DEBUG
(meta.toString() << endl);
49
50
ASSERT
(JMeta::valueOf(meta.toString()) == meta);
51
52
{
53
TFile*
file
= TFile::Open(
outputFile
.c_str(),
"recreate"
);
54
55
putObject
(file, meta);
56
57
file->Write();
58
file->Close();
59
}
60
61
{
62
TFile*
file
= TFile::Open(
outputFile
.c_str(),
"exists"
);
63
64
ASSERT
(file != NULL);
65
66
JMeta* p = NULL;
67
68
const
int
cycle = 1;
69
70
getObject
(file,
MAKE_CSTRING
(
META_NAME
<<
';'
<< cycle), p);
71
72
ASSERT
(p != NULL);
73
74
DEBUG
(*p);
75
76
ASSERT
(meta == *p);
77
78
file->Close();
79
}
80
81
return
0;
82
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
JGIZMO::getObject
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
Definition:
JGizmoToolkit.hh:152
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
MAKE_CSTRING
#define MAKE_CSTRING(A)
Make C-string.
Definition:
JPrint.hh:151
outputFile
string outputFile
Definition:
JDAQTimesliceSelector.cc:37
std::vector< int >
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:1961
JMeta.hh
ROOT I/O of application specific meta data.
debug
int debug
debug level
Definition:
JSirene.cc:63
JROOT::putObject
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Definition:
JRootFileWriter.hh:41
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
JSUPPORT::META_NAME
static const char *const META_NAME
ROOT name for meta data.
Definition:
JMeta.hh:46
DEBUG
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
Definition:
JCalibratePMT.sh:21
file
then usage $script< string identifier >< detectorfile > event file(toashort file)+" "\nNote that the event files and toashort files should be one-to-one related." fi if (( $
Definition:
hydrophone-phi:run.sh:18
Generated by
1.8.5