Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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 */
20int 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}
string outputFile
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
int main(int argc, char **argv)
Definition JMeta.cc:20
ROOT I/O of application specific meta data.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:72
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72
std::string toString() const
Convert meta data to string.
Definition JMeta.hh:187