Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintMeta.cc File Reference

Auxiliary program to print Jpp meta data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TNamed.h"
#include "TKey.h"
#include "TRegexp.h"
#include "JLang/JLangToolkit.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "Jeep/JeepToolkit.hh"
#include "JSon/JSon.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.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

Auxiliary program to print Jpp meta data.

Author
mdejong

Definition in file JPrintMeta.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 37 of file JPrintMeta.cc.

38 {
39  using namespace std;
40  using namespace JPP;
41 
42  string inputFile;
43  JLimit_t numberOfEvents;
44  string application;
45  string option;
46  vector<string> key;
47  int debug;
48 
49  try {
50 
51  JParser<> zap("Auxiliary program to print Jpp meta data.");
52 
53  zap['f'] = make_field(inputFile);
54  zap['n'] = make_field(numberOfEvents) = JLimit::max();
55  zap['A'] = make_field(application) = "";
56  zap['O'] = make_field(option) = plain_t, json_t;
57  zap['k'] = make_field(key, "possible values: "
58  << GITrelease_t << ", "
59  << SVNrelease_t << ", "
60  << ROOTrelease_t << ", "
61  << namespace_t << ", "
62  << command_t << ", "
64  zap['d'] = make_field(debug) = 1;
65 
66  zap(argc, argv);
67  }
68  catch(const exception &error) {
69  FATAL(error.what() << endl);
70  }
71 
72  cout.tie(&cerr);
73 
74  if (application != "") {
75 
76  TFile* in = TFile::Open(inputFile.c_str(), "exists");
77 
78  if (in != NULL && in->IsOpen()) {
79 
80  const TRegexp regexp(application.c_str());
81 
82  TIter iter(in->GetListOfKeys());
83 
84  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
85 
86  const TString tag(key->GetName());
87 
88  if (tag.Contains(regexp)) {
89 
90  TNamed* named = dynamic_cast<TNamed*>(key->ReadObj());
91 
92  if (named != NULL) {
93  cout << named->GetName() << "[" << key->GetCycle() << "] " << named->GetTitle() << endl;
94  }
95  }
96  }
97 
98  in->Close();
99 
100  } else {
101 
102  ERROR("Error opening file: " << inputFile << endl);
103  }
104 
105  } else {
106 
107  JMultipleFileScanner<JMetaTypes_t> in(inputFile, numberOfEvents);
109 
110  json js;
111 
112  while (abc.hasNext()) {
113 
114  JMeta* meta = abc.next();
115 
116  if (option == plain_t) {
117 
118  if (key.empty()) {
119 
120  cout << (*meta) << endl;
121 
122  } else {
123 
124  for (const auto& i : key) {
125  cout << ' ' << (*meta)[i];
126  }
127  cout << endl;
128  }
129 
130  } else if (option == json_t) {
131 
132  js += json(*meta);
133  }
134  }
135 
136  if (option == json_t) {
137  cout << setw(4) << js << endl;
138  }
139  }
140 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1500
static const char *const GITrelease_t
GIT release.
Definition: JMeta.hh:60
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
Auxiliary class for multiplexing object iterators.
static const char *const ROOTrelease_t
ROOT release.
Definition: JMeta.hh:61
static const char *const SVNrelease_t
SVN release.
Definition: JMeta.hh:59
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define ERROR(A)
Definition: JMessage.hh:66
int debug
debug level
Definition: JSirene.cc:67
static const char *const system_t
system information
Definition: JMeta.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
static const char *const namespace_t
name space
Definition: JMeta.hh:62
General purpose class for object reading from a list of file names.
nlohmann::json json
static const char *const command_t
Linux command.
Definition: JMeta.hh:63
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46