CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PayLoadInspector.h
Go to the documentation of this file.
1 #ifndef PayLoadInspector_H
2 #define PayLoadInspector_H
7 #include "TFile.h"
8 #include "Cintex/Cintex.h"
9 #include <sstream>
10 #include <iostream>
11 //#include <fstream>
12 #include <string>
13 #include <utility>
14 #include <vector>
15 
16 namespace cond {
17 
18  template<typename T>
20  public:
21  typedef T Class;
22 
24 
25  virtual ~BaseValueExtractor(){}
26  void computeW(Class const &o){
27  reset();
28  compute(o);
29  }
30  std::vector<float> const & values() const { return m_values;}
31  protected:
32  void add(float v) { m_values.push_back(v); }
33  void swap(std::vector<float> & v) {m_values.swap(v);}
34  private:
35  void reset() { m_values.clear();}
36  virtual void compute(Class const &){}
37 
38 
39  private:
40  std::vector<float> m_values;
41  };
42 
43 
44  // a collection of enumerators, strings, ints
45  template<typename T>
46  struct ExtractWhat {
47 
48  };
49 
50 
51 
52  template<typename T>
53  class ValueExtractor : public BaseValueExtractor<T> {
54  public:
55  typedef T Class;
58  ValueExtractor(What const &){}
59  static What what() { return What();}
60  private:
61  void compute(Class const &){}
62  private:
63  };
64 
65  template<typename DataT>
67  public:
68  typedef DataT Class;
70 
72 
75  }
76 
77  PayLoadInspector(cond::CondDB const & conddb): m_session(conddb.session()), m_since(cond::invalidTime), m_token("") {
78  ROOT::Cintex::Cintex::Enable();
79  }
80 
82  size_t pos = filename.find(".xml");
83  if(pos == std::string::npos)
84  filename.append(".xml");
86  TFile * xml =0;
87  xml = TFile::Open(filename.c_str(), "recreate");
88  xml->WriteObjectAny(m_object.address(), m_object.typeName().c_str(), filename.c_str());
89  xml->Close();
90  return filename;
91  }
92 
93  std::string dump() const {
94  std::ostringstream ss;
95  //token parser
96  std::pair<std::string,int> oidData = parseToken( m_token );
97  ss << m_since << "_"<< oidData.first << "_" << oidData.second;
98  //std::string filename(ss.str()+".xml");
99  return this->dumpXML(ss.str()+".xml");
100  }
101 
102  // specialize...
104  std::ostringstream os;
105  os << std::endl;
106  return os.str();
107  }
108 
109  // return the real name of the file including extension...
110  std::string plot(std::string const & /* filename */,
111  std::string const &,
112  std::vector<int> const&, std::vector<float> const& ) const {return "";}
113 
114 
115  // return the real name of the file including extension...
116  std::string trend_plot(std::string const & /* filename */,//
117  std::string const &,
118  std::vector<int> const&, std::vector<float> const&, std::vector<std::string> const&) const {return "";}
119 
120  // summary, which takes arguments
121  std::string summary_adv(//int const &,
122  std::string const &,
123  std::vector<int> const&, std::vector<float> const&, std::vector<std::string> const&) const {return "";}
124 
125  //returns a file in the format chosen by the user (typically root)
126  std::string dumpFile(std::string const & /* filename */,//
127  std::string const &,
128  std::vector<int> const&, std::vector<float> const&, std::vector<std::string> const&) const {return "";}
129 
130  void extract(Extractor & extractor) const {extractor.computeW(object()); }
131 
132  Class const & object() const {
133  return *(m_object.cast<Class>());
134  }
135 
136  ora::Object const & ora_object() const {
137  return m_object;
138  }
139 
140  bool load( cond::IOVElementProxy const& elem ) {
141  bool ok = false;
142  m_since = elem.since();
143  m_token = elem.token();
145  if(m_object.address()) ok = true;
146  return ok;
147  }
148 
149  private:
154  };
155 
156 }
157 
158 #endif // PayLoadInspector_H
void * cast(const std::type_info &asType) const
Definition: Object.cc:53
std::string trend_plot(std::string const &, std::string const &, std::vector< int > const &, std::vector< float > const &, std::vector< std::string > const &) const
std::string plot(std::string const &, std::string const &, std::vector< int > const &, std::vector< float > const &) const
std::vector< float > const & values() const
ValueExtractor(What const &)
ora::Object const & ora_object() const
std::string typeName() const
Definition: Object.cc:49
std::pair< std::string, int > parseToken(const std::string &objectId)
Definition: PoolToken.cc:15
ExtractWhat< Class > What
void * address() const
Definition: Object.cc:41
std::string dumpXML(std::string filename) const
void extract(Extractor &extractor) const
std::string summary() const
Definition: DTT0.h:52
virtual void compute(Class const &)
unsigned long long Time_t
Definition: Time.h:16
void computeW(Class const &o)
std::string const & token() const
Definition: IOVProxy.h:75
Class const & object() const
const Time_t invalidTime(0)
std::string summary_adv(std::string const &, std::vector< int > const &, std::vector< float > const &, std::vector< std::string > const &) const
std::string dumpFile(std::string const &, std::string const &, std::vector< int > const &, std::vector< float > const &, std::vector< std::string > const &) const
void swap(std::vector< float > &v)
std::vector< float > m_values
bool load(cond::IOVElementProxy const &elem)
void compute(Class const &)
cond::Time_t since() const
Definition: IOVProxy.h:67
tuple filename
Definition: lut2db_cfg.py:20
PayLoadInspector(cond::CondDB const &conddb)
ora::Object getObject(const std::string &objectId)
Definition: DbSession.cc:253
long double T
void destruct()
Definition: Object.cc:63
std::string dump() const
cond::DbSession m_session
ValueExtractor< DataT > Extractor