CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MonitorXMLParser.h
Go to the documentation of this file.
1 // $Id: MonitorXMLParser.h,v 1.7 2008/04/03 05:51:36 dellaric Exp $
2 
11 #ifndef MonitorXMLParser_h
12 #define MonitorXMLParser_h
13 
14 #include <string>
15 #include <vector>
16 #include <map>
17 #include <iostream>
18 
19 #include <xercesc/dom/DOM.hpp>
20 #include <xercesc/dom/DOMElement.hpp>
21 #include <xercesc/parsers/XercesDOMParser.hpp>
22 
23 // - - - - - - - - - - - - - - - - - - - -
24 
25 enum { ERROR_ARGS = 1 ,
29 };
30 
31 // - - - - - - - - - - - - - - - - - - - -
32 
33 struct DbQuery { std::string query;
34  std::string arg;
35  std::string alias; };
36 
37 struct DB_ME { std::string type;
38  std::string title;
39  int xbins; double xfrom; double xto;
40  int ybins; double yfrom; double yto;
41  int zbins; double zfrom; double zto;
42  unsigned int ncycle;
43  unsigned int loop;
44  std::vector< DbQuery > queries; };
45 
46 // - - - - - - - - - - - - - - - - - - - -
47 
48 class TagNames {
49 
50 public:
51  XMLCh* TAG_DBE;
52  XMLCh* TAG_ME;
53  XMLCh* TAG_1D;
54  XMLCh* TAG_2D;
55  XMLCh* TAG_TPROFILE;
57  XMLCh* TAG_QUERY;
58 
59  XMLCh* ATTR_TITLE;
60  XMLCh* ATTR_XBINS;
61  XMLCh* ATTR_XFROM;
62  XMLCh* ATTR_XTO;
63  XMLCh* ATTR_YBINS;
64  XMLCh* ATTR_YFROM;
65  XMLCh* ATTR_YTO;
66  XMLCh* ATTR_ZBINS;
67  XMLCh* ATTR_ZFROM;
68  XMLCh* ATTR_ZTO;
69  XMLCh* ATTR_NCYCLE;
70  XMLCh* ATTR_LOOP;
71  XMLCh* ATTR_NAME;
72  XMLCh* ATTR_ARG;
73  XMLCh* ATTR_ALIAS;
74 
76  TAG_DBE( xercesc::XMLString::transcode( "dbelements" ) ),
77  TAG_ME( xercesc::XMLString::transcode( "me" ) ),
78  TAG_1D( xercesc::XMLString::transcode( "th1d" ) ),
79  TAG_2D( xercesc::XMLString::transcode( "th2d" ) ),
80  TAG_TPROFILE( xercesc::XMLString::transcode( "tprofile" ) ),
81  TAG_TPROFILE2D( xercesc::XMLString::transcode( "tprofile2d" ) ),
82  TAG_QUERY( xercesc::XMLString::transcode( "query" ) ),
83 
84  ATTR_TITLE( xercesc::XMLString::transcode( "title" ) ),
85  ATTR_XBINS( xercesc::XMLString::transcode( "xbins" ) ),
86  ATTR_XFROM( xercesc::XMLString::transcode( "xfrom" ) ),
87  ATTR_XTO( xercesc::XMLString::transcode( "xto" ) ),
88  ATTR_YBINS( xercesc::XMLString::transcode( "ybins" ) ),
89  ATTR_YFROM( xercesc::XMLString::transcode( "yfrom" ) ),
90  ATTR_YTO( xercesc::XMLString::transcode( "yto" ) ),
91  ATTR_ZBINS( xercesc::XMLString::transcode( "ybins" ) ),
92  ATTR_ZFROM( xercesc::XMLString::transcode( "yfrom" ) ),
93  ATTR_ZTO( xercesc::XMLString::transcode( "yto" ) ),
94  ATTR_NCYCLE( xercesc::XMLString::transcode( "ncycle" ) ),
95  ATTR_LOOP( xercesc::XMLString::transcode( "loop" ) ),
96  ATTR_NAME( xercesc::XMLString::transcode( "name" ) ),
97  ATTR_ARG( xercesc::XMLString::transcode( "arg" ) ),
98  ATTR_ALIAS( xercesc::XMLString::transcode( "alias" ) ) {
99 
100  return ;
101 
102  }
103 
104 
106 
107  try{
108 
116 
129 
130  }catch( xercesc::XMLException& e ){
131 
132  char* message = xercesc::XMLString::transcode( e.getMessage() );
133 
134  std::ostringstream buf ;
135  buf << "Error parsing file: " << message << std::flush;
136 
137  xercesc::XMLString::release( &message );
138 
139  throw( std::runtime_error( buf.str() ) );
140 
141  }catch( const xercesc::DOMException& e ){
142 
143  char* message = xercesc::XMLString::transcode( e.getMessage() );
144 
145  std::ostringstream buf;
146  buf << "Encountered DOM Exception: " << message << std::flush;
147 
148  xercesc::XMLString::release( &message );
149 
150  throw( std::runtime_error( buf.str() ) );
151 
152  }
153 
154  }
155 
156 }; // class TagNames
157 
158 
159 // - - - - - - - - - - - - - - - - - - - -
160 
161 
163 
164 private:
165 
166  std::vector< DB_ME > DBMonitoringElements_;
167  std::string xmlFile_;
168  xercesc::XercesDOMParser* parser_;
170  void handleElement( xercesc::DOMElement* element );
171 
172 public:
173 
174  MonitorXMLParser( const std::string& fromFile );
175 
177 
178  const std::vector< DB_ME > & getDB_ME( void ) const { return (DBMonitoringElements_ ); }
179 
180  void load() throw( std::runtime_error );
181 
182 }; // class MonitorXMLParser
183 
184 #endif // MonitorXMLParser_h
XMLCh * TAG_ME
std::string type
XMLCh * TAG_QUERY
XMLCh * ATTR_YTO
std::string xmlFile_
XMLCh * ATTR_ZBINS
XMLCh * ATTR_XBINS
XMLCh * ATTR_ARG
MonitorXMLParser(const std::string &fromFile)
std::string alias
XMLCh * TAG_2D
double xto
unsigned int ncycle
double yfrom
XMLCh * ATTR_YFROM
double yto
std::vector< DbQuery > queries
const std::vector< DB_ME > & getDB_ME(void) const
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
string const
Definition: compareJSON.py:14
XMLCh * ATTR_NCYCLE
double zto
XMLCh * ATTR_TITLE
XMLCh * ATTR_LOOP
std::string query
XMLCh * ATTR_XFROM
XMLCh * TAG_TPROFILE
double xfrom
xercesc::XercesDOMParser * parser_
XMLCh * TAG_DBE
XMLCh * ATTR_ZFROM