CMS 3D CMS Logo

MonitorXMLParser.h
Go to the documentation of this file.
1 
8 #ifndef MonitorXMLParser_h
9 #define MonitorXMLParser_h
10 
11 #include <iostream>
12 #include <map>
13 #include <sstream>
14 #include <string>
15 #include <vector>
16 
17 #include <xercesc/dom/DOM.hpp>
18 #include <xercesc/dom/DOMElement.hpp>
19 #include <xercesc/parsers/XercesDOMParser.hpp>
20 
21 // - - - - - - - - - - - - - - - - - - - -
22 
24 
25 // - - - - - - - - - - - - - - - - - - - -
26 
27 struct DbQuery {
31 };
32 
33 struct DB_ME {
36  int xbins;
37  double xfrom;
38  double xto;
39  int ybins;
40  double yfrom;
41  double yto;
42  int zbins;
43  double zfrom;
44  double zto;
45  unsigned int ncycle;
46  unsigned int loop;
47  std::vector<DbQuery> queries;
48 };
49 
50 // - - - - - - - - - - - - - - - - - - - -
51 
52 class TagNames {
53 public:
54  XMLCh *TAG_DBE;
55  XMLCh *TAG_ME;
56  XMLCh *TAG_1D;
57  XMLCh *TAG_2D;
58  XMLCh *TAG_TPROFILE;
60  XMLCh *TAG_QUERY;
61 
62  XMLCh *ATTR_TITLE;
63  XMLCh *ATTR_XBINS;
64  XMLCh *ATTR_XFROM;
65  XMLCh *ATTR_XTO;
66  XMLCh *ATTR_YBINS;
67  XMLCh *ATTR_YFROM;
68  XMLCh *ATTR_YTO;
69  XMLCh *ATTR_ZBINS;
70  XMLCh *ATTR_ZFROM;
71  XMLCh *ATTR_ZTO;
72  XMLCh *ATTR_NCYCLE;
73  XMLCh *ATTR_LOOP;
74  XMLCh *ATTR_NAME;
75  XMLCh *ATTR_ARG;
76  XMLCh *ATTR_ALIAS;
77 
79  : TAG_DBE(xercesc::XMLString::transcode("dbelements")),
80  TAG_ME(xercesc::XMLString::transcode("me")),
81  TAG_1D(xercesc::XMLString::transcode("th1d")),
82  TAG_2D(xercesc::XMLString::transcode("th2d")),
83  TAG_TPROFILE(xercesc::XMLString::transcode("tprofile")),
84  TAG_TPROFILE2D(xercesc::XMLString::transcode("tprofile2d")),
85  TAG_QUERY(xercesc::XMLString::transcode("query")),
86 
87  ATTR_TITLE(xercesc::XMLString::transcode("title")),
88  ATTR_XBINS(xercesc::XMLString::transcode("xbins")),
89  ATTR_XFROM(xercesc::XMLString::transcode("xfrom")),
90  ATTR_XTO(xercesc::XMLString::transcode("xto")),
91  ATTR_YBINS(xercesc::XMLString::transcode("ybins")),
92  ATTR_YFROM(xercesc::XMLString::transcode("yfrom")),
93  ATTR_YTO(xercesc::XMLString::transcode("yto")),
94  ATTR_ZBINS(xercesc::XMLString::transcode("ybins")),
95  ATTR_ZFROM(xercesc::XMLString::transcode("yfrom")),
96  ATTR_ZTO(xercesc::XMLString::transcode("yto")),
97  ATTR_NCYCLE(xercesc::XMLString::transcode("ncycle")),
98  ATTR_LOOP(xercesc::XMLString::transcode("loop")),
99  ATTR_NAME(xercesc::XMLString::transcode("name")),
100  ATTR_ARG(xercesc::XMLString::transcode("arg")),
101  ATTR_ALIAS(xercesc::XMLString::transcode("alias")) {
102  return;
103  }
104 
105  ~TagNames() noexcept(false) {
106  try {
114 
127 
128  } catch (xercesc::XMLException &e) {
129  char *message = xercesc::XMLString::transcode(e.getMessage());
130 
131  std::ostringstream buf;
132  buf << "Error parsing file: " << message << std::flush;
133 
134  xercesc::XMLString::release(&message);
135 
136  throw(std::runtime_error(buf.str()));
137 
138  } catch (const xercesc::DOMException &e) {
139  char *message = xercesc::XMLString::transcode(e.getMessage());
140 
141  std::ostringstream buf;
142  buf << "Encountered DOM Exception: " << message << std::flush;
143 
144  xercesc::XMLString::release(&message);
145 
146  throw(std::runtime_error(buf.str()));
147  }
148  }
149 
150 }; // class TagNames
151 
152 // - - - - - - - - - - - - - - - - - - - -
153 
155 private:
156  std::vector<DB_ME> DBMonitoringElements_;
158  xercesc::XercesDOMParser *parser_;
160  void handleElement(xercesc::DOMElement *element);
161 
162 public:
163  MonitorXMLParser(const std::string &fromFile);
164 
166 
167  const std::vector<DB_ME> &getDB_ME(void) const { return (DBMonitoringElements_); }
168 
169  void load() noexcept(false);
170 
171 }; // class MonitorXMLParser
172 
173 #endif // MonitorXMLParser_h
MonitorXMLParser::MonitorXMLParser
MonitorXMLParser(const std::string &fromFile)
Definition: MonitorXMLParser.cc:18
TagNames::TAG_DBE
XMLCh * TAG_DBE
Definition: MonitorXMLParser.h:54
TagNames::TAG_ME
XMLCh * TAG_ME
Definition: MonitorXMLParser.h:55
DB_ME::ybins
int ybins
Definition: MonitorXMLParser.h:39
funct::false
false
Definition: Factorize.h:29
ERROR_ARGS
Definition: MonitorXMLParser.h:23
ERROR_PARSE
Definition: MonitorXMLParser.h:23
ERROR_XERCES_INIT
Definition: MonitorXMLParser.h:23
DB_ME::zto
double zto
Definition: MonitorXMLParser.h:44
TagNames::TAG_2D
XMLCh * TAG_2D
Definition: MonitorXMLParser.h:57
MonitorXMLParser
Definition: MonitorXMLParser.h:154
TagNames::TAG_TPROFILE
XMLCh * TAG_TPROFILE
Definition: MonitorXMLParser.h:58
watchdog.const
const
Definition: watchdog.py:83
DbQuery::alias
std::string alias
Definition: MonitorXMLParser.h:30
MonitorXMLParser::load
void load() noexcept(false)
Definition: MonitorXMLParser.cc:402
TagNames::ATTR_XBINS
XMLCh * ATTR_XBINS
Definition: MonitorXMLParser.h:63
DB_ME::queries
std::vector< DbQuery > queries
Definition: MonitorXMLParser.h:47
MonitorXMLParser::DBMonitoringElements_
std::vector< DB_ME > DBMonitoringElements_
Definition: MonitorXMLParser.h:156
TagNames::ATTR_NCYCLE
XMLCh * ATTR_NCYCLE
Definition: MonitorXMLParser.h:72
MonitorXMLParser::parser_
xercesc::XercesDOMParser * parser_
Definition: MonitorXMLParser.h:158
DB_ME::yfrom
double yfrom
Definition: MonitorXMLParser.h:40
DB_ME::loop
unsigned int loop
Definition: MonitorXMLParser.h:46
DB_ME::zbins
int zbins
Definition: MonitorXMLParser.h:42
TagNames::~TagNames
~TagNames() noexcept(false)
Definition: MonitorXMLParser.h:105
TagNames::ATTR_ZTO
XMLCh * ATTR_ZTO
Definition: MonitorXMLParser.h:71
TagNames::ATTR_ZBINS
XMLCh * ATTR_ZBINS
Definition: MonitorXMLParser.h:69
TagNames::ATTR_YFROM
XMLCh * ATTR_YFROM
Definition: MonitorXMLParser.h:67
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TagNames::ATTR_NAME
XMLCh * ATTR_NAME
Definition: MonitorXMLParser.h:74
TagNames::ATTR_XTO
XMLCh * ATTR_XTO
Definition: MonitorXMLParser.h:65
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
DB_ME
Definition: MonitorXMLParser.h:33
TagNames::ATTR_ALIAS
XMLCh * ATTR_ALIAS
Definition: MonitorXMLParser.h:76
MonitorXMLParser::xmlFile_
std::string xmlFile_
Definition: MonitorXMLParser.h:157
DB_ME::yto
double yto
Definition: MonitorXMLParser.h:41
TagNames::ATTR_LOOP
XMLCh * ATTR_LOOP
Definition: MonitorXMLParser.h:73
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
DbQuery
Definition: MonitorXMLParser.h:27
DB_ME::title
std::string title
Definition: MonitorXMLParser.h:35
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
DB_ME::xto
double xto
Definition: MonitorXMLParser.h:38
std
Definition: JetResolutionObject.h:76
TagNames::ATTR_XFROM
XMLCh * ATTR_XFROM
Definition: MonitorXMLParser.h:64
TagNames::TAG_1D
XMLCh * TAG_1D
Definition: MonitorXMLParser.h:56
MonitorXMLParser::getDB_ME
const std::vector< DB_ME > & getDB_ME(void) const
Definition: MonitorXMLParser.h:167
DB_ME::xbins
int xbins
Definition: MonitorXMLParser.h:36
DB_ME::zfrom
double zfrom
Definition: MonitorXMLParser.h:43
DbQuery::arg
std::string arg
Definition: MonitorXMLParser.h:29
TagNames::ATTR_YBINS
XMLCh * ATTR_YBINS
Definition: MonitorXMLParser.h:66
MonitorXMLParser::tags_
TagNames * tags_
Definition: MonitorXMLParser.h:159
TagNames::TAG_QUERY
XMLCh * TAG_QUERY
Definition: MonitorXMLParser.h:60
DbQuery::query
std::string query
Definition: MonitorXMLParser.h:28
TagNames::TAG_TPROFILE2D
XMLCh * TAG_TPROFILE2D
Definition: MonitorXMLParser.h:59
MonitorXMLParser::~MonitorXMLParser
~MonitorXMLParser()
Definition: MonitorXMLParser.cc:39
TagNames::TagNames
TagNames()
Definition: MonitorXMLParser.h:78
ALCARECOPromptCalibProdSiPixelAli0T_cff.throw
throw
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:9
TagNames::ATTR_ARG
XMLCh * ATTR_ARG
Definition: MonitorXMLParser.h:75
TagNames
Definition: MonitorXMLParser.h:52
DB_ME::type
std::string type
Definition: MonitorXMLParser.h:34
TagNames::ATTR_YTO
XMLCh * ATTR_YTO
Definition: MonitorXMLParser.h:68
TagNames::ATTR_ZFROM
XMLCh * ATTR_ZFROM
Definition: MonitorXMLParser.h:70
ERROR_EMPTY_DOCUMENT
Definition: MonitorXMLParser.h:23
TagNames::ATTR_TITLE
XMLCh * ATTR_TITLE
Definition: MonitorXMLParser.h:62
MonitorXMLParser::handleElement
void handleElement(xercesc::DOMElement *element)
Definition: MonitorXMLParser.cc:54
DB_ME::xfrom
double xfrom
Definition: MonitorXMLParser.h:37
DB_ME::ncycle
unsigned int ncycle
Definition: MonitorXMLParser.h:45
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37