test
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 
8 #ifndef MonitorXMLParser_h
9 #define MonitorXMLParser_h
10 
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <iostream>
15 
16 #include <xercesc/dom/DOM.hpp>
17 #include <xercesc/dom/DOMElement.hpp>
18 #include <xercesc/parsers/XercesDOMParser.hpp>
19 
20 // - - - - - - - - - - - - - - - - - - - -
21 
22 enum { ERROR_ARGS = 1 ,
26 };
27 
28 // - - - - - - - - - - - - - - - - - - - -
29 
33 
36  int xbins; double xfrom; double xto;
37  int ybins; double yfrom; double yto;
38  int zbins; double zfrom; double zto;
39  unsigned int ncycle;
40  unsigned int loop;
41  std::vector< DbQuery > queries; };
42 
43 // - - - - - - - - - - - - - - - - - - - -
44 
45 class TagNames {
46 
47 public:
48  XMLCh* TAG_DBE;
49  XMLCh* TAG_ME;
50  XMLCh* TAG_1D;
51  XMLCh* TAG_2D;
52  XMLCh* TAG_TPROFILE;
54  XMLCh* TAG_QUERY;
55 
56  XMLCh* ATTR_TITLE;
57  XMLCh* ATTR_XBINS;
58  XMLCh* ATTR_XFROM;
59  XMLCh* ATTR_XTO;
60  XMLCh* ATTR_YBINS;
61  XMLCh* ATTR_YFROM;
62  XMLCh* ATTR_YTO;
63  XMLCh* ATTR_ZBINS;
64  XMLCh* ATTR_ZFROM;
65  XMLCh* ATTR_ZTO;
66  XMLCh* ATTR_NCYCLE;
67  XMLCh* ATTR_LOOP;
68  XMLCh* ATTR_NAME;
69  XMLCh* ATTR_ARG;
70  XMLCh* ATTR_ALIAS;
71 
73  TAG_DBE( xercesc::XMLString::transcode( "dbelements" ) ),
74  TAG_ME( xercesc::XMLString::transcode( "me" ) ),
75  TAG_1D( xercesc::XMLString::transcode( "th1d" ) ),
76  TAG_2D( xercesc::XMLString::transcode( "th2d" ) ),
77  TAG_TPROFILE( xercesc::XMLString::transcode( "tprofile" ) ),
78  TAG_TPROFILE2D( xercesc::XMLString::transcode( "tprofile2d" ) ),
79  TAG_QUERY( xercesc::XMLString::transcode( "query" ) ),
80 
81  ATTR_TITLE( xercesc::XMLString::transcode( "title" ) ),
82  ATTR_XBINS( xercesc::XMLString::transcode( "xbins" ) ),
83  ATTR_XFROM( xercesc::XMLString::transcode( "xfrom" ) ),
84  ATTR_XTO( xercesc::XMLString::transcode( "xto" ) ),
85  ATTR_YBINS( xercesc::XMLString::transcode( "ybins" ) ),
86  ATTR_YFROM( xercesc::XMLString::transcode( "yfrom" ) ),
87  ATTR_YTO( xercesc::XMLString::transcode( "yto" ) ),
88  ATTR_ZBINS( xercesc::XMLString::transcode( "ybins" ) ),
89  ATTR_ZFROM( xercesc::XMLString::transcode( "yfrom" ) ),
90  ATTR_ZTO( xercesc::XMLString::transcode( "yto" ) ),
91  ATTR_NCYCLE( xercesc::XMLString::transcode( "ncycle" ) ),
92  ATTR_LOOP( xercesc::XMLString::transcode( "loop" ) ),
93  ATTR_NAME( xercesc::XMLString::transcode( "name" ) ),
94  ATTR_ARG( xercesc::XMLString::transcode( "arg" ) ),
95  ATTR_ALIAS( xercesc::XMLString::transcode( "alias" ) ) {
96 
97  return ;
98 
99  }
100 
101 
103 
104  try{
105 
113 
126 
127  }catch( xercesc::XMLException& e ){
128 
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 
140  char* message = xercesc::XMLString::transcode( e.getMessage() );
141 
142  std::ostringstream buf;
143  buf << "Encountered DOM Exception: " << message << std::flush;
144 
145  xercesc::XMLString::release( &message );
146 
147  throw( std::runtime_error( buf.str() ) );
148 
149  }
150 
151  }
152 
153 }; // class TagNames
154 
155 
156 // - - - - - - - - - - - - - - - - - - - -
157 
158 
160 
161 private:
162 
163  std::vector< DB_ME > DBMonitoringElements_;
165  xercesc::XercesDOMParser* parser_;
167  void handleElement( xercesc::DOMElement* element );
168 
169 public:
170 
171  MonitorXMLParser( const std::string& fromFile );
172 
174 
175  const std::vector< DB_ME > & getDB_ME( void ) const { return (DBMonitoringElements_ ); }
176 
177  void load() throw( std::runtime_error );
178 
179 }; // class MonitorXMLParser
180 
181 #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
XMLCh * transcode(const T &fInput)
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
return(e1-e2)*(e1-e2)+dp *dp
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