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 <string>
12 #include <sstream>
13 #include <vector>
14 #include <map>
15 #include <iostream>
16 
17 #include <xercesc/dom/DOM.hpp>
18 #include <xercesc/dom/DOMElement.hpp>
19 #include <xercesc/parsers/XercesDOMParser.hpp>
20 
21 // - - - - - - - - - - - - - - - - - - - -
22 
23 enum { ERROR_ARGS = 1 ,
27 };
28 
29 // - - - - - - - - - - - - - - - - - - - -
30 
34 
37  int xbins; double xfrom; double xto;
38  int ybins; double yfrom; double yto;
39  int zbins; double zfrom; double zto;
40  unsigned int ncycle;
41  unsigned int loop;
42  std::vector< DbQuery > queries; };
43 
44 // - - - - - - - - - - - - - - - - - - - -
45 
46 class TagNames {
47 
48 public:
49  XMLCh* TAG_DBE;
50  XMLCh* TAG_ME;
51  XMLCh* TAG_1D;
52  XMLCh* TAG_2D;
53  XMLCh* TAG_TPROFILE;
55  XMLCh* TAG_QUERY;
56 
57  XMLCh* ATTR_TITLE;
58  XMLCh* ATTR_XBINS;
59  XMLCh* ATTR_XFROM;
60  XMLCh* ATTR_XTO;
61  XMLCh* ATTR_YBINS;
62  XMLCh* ATTR_YFROM;
63  XMLCh* ATTR_YTO;
64  XMLCh* ATTR_ZBINS;
65  XMLCh* ATTR_ZFROM;
66  XMLCh* ATTR_ZTO;
67  XMLCh* ATTR_NCYCLE;
68  XMLCh* ATTR_LOOP;
69  XMLCh* ATTR_NAME;
70  XMLCh* ATTR_ARG;
71  XMLCh* ATTR_ALIAS;
72 
74  TAG_DBE( xercesc::XMLString::transcode( "dbelements" ) ),
75  TAG_ME( xercesc::XMLString::transcode( "me" ) ),
76  TAG_1D( xercesc::XMLString::transcode( "th1d" ) ),
77  TAG_2D( xercesc::XMLString::transcode( "th2d" ) ),
78  TAG_TPROFILE( xercesc::XMLString::transcode( "tprofile" ) ),
79  TAG_TPROFILE2D( xercesc::XMLString::transcode( "tprofile2d" ) ),
80  TAG_QUERY( xercesc::XMLString::transcode( "query" ) ),
81 
82  ATTR_TITLE( xercesc::XMLString::transcode( "title" ) ),
83  ATTR_XBINS( xercesc::XMLString::transcode( "xbins" ) ),
84  ATTR_XFROM( xercesc::XMLString::transcode( "xfrom" ) ),
85  ATTR_XTO( xercesc::XMLString::transcode( "xto" ) ),
86  ATTR_YBINS( xercesc::XMLString::transcode( "ybins" ) ),
87  ATTR_YFROM( xercesc::XMLString::transcode( "yfrom" ) ),
88  ATTR_YTO( xercesc::XMLString::transcode( "yto" ) ),
89  ATTR_ZBINS( xercesc::XMLString::transcode( "ybins" ) ),
90  ATTR_ZFROM( xercesc::XMLString::transcode( "yfrom" ) ),
91  ATTR_ZTO( xercesc::XMLString::transcode( "yto" ) ),
92  ATTR_NCYCLE( xercesc::XMLString::transcode( "ncycle" ) ),
93  ATTR_LOOP( xercesc::XMLString::transcode( "loop" ) ),
94  ATTR_NAME( xercesc::XMLString::transcode( "name" ) ),
95  ATTR_ARG( xercesc::XMLString::transcode( "arg" ) ),
96  ATTR_ALIAS( xercesc::XMLString::transcode( "alias" ) ) {
97 
98  return ;
99 
100  }
101 
102 
104 
105  try{
106 
107  xercesc::XMLString::release( &TAG_DBE ) ;
108  xercesc::XMLString::release( &TAG_ME ) ;
109  xercesc::XMLString::release( &TAG_1D ) ;
110  xercesc::XMLString::release( &TAG_2D ) ;
111  xercesc::XMLString::release( &TAG_TPROFILE ) ;
112  xercesc::XMLString::release( &TAG_TPROFILE2D ) ;
113  xercesc::XMLString::release( &TAG_QUERY ) ;
114 
115  xercesc::XMLString::release( &ATTR_TITLE ) ;
116  xercesc::XMLString::release( &ATTR_XFROM ) ;
117  xercesc::XMLString::release( &ATTR_XTO ) ;
118  xercesc::XMLString::release( &ATTR_XBINS ) ;
119  xercesc::XMLString::release( &ATTR_YFROM ) ;
120  xercesc::XMLString::release( &ATTR_YTO ) ;
121  xercesc::XMLString::release( &ATTR_YBINS ) ;
122  xercesc::XMLString::release( &ATTR_NCYCLE ) ;
123  xercesc::XMLString::release( &ATTR_LOOP ) ;
124  xercesc::XMLString::release( &ATTR_NAME ) ;
125  xercesc::XMLString::release( &ATTR_ARG ) ;
126  xercesc::XMLString::release( &ATTR_ALIAS ) ;
127 
128  }catch( xercesc::XMLException& e ){
129 
130  char* message = xercesc::XMLString::transcode( e.getMessage() );
131 
132  std::ostringstream buf ;
133  buf << "Error parsing file: " << message << std::flush;
134 
135  xercesc::XMLString::release( &message );
136 
137  throw( std::runtime_error( buf.str() ) );
138 
139  }catch( const xercesc::DOMException& e ){
140 
141  char* message = xercesc::XMLString::transcode( e.getMessage() );
142 
143  std::ostringstream buf;
144  buf << "Encountered DOM Exception: " << message << std::flush;
145 
146  xercesc::XMLString::release( &message );
147 
148  throw( std::runtime_error( buf.str() ) );
149 
150  }
151 
152  }
153 
154 }; // class TagNames
155 
156 
157 // - - - - - - - - - - - - - - - - - - - -
158 
159 
161 
162 private:
163 
164  std::vector< DB_ME > DBMonitoringElements_;
166  xercesc::XercesDOMParser* parser_;
168  void handleElement( xercesc::DOMElement* element );
169 
170 public:
171 
172  MonitorXMLParser( const std::string& fromFile );
173 
174  ~MonitorXMLParser() throw();
175 
176  const std::vector< DB_ME > & getDB_ME( void ) const { return (DBMonitoringElements_ ); }
177 
178  void load() noexcept(false);
179 
180 }; // class MonitorXMLParser
181 
182 #endif // MonitorXMLParser_h
XMLCh * TAG_ME
std::string type
XMLCh * TAG_QUERY
XMLCh * ATTR_YTO
std::string xmlFile_
XMLCh * ATTR_ZBINS
const double xbins[]
XMLCh * ATTR_XBINS
XMLCh * ATTR_ARG
#define noexcept
std::string alias
XMLCh * TAG_2D
double xto
unsigned int ncycle
return((rh^lh)&mask)
XMLCh * ATTR_YFROM
~TagNames() noexcept(false)
double yto
std::vector< DbQuery > queries
std::vector< DB_ME > DBMonitoringElements_
XMLCh * ATTR_ZTO
XMLCh * TAG_1D
XMLCh * ATTR_YBINS
XMLCh * ATTR_NAME
std::string title
XMLCh * ATTR_XTO
unsigned int loop
XMLCh * TAG_TPROFILE2D
XMLCh * ATTR_ALIAS
std::string arg
def load(fileName)
Definition: svgfig.py:546
XMLCh * ATTR_NCYCLE
double zto
XMLCh * ATTR_TITLE
XMLCh * ATTR_LOOP
std::string query
XMLCh * ATTR_XFROM
XMLCh * TAG_TPROFILE
xercesc::XercesDOMParser * parser_
XMLCh * TAG_DBE
XMLCh * ATTR_ZFROM