Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
11 
12 #include "JDAQ/JDAQEventIO.hh"
13 #include "JDAQ/JDAQTimesliceIO.hh"
15 
17 
18 #include "JROOT/JRootToolkit.hh"
19 #include "JSupport/JSupport.hh"
20 #include "JLang/JTypeList.hh"
21 #include "JLang/JType.hh"
22 #include "JLang/JNullType.hh"
23 
24 #include "Jeep/JParser.hh"
25 #include "Jeep/JMessage.hh"
26 
27 
28 namespace {
29 
30  using namespace JPP;
31 
32  /**
33  * Print class streamer version.
34  *
35  * \param out output stream
36  * \param name class name
37  * \param file pointer to ROOT file
38  */
39  inline void print(std::ostream& out, const char* name, TFile* file = NULL)
40  {
41  using namespace std;
42  using namespace JPP;
43 
44  TDictionary* dictionary = TDictionary::GetDictionary(name);
45 
46  out << setw(40) << left << name << ' ';
47 
48  if (dictionary != NULL) {
49  out << setw( 4) << right << dynamic_cast<TClass*>(dictionary)->GetClassVersion() << ' ';
50  }
51 
52  if (file != NULL) {
53  out << setw(4) << right << getStreamerVersion(file, name);
54  }
55 
56  cout << endl;
57  }
58 
59 
60  /**
61  * Print class streamer version.
62  *
63  * \param out output stream
64  * \param typelist type list
65  * \param file pointer to ROOT file
66  */
67  inline void print(std::ostream& out, JType<JNullType> typelist, TFile* file = NULL)
68  {}
69 
70 
71  /**
72  * Print class streamer version.
73  *
74  * \param out output stream
75  * \param typelist type list
76  * \param file pointer to ROOT file
77  */
78  template<class JHead_t, class JTail_t>
79  inline void print(std::ostream& out, JType< JTypeList<JHead_t, JTail_t> > typelist, TFile* file = NULL)
80  {
81  print(out, JHead_t::Class_Name(), file);
82  print(out, JType<JTail_t>(), file);
83  }
84 }
85 
86 
87 /**
88  * \file
89  *
90  * Auxiliary program to print ROOT class version information.
91  * \author mdejong
92  */
93 int main(int argc, char **argv)
94 {
95  using namespace std;
96 
97  string input_file;
98  string class_name;
99  int debug;
100 
101  try {
102 
103  JParser<> zap("Auxiliary program to print ROOT class version information.");
104 
105  zap['f'] = make_field(input_file) = "";
106  zap['c'] = make_field(class_name) = "";
107  zap['d'] = make_field(debug) = 1;
108 
109  zap(argc, argv);
110  }
111  catch(const exception &error) {
112  FATAL(error.what() << endl);
113  }
114 
115  cout.tie(&cerr);
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 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
int getStreamerVersion(TFile *file, const char *name)
Get ROOT streamer version of class with given name.
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
Auxiliary class for a type holder.
Definition: JType.hh:19
Type list.
Definition: JTypeList.hh:22
virtual void open(const char *file_name) override
Open file.
Definition: JRootFile.hh:143
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
ROOT input file.
Definition: JRootFile.hh:113
int debug
debug level
Definition: JSirene.cc:63
print
Definition: JConvertDusj.sh:44
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.