Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JMeta.cc File Reference

Example program to test JSUPPORT::JMeta class. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "TFile.h"
#include "JSupport/JMeta.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JSUPPORT::JMeta class.

Author
mdejong

Definition in file JMeta.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 20 of file JMeta.cc.

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
#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
#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
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72