CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
XMLCh * TAG_ME
std::string type
XMLCh * TAG_QUERY
XMLCh * ATTR_YTO
std::string xmlFile_
XMLCh * ATTR_ZBINS
XMLCh * ATTR_XBINS
const std::vector< DB_ME > & getDB_ME(void) const
XMLCh * ATTR_ARG
MonitorXMLParser(const std::string &fromFile)
std::string alias
XMLCh * TAG_2D
double xto
unsigned int ncycle
double yfrom
XMLCh * ATTR_YFROM
~TagNames() noexcept(false)
double yto
void load() noexcept(false)
std::vector< DB_ME > DBMonitoringElements_
XMLCh * ATTR_ZTO
XMLCh * TAG_1D
XMLCh * ATTR_YBINS
double zfrom
XMLCh * ATTR_NAME
std::string title
XMLCh * ATTR_XTO
unsigned int loop
void handleElement(xercesc::DOMElement *element)
XMLCh * TAG_TPROFILE2D
XMLCh * ATTR_ALIAS
std::string arg
XMLCh * ATTR_NCYCLE
double zto
XMLCh * ATTR_TITLE
XMLCh * ATTR_LOOP
std::string query
XMLCh * ATTR_XFROM
std::vector< DbQuery > queries
XMLCh * TAG_TPROFILE
double xfrom
xercesc::XercesDOMParser * parser_
XMLCh * TAG_DBE
XMLCh * ATTR_ZFROM