CMS 3D CMS Logo

XMLProcessor.h
Go to the documentation of this file.
1 #ifndef HCALConfigDBTools_XMLTools_XMLProcessor_h
2 #define HCALConfigDBTools_XMLTools_XMLProcessor_h
3 // -*- C++ -*-
4 //
5 // Package: XMLTools
6 // Class : XMLProcessor
7 //
16 //
17 // Original Author: Gena Kukartsev
18 // Created: Sun Sep 23 16:57:06 CEST 2007
19 //
20 
21 // system include files
22 #include <vector>
23 #include <string>
24 #include <ctime>
25 #include <xercesc/dom/DOM.hpp>
26 #include <xercesc/util/XMLString.hpp>
28 #include <xercesc/dom/DOMNode.hpp>
29 #include <xercesc/framework/MemBufInputSource.hpp>
30 #include <cstdio>
31 
32 #if defined(XERCES_NEW_IOSTREAMS)
33 #include <iostream>
34 #else
35 #include <iostream.h>
36 #endif
37 
39 
40 class XMLProcessor {
41 public:
42  typedef struct _loaderBaseConfig {
57 
58  typedef struct _LMapRowHBEF {
59  int side;
60  int eta;
61  int phi;
62  int dphi;
63  int depth;
66  int wedge;
67  int rm;
68  int pixel;
69  int qie;
70  int adc;
71  int rm_fi;
72  int fi_ch;
73  int crate;
74  int htr;
76  int htr_fi;
77  int dcc_sl;
78  int spigo;
79  int dcc;
80  int slb;
84  int rctcra;
85  int rctcar;
86  int rctcon;
88  int fedid;
89  } LMapRowHBEF;
90 
91  typedef struct _LMapRowHO {
92  int sideO;
93  int etaO;
94  int phiO;
95  int dphiO;
96  int depthO;
99  int sectorO;
100  int rmO;
101  int pixelO;
102  int qieO;
103  int adcO;
104  int rm_fiO;
105  int fi_chO;
107  int crateO;
108  int htrO;
110  int htr_fiO;
111  int dcc_slO;
112  int spigoO;
113  int dccO;
114  int fedidO;
115  } LMapRowHO;
116 
117  typedef struct _DBConfig {
118  _DBConfig();
123  } DBConfig;
124 
125  typedef struct _lutDBConfig : public _DBConfig {
127  } lutDBConfig;
128 
129  typedef struct _checksumsDBConfig : public _DBConfig {
132 
133  // this class is a singleton
135  if (!instance)
136  instance = new XMLProcessor();
137  return instance;
138  }
139 
140  // returns XML std::string if target == "string" otherwise NULL
141  XMLCh* serializeDOM(XERCES_CPP_NAMESPACE::DOMNode* node, std::string target = "stdout");
142 
143  inline static XMLCh* _toXMLCh(std::string temp);
144  inline static XMLCh* _toXMLCh(int temp);
145  inline static XMLCh* _toXMLCh(double temp);
146  inline static XMLCh* _toXMLCh(time_t temp);
147  virtual ~XMLProcessor();
148 
149  int test(void);
150  int init(void);
151  int terminate(void);
152 
153  XMLDOMBlock* createLMapHBEFXMLBase(std::string templateFileName);
154  XMLDOMBlock* createLMapHOXMLBase(std::string templateFileName);
155 
156  int addLMapHBEFDataset(XMLDOMBlock* doc, LMapRowHBEF* row, std::string templateFileName);
157  int addLMapHODataset(XMLDOMBlock* doc, LMapRowHO* row, std::string templateFileName);
158 
159  int write(XMLDOMBlock* doc, std::string target = "stdout");
160 
161 private:
162  XMLProcessor();
163 
164  XMLProcessor(const XMLProcessor&) = delete; // stop default
165 
166  //const XMLProcessor& operator=(const XMLProcessor&); // stop default
167 
168  // ---------- member data --------------------------------
170 };
171 
173  XMLCh* buff = XERCES_CPP_NAMESPACE::XMLString::transcode(temp.c_str());
174  return buff;
175 }
176 
177 inline XMLCh* XMLProcessor::_toXMLCh(int temp) {
178  char buf[100];
179  int status = snprintf(buf, 100, "%d", temp);
180  if (status >= 100) {
181  std::cout << "XMLProcessor::_toXMLCh(int temp): buffer overflow, the std::string will be truncated!" << std::endl;
182  } else if (status < 0) {
183  std::cout << "XMLProcessor::_toXMLCh(int temp): output error" << std::endl;
184  }
185  XMLCh* buff = XERCES_CPP_NAMESPACE::XMLString::transcode(buf);
186  return buff;
187 }
188 
189 inline XMLCh* XMLProcessor::_toXMLCh(double temp) {
190  char buf[100];
191  int status = snprintf(buf, 100, "%.10e", temp);
192  if (status >= 100) {
193  std::cout << "XMLProcessor::_toXMLCh(int temp): buffer overflow, the std::string will be truncated!" << std::endl;
194  } else if (status < 0) {
195  std::cout << "XMLProcessor::_toXMLCh(int temp): output error" << std::endl;
196  }
197  XMLCh* buff = XERCES_CPP_NAMESPACE::XMLString::transcode(buf);
198  return buff;
199 }
200 
201 inline XMLCh* XMLProcessor::_toXMLCh(time_t temp) {
202  char buf[100];
203  int status = strftime(buf, 50, "%c", gmtime(&temp));
204  if (status == 0) {
205  std::cout << "XML Processor::_toXMLCh(int temp): buffer overflow, the std::string is indeterminate!" << std::endl;
206  }
207  XMLCh* buff = XERCES_CPP_NAMESPACE::XMLString::transcode(buf);
208  return buff;
209 }
210 
211 #endif
XMLProcessor::_LMapRowHO::rmO
int rmO
Definition: XMLProcessor.h:100
XMLProcessor::_LMapRowHBEF::eta
int eta
Definition: XMLProcessor.h:60
XMLProcessor::_toXMLCh
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:172
XMLProcessor::_LMapRowHO::fpgaO
std::string fpgaO
Definition: XMLProcessor.h:109
common_cff.doc
doc
Definition: common_cff.py:54
XMLProcessor::_LMapRowHO::spigoO
int spigoO
Definition: XMLProcessor.h:112
XMLProcessor::_DBConfig::create_timestamp
time_t create_timestamp
Definition: XMLProcessor.h:121
XMLProcessor::_LMapRowHBEF::rctcra
int rctcra
Definition: XMLProcessor.h:84
XMLProcessor::instance
static XMLProcessor * instance
Definition: XMLProcessor.h:169
XMLProcessor::getInstance
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:134
XMLProcessor::_LMapRowHO::rm_fiO
int rm_fiO
Definition: XMLProcessor.h:104
XMLProcessor::createLMapHBEFXMLBase
XMLDOMBlock * createLMapHBEFXMLBase(std::string templateFileName)
Definition: XMLProcessor.cc:77
XMLProcessor::LMapRowHBEF
struct XMLProcessor::_LMapRowHBEF LMapRowHBEF
XMLProcessor::_LMapRowHBEF::depth
int depth
Definition: XMLProcessor.h:63
XMLProcessor::_LMapRowHBEF::dcc
int dcc
Definition: XMLProcessor.h:79
XMLProcessor::_LMapRowHBEF::qie
int qie
Definition: XMLProcessor.h:69
XMLProcessor::init
int init(void)
Definition: XMLProcessor.cc:296
mps_update.status
status
Definition: mps_update.py:69
XMLProcessor::_LMapRowHBEF::rm_fi
int rm_fi
Definition: XMLProcessor.h:71
XMLProcessor::_LMapRowHO::detO
std::string detO
Definition: XMLProcessor.h:97
XMLProcessor::_LMapRowHO::pixelO
int pixelO
Definition: XMLProcessor.h:101
XMLProcessor::terminate
int terminate(void)
Definition: XMLProcessor.cc:313
XMLProcessor::_loaderBaseConfig::iov_begin
std::string iov_begin
Definition: XMLProcessor.h:49
XMLProcessor::_loaderBaseConfig::tag_id
std::string tag_id
Definition: XMLProcessor.h:51
gather_cfg.cout
cout
Definition: gather_cfg.py:144
XMLProcessor::_LMapRowHO::dphiO
int dphiO
Definition: XMLProcessor.h:95
XMLProcessor::_LMapRowHO::let_codeO
std::string let_codeO
Definition: XMLProcessor.h:106
XMLProcessor::_LMapRowHO::depthO
int depthO
Definition: XMLProcessor.h:96
XMLProcessor
Definition: XMLProcessor.h:40
XMLProcessor::_LMapRowHBEF::wedge
int wedge
Definition: XMLProcessor.h:66
XMLProcessor::_LMapRowHBEF::rctnam
std::string rctnam
Definition: XMLProcessor.h:87
XMLProcessor::lutDBConfig
XMLProcessor::_lutDBConfig lutDBConfig
XMLProcessor::_checksumsDBConfig::comment
std::string comment
Definition: XMLProcessor.h:130
XMLProcessor::_lutDBConfig
Definition: XMLProcessor.h:125
XMLProcessor::_LMapRowHO::adcO
int adcO
Definition: XMLProcessor.h:103
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
XMLProcessor::_loaderBaseConfig::comment_description
std::string comment_description
Definition: XMLProcessor.h:55
XMLProcessor::_LMapRowHO::dccO
int dccO
Definition: XMLProcessor.h:113
XMLProcessor::_loaderBaseConfig::tag_name
std::string tag_name
Definition: XMLProcessor.h:53
XMLProcessor::_LMapRowHBEF::phi
int phi
Definition: XMLProcessor.h:61
XMLProcessor::_LMapRowHO
Definition: XMLProcessor.h:91
XMLDOMBlock
Definition: XMLDOMBlock.h:39
XMLProcessor::_LMapRowHBEF::htr
int htr
Definition: XMLProcessor.h:74
XMLProcessor::_LMapRowHO::fi_chO
int fi_chO
Definition: XMLProcessor.h:105
XMLProcessor::_loaderBaseConfig::data_set_id
std::string data_set_id
Definition: XMLProcessor.h:47
XMLProcessor::_LMapRowHO::crateO
int crateO
Definition: XMLProcessor.h:107
XMLProcessor::_loaderBaseConfig::extention_table_name
std::string extention_table_name
Definition: XMLProcessor.h:44
XMLProcessor::_LMapRowHBEF::crate
int crate
Definition: XMLProcessor.h:73
XMLProcessor::addLMapHODataset
int addLMapHODataset(XMLDOMBlock *doc, LMapRowHO *row, std::string templateFileName)
Definition: XMLProcessor.cc:158
XMLProcessor::test
int test(void)
Definition: XMLProcessor.cc:218
XMLProcessor::_DBConfig::subversion
std::string subversion
Definition: XMLProcessor.h:120
XMLProcessor::_LMapRowHBEF::rctcar
int rctcar
Definition: XMLProcessor.h:85
XMLProcessor::checksumsDBConfig
XMLProcessor::_checksumsDBConfig checksumsDBConfig
XMLProcessor::loaderBaseConfig
struct XMLProcessor::_loaderBaseConfig loaderBaseConfig
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
XMLProcessor::_loaderBaseConfig::tag_mode
std::string tag_mode
Definition: XMLProcessor.h:52
XMLProcessor::_LMapRowHBEF::dphi
int dphi
Definition: XMLProcessor.h:62
XMLProcessor::_LMapRowHBEF::slb
int slb
Definition: XMLProcessor.h:80
XMLProcessor::XMLProcessor
XMLProcessor()
Definition: XMLProcessor.cc:44
XMLProcessor::_LMapRowHBEF::fi_ch
int fi_ch
Definition: XMLProcessor.h:72
XMLProcessor::_loaderBaseConfig::_loaderBaseConfig
_loaderBaseConfig()
Definition: XMLProcessor.cc:55
XMLProcessor::_loaderBaseConfig::iov_id
std::string iov_id
Definition: XMLProcessor.h:48
XMLProcessor::_checksumsDBConfig
Definition: XMLProcessor.h:129
XMLProcessor::_LMapRowHBEF::htr_fi
int htr_fi
Definition: XMLProcessor.h:76
XMLProcessor::_LMapRowHO::fedidO
int fedidO
Definition: XMLProcessor.h:114
XMLProcessor::serializeDOM
XMLCh * serializeDOM(XERCES_CPP_NAMESPACE::DOMNode *node, std::string target="stdout")
Definition: XMLProcessor.cc:245
XMLProcessor::_LMapRowHBEF::fpga
std::string fpga
Definition: XMLProcessor.h:75
XMLProcessor::_DBConfig::version
std::string version
Definition: XMLProcessor.h:119
XMLProcessor::_DBConfig
Definition: XMLProcessor.h:117
XMLProcessor::_loaderBaseConfig::name
std::string name
Definition: XMLProcessor.h:45
XMLProcessor::_LMapRowHO::htr_fiO
int htr_fiO
Definition: XMLProcessor.h:110
Xerces.h
XMLProcessor::DBConfig
struct XMLProcessor::_DBConfig DBConfig
XMLProcessor::createLMapHOXMLBase
XMLDOMBlock * createLMapHOXMLBase(std::string templateFileName)
Definition: XMLProcessor.cc:146
XMLDOMBlock.h
XMLProcessor::_LMapRowHBEF::adc
int adc
Definition: XMLProcessor.h:70
XMLProcessor::_LMapRowHBEF::det
std::string det
Definition: XMLProcessor.h:64
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
XMLProcessor::_LMapRowHBEF::rbx
std::string rbx
Definition: XMLProcessor.h:65
XMLProcessor::_LMapRowHBEF
Definition: XMLProcessor.h:58
XMLProcessor::_LMapRowHBEF::spigo
int spigo
Definition: XMLProcessor.h:78
XMLProcessor::_LMapRowHO::htrO
int htrO
Definition: XMLProcessor.h:108
XMLProcessor::LMapRowHO
struct XMLProcessor::_LMapRowHO LMapRowHO
XMLProcessor::_loaderBaseConfig::run_mode
std::string run_mode
Definition: XMLProcessor.h:46
XMLProcessor::_LMapRowHBEF::dcc_sl
int dcc_sl
Definition: XMLProcessor.h:77
XMLProcessor::_LMapRowHBEF::fedid
int fedid
Definition: XMLProcessor.h:88
XMLProcessor::_LMapRowHO::sectorO
int sectorO
Definition: XMLProcessor.h:99
XMLProcessor::_DBConfig::created_by_user
std::string created_by_user
Definition: XMLProcessor.h:122
XMLProcessor::write
int write(XMLDOMBlock *doc, std::string target="stdout")
Definition: XMLProcessor.cc:207
XMLProcessor::_LMapRowHO::dcc_slO
int dcc_slO
Definition: XMLProcessor.h:111
XMLProcessor::_DBConfig::_DBConfig
_DBConfig()
Definition: XMLProcessor.cc:70
XMLProcessor::addLMapHBEFDataset
int addLMapHBEFDataset(XMLDOMBlock *doc, LMapRowHBEF *row, std::string templateFileName)
Definition: XMLProcessor.cc:92
XMLProcessor::~XMLProcessor
virtual ~XMLProcessor()
Definition: XMLProcessor.cc:49
XMLProcessor::_LMapRowHBEF::rctcon
int rctcon
Definition: XMLProcessor.h:86
XMLProcessor::_LMapRowHO::sideO
int sideO
Definition: XMLProcessor.h:92
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
XMLProcessor::_LMapRowHO::qieO
int qieO
Definition: XMLProcessor.h:102
XMLProcessor::_LMapRowHBEF::rm
int rm
Definition: XMLProcessor.h:67
XMLProcessor::_lutDBConfig::crateNumber
int crateNumber
Definition: XMLProcessor.h:126
XMLProcessor::_LMapRowHBEF::side
int side
Definition: XMLProcessor.h:59
XMLProcessor::_LMapRowHBEF::pixel
int pixel
Definition: XMLProcessor.h:68
XMLProcessor::_LMapRowHO::phiO
int phiO
Definition: XMLProcessor.h:94
XMLProcessor::_LMapRowHBEF::slbin
std::string slbin
Definition: XMLProcessor.h:81
XMLProcessor::_loaderBaseConfig::iov_end
std::string iov_end
Definition: XMLProcessor.h:50
XMLProcessor::_loaderBaseConfig
Definition: XMLProcessor.h:42
XMLProcessor::_LMapRowHO::etaO
int etaO
Definition: XMLProcessor.h:93
XMLProcessor::_LMapRowHBEF::slnam
std::string slnam
Definition: XMLProcessor.h:83
XMLProcessor::_loaderBaseConfig::detector_name
std::string detector_name
Definition: XMLProcessor.h:54
XMLProcessor::_LMapRowHBEF::slbin2
std::string slbin2
Definition: XMLProcessor.h:82
XMLProcessor::_LMapRowHO::rbxO
std::string rbxO
Definition: XMLProcessor.h:98