Go to the documentation of this file.00001 #include "DQM/SiPixelMonitorClient/interface/SiPixelConfigWriter.h"
00002
00003
00004 #include "DQMServices/ClientConfig/interface/ParserFunctions.h"
00005
00006 using namespace xercesc;
00007 using namespace std;
00008
00009
00010
00011 SiPixelConfigWriter::SiPixelConfigWriter() {
00012 }
00013
00014
00015
00016 SiPixelConfigWriter::~SiPixelConfigWriter() {
00017
00018 }
00019
00020
00021
00022 bool SiPixelConfigWriter::init() {
00023 try {
00024 XMLPlatformUtils::Initialize();
00025 }
00026 catch (const XMLException& toCatch) {
00027 cout << "Problem to initialise XML !!! " << endl;
00028 return false;
00029 }
00030 DOMImplementation* domImpl = DOMImplementationRegistry::getDOMImplementation(qtxml::_toDOMS("Range"));
00031 domWriter = (dynamic_cast<DOMImplementation*>(domImpl))->createDOMWriter();
00032 domWriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
00033 theDoc = domImpl->createDocument(0,qtxml::_toDOMS("Layouts"), 0);
00034 theTopElement = theDoc->getDocumentElement();
00035 theTopElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00036 return true;
00037 }
00038
00039
00040
00041 void SiPixelConfigWriter::createLayout(string& name) {
00042 lastLayout = theDoc->createElement(qtxml::_toDOMS("layout"));
00043 lastLayout->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name));
00044 theTopElement->appendChild(lastLayout);
00045 }
00046
00047
00048
00049 void SiPixelConfigWriter::createRow() {
00050 lastLayout->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00051
00052 lastRow = theDoc->createElement(qtxml::_toDOMS("row"));
00053 lastLayout->appendChild(lastRow);
00054 lastLayout->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00055 }
00056
00057
00058
00059 void SiPixelConfigWriter::createColumn(string& element, string& name) {
00060
00061 lastRow->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00062 DOMElement* e1 = theDoc->createElement(qtxml::_toDOMS("column"));
00063 lastRow->appendChild(e1);
00064
00065
00066 DOMElement* e2 = theDoc->createElement(qtxml::_toDOMS(element));
00067 e2->setAttribute(qtxml::_toDOMS("name"),qtxml::_toDOMS(name));
00068 e1->appendChild(e2);
00069 }
00070
00071
00072
00073 void SiPixelConfigWriter::write(string& fname) {
00074 XMLFormatTarget* formTarget = new LocalFileFormatTarget(fname.c_str());
00075 domWriter->writeNode(formTarget, *theTopElement);
00076 delete formTarget;
00077 theDoc->release();
00078
00079
00080 }