Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JPrintRootVersion.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5
6#include "TROOT.h"
7#include "TFile.h"
8
12
13#include "JDAQ/JDAQEventIO.hh"
16
18
19#include "JROOT/JRootToolkit.hh"
20#include "JSupport/JSupport.hh"
21#include "JLang/JTypeList.hh"
22#include "JLang/JType.hh"
23#include "JLang/JNullType.hh"
24
25#include "Jeep/JParser.hh"
26#include "Jeep/JMessage.hh"
27
28
29namespace {
30
31 using namespace JPP;
32
33 /**
34 * Print class streamer version.
35 *
36 * \param out output stream
37 * \param name class name
38 * \param file pointer to ROOT file
39 */
40 inline void print(std::ostream& out, const char* name, TFile* file = NULL)
41 {
42 using namespace std;
43 using namespace JPP;
44
45 TDictionary* dictionary = TDictionary::GetDictionary(name);
46
47 out << setw(40) << left << name << ' ';
48
49 if (dictionary != NULL) {
50 out << setw( 4) << right << dynamic_cast<TClass*>(dictionary)->GetClassVersion() << ' ';
51 }
52
53 if (file != NULL) {
54 out << setw(4) << right << getStreamerVersion(file, name);
55 }
56
57 cout << endl;
58 }
59
60
61 /**
62 * Print class streamer version.
63 *
64 * \param out output stream
65 * \param typelist type list
66 * \param file pointer to ROOT file
67 */
68 inline void print(std::ostream& out, JType<JNullType> typelist, TFile* file = NULL)
69 {}
70
71
72 /**
73 * Print class streamer version.
74 *
75 * \param out output stream
76 * \param typelist type list
77 * \param file pointer to ROOT file
78 */
79 template<class JHead_t, class JTail_t>
80 inline void print(std::ostream& out, JType< JTypeList<JHead_t, JTail_t> > typelist, TFile* file = NULL)
81 {
82 print(out, JHead_t::Class_Name(), file);
83 print(out, JType<JTail_t>(), file);
84 }
85}
86
87
88/**
89 * \file
90 *
91 * Auxiliary program to print ROOT class version information.
92 * \author mdejong
93 */
94int main(int argc, char **argv)
95{
96 using namespace std;
97
98 string input_file;
99 string class_name;
100 int debug;
101
102 try {
103
104 JParser<> zap("Auxiliary program to print ROOT class version information.");
105
106 zap['f'] = make_field(input_file) = "";
107 zap['c'] = make_field(class_name) = "";
108 zap['d'] = make_field(debug) = 1;
109
110 zap(argc, argv);
111 }
112 catch(const exception &error) {
113 FATAL(error.what() << endl);
114 }
115
116
117 using namespace JPP;
118
119 JRootInputFile file;
120
121 if (input_file != "") {
122
123 try {
124 file.open(input_file.c_str());
125 }
126 catch(const exception& error) {
127 FATAL(error.what() << endl);
128 }
129
130 if (!file.is_open()) {
131 FATAL("Error opening file " << input_file << endl);
132 }
133 }
134
135 if (class_name != "")
136 print(cout, class_name.c_str(), file.getFile());
137 else
138 print(cout, JType<JAllDataTypes_t>(), file.getFile());
139}
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
ROOT TTree parameter settings of various packages.
Utility class to parse command line options.
Definition JParser.hh:1698
TFile * getFile() const
Get file.
Definition JRootFile.hh:66
virtual bool is_open() const override
Check is file is open.
Definition JRootFile.hh:77
ROOT input file.
Definition JRootFile.hh:97
virtual void open(const char *file_name) override
Open file.
Definition JRootFile.hh:136
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
int getStreamerVersion(TFile *file, const char *const name)
Get ROOT streamer version of class with given name.
Type list.
Definition JTypeList.hh:23
Auxiliary class for a type holder.
Definition JType.hh:19