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