CMS 3D CMS Logo

XMLDOMBlock Class Reference

Description: <one line="" class="" summary>="">. More...

#include <CaloOnlineTools/HcalOnlineDb/interface/XMLDOMBlock.h>

Inheritance diagram for XMLDOMBlock:

HcalHardwareXml LMapLoader LutXml XMLHTRPatternLoader XMLHTRPatterns XMLHTRZeroSuppressionLoader XMLLUTLoader XMLRBXPedestalsLoader XMLZeroSuppression

List of all members.

Public Member Functions

DOMDocument * getDocument (void)
DOMDocument * getNewDocument (string xmlFileName)
std::string & getString (DOMNode *_node)
std::string & getString (void)
const char * getTagAttribute (const string &tagName, const string &attrName, int _item=0)
const char * getTagValue (const string &tagName, int _item=0, DOMDocument *_document=NULL)
string getTimestamp (time_t _time)
int setTagAttribute (const string &tagName, const string &attrName, const string &attrValue, int _item=0)
int setTagValue (const string &tagName, const int &tagValue, int _item=0, DOMDocument *_document=NULL)
int setTagValue (const string &tagName, const string &tagValue, int _item=0, DOMDocument *_document=NULL)
int write (string target="stdout")
 XMLDOMBlock (string _root, int rootElementName)
 XMLDOMBlock (InputSource &_source)
 XMLDOMBlock (string xmlFileName)
 XMLDOMBlock ()
virtual ~XMLDOMBlock ()

Protected Member Functions

int init (string _root)

Protected Attributes

DOMDocument * document
ErrorHandler * errHandler
XercesDOMParser * parser
std::string * the_string
string theFileName
XMLProcessortheProcessor

Friends

class XMLProcessor


Detailed Description

Description: <one line="" class="" summary>="">.

Usage: <usage>

Definition at line 34 of file XMLDOMBlock.h.


Constructor & Destructor Documentation

XMLDOMBlock::XMLDOMBlock (  ) 

Definition at line 46 of file XMLDOMBlock.cc.

References init().

00047 {
00048   //cout << "XMLDOMBlock (or derived): default constructor called - this is meaningless!" << endl;
00049   //cout << "XMLDOMBlock (or derived): use yourClass( loaderBaseConfig & ) instead." << endl;
00050   init( "ROOT" );
00051 }

XMLDOMBlock::XMLDOMBlock ( string  xmlFileName  ) 

Definition at line 135 of file XMLDOMBlock.cc.

References GenMuonPlsPt100GeV_cfg::cout, document, errHandler, getDocument(), XMLProcessor::getInstance(), parser, release(), theFileName, theProcessor, and transcode().

00136 {
00137 
00138   theProcessor = XMLProcessor::getInstance();
00139 
00140   theFileName = xmlFileName;
00141 
00142   // initialize the parser
00143   parser = new XercesDOMParser();
00144   parser->setValidationScheme(XercesDOMParser::Val_Always);    
00145   parser->setDoNamespaces(true);    // optional
00146   
00147   errHandler = (ErrorHandler*) new HandlerBase();
00148   parser->setErrorHandler(errHandler);
00149 
00150   // parse the input xml file
00151   try
00152     {
00153       parser->parse( theFileName . c_str() );
00154     }
00155   catch (const XMLException& toCatch) {
00156     char* message = XMLString::transcode(toCatch.getMessage());
00157     cout << "Exception message is: \n"
00158          << message << "\n";
00159     XMLString::release(&message);
00160     //return -1;
00161   }
00162   catch (const DOMException& toCatch) {
00163     char* message = XMLString::transcode(toCatch.msg);
00164     cout << "Exception message is: \n"
00165          << message << "\n";
00166     XMLString::release(&message);
00167     //return -1;
00168   }
00169   catch (...) {
00170     cout << "Unexpected Exception \n" ;
00171     //return -1;
00172   }
00173 
00174   //get the XML document
00175   document = parser -> getDocument();
00176 
00177 }

XMLDOMBlock::XMLDOMBlock ( InputSource &  _source  ) 

Definition at line 61 of file XMLDOMBlock.cc.

References GenMuonPlsPt100GeV_cfg::cout, document, errHandler, getDocument(), XMLProcessor::getInstance(), parser, release(), theProcessor, and transcode().

00062 {
00063 
00064   theProcessor = XMLProcessor::getInstance();
00065 
00066   //theFileName = xmlFileName;
00067 
00068   // initialize the parser
00069   parser = new XercesDOMParser();
00070   parser->setValidationScheme(XercesDOMParser::Val_Always);    
00071   parser->setDoNamespaces(true);    // optional
00072   
00073   errHandler = (ErrorHandler*) new HandlerBase();
00074   parser->setErrorHandler(errHandler);
00075 
00076   // parse the input xml file
00077   try
00078     {
00079       parser->parse( _source );
00080     }
00081   catch (const XMLException& toCatch) {
00082     char* message = XMLString::transcode(toCatch.getMessage());
00083     cout << "Exception message is: \n"
00084          << message << "\n";
00085     XMLString::release(&message);
00086     //return -1;
00087   }
00088   catch (const DOMException& toCatch) {
00089     char* message = XMLString::transcode(toCatch.msg);
00090     cout << "Exception message is: \n"
00091          << message << "\n";
00092     XMLString::release(&message);
00093     //return -1;
00094   }
00095   catch (...) {
00096     cout << "Unexpected Exception \n" ;
00097     //return -1;
00098   }
00099 
00100   //get the XML document
00101   document = parser -> getDocument();
00102 }

XMLDOMBlock::XMLDOMBlock ( string  _root,
int  rootElementName 
)

Definition at line 53 of file XMLDOMBlock.cc.

References init().

00054 {
00055   //cout << "XMLDOMBlock (or derived): default constructor called - this is meaningless!" << endl;
00056   //cout << "XMLDOMBlock (or derived): use yourClass( loaderBaseConfig & ) instead." << endl;
00057   init( _root );
00058 }

XMLDOMBlock::~XMLDOMBlock (  )  [virtual]

Definition at line 237 of file XMLDOMBlock.cc.

References errHandler, and parser.

00238 {
00239   delete parser;
00240   delete errHandler;
00241   //if (the_string) delete the_string;
00242 }


Member Function Documentation

DOMDocument * XMLDOMBlock::getDocument ( void   ) 

Definition at line 225 of file XMLDOMBlock.cc.

References document.

Referenced by XMLHTRPatternLoader::addChecksums(), XMLLUTLoader::addChecksums(), LMapLoader::addLMapHBEFDataset(), LMapLoader::addLMapHODataset(), XMLLUTLoader::addLUT(), XMLZeroSuppression::addPattern(), XMLHTRPatterns::addPattern(), XMLHTRPatternLoader::addPattern(), XMLRBXPedestalsLoader::addRBXSlot(), XMLHTRZeroSuppressionLoader::addZS(), getNewDocument(), and XMLDOMBlock().

00226 {
00227   return document;
00228 }

DOMDocument * XMLDOMBlock::getNewDocument ( string  xmlFileName  ) 

Definition at line 179 of file XMLDOMBlock.cc.

References GenMuonPlsPt100GeV_cfg::cout, document, errHandler, getDocument(), XMLProcessor::getInstance(), parser, release(), theFileName, theProcessor, and transcode().

Referenced by XMLZeroSuppression::createByCrate(), and XMLHTRPatterns::createByCrate().

00180 {
00181   delete document;
00182 
00183   theProcessor = XMLProcessor::getInstance();
00184 
00185   theFileName = xmlFileName;
00186 
00187   // initialize the parser
00188   parser = new XercesDOMParser();
00189   parser->setValidationScheme(XercesDOMParser::Val_Always);    
00190   parser->setDoNamespaces(true);    // optional
00191   
00192   errHandler = (ErrorHandler*) new HandlerBase();
00193   parser->setErrorHandler(errHandler);
00194 
00195   // parse the input xml file
00196   try
00197     {
00198       parser->parse( theFileName . c_str() );
00199     }
00200   catch (const XMLException& toCatch) {
00201     char* message = XMLString::transcode(toCatch.getMessage());
00202     cout << "Exception message is: \n"
00203          << message << "\n";
00204     XMLString::release(&message);
00205     //return -1;
00206   }
00207   catch (const DOMException& toCatch) {
00208     char* message = XMLString::transcode(toCatch.msg);
00209     cout << "Exception message is: \n"
00210          << message << "\n";
00211     XMLString::release(&message);
00212     //return -1;
00213   }
00214   catch (...) {
00215     cout << "Unexpected Exception \n" ;
00216     //return -1;
00217   }
00218 
00219   //get the XML document
00220   document = parser -> getDocument();
00221 
00222   return document;
00223 }

std::string & XMLDOMBlock::getString ( DOMNode *  _node  ) 

Definition at line 302 of file XMLDOMBlock.cc.

References XMLProcessor::serializeDOM(), the_string, theProcessor, and transcode().

00303 {
00304   if (the_string) delete the_string;
00305   std::string _target = "string";
00306   the_string = new std::string( XMLString::transcode( theProcessor->serializeDOM(_node,_target) ) );
00307   return (*the_string);
00308 }

std::string & XMLDOMBlock::getString ( void   ) 

Definition at line 294 of file XMLDOMBlock.cc.

Referenced by LutXml::getCurrentBrick().

00295 {
00296   return getString( this->getDocument() );
00297 }

const char * XMLDOMBlock::getTagAttribute ( const string &  tagName,
const string &  attrName,
int  _item = 0 
)

Definition at line 265 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh(), document, and transcode().

Referenced by XMLRBXPedestalsLoader::addRBXSlot().

00266 {
00267   DOMElement * _tag = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ));
00268   const char * _result = XMLString::transcode( _tag -> getAttribute( XMLProcessor::_toXMLCh( attrName ) ) );
00269 
00270   return _result;
00271 }

const char * XMLDOMBlock::getTagValue ( const string &  tagName,
int  _item = 0,
DOMDocument *  _document = NULL 
)

Definition at line 244 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh(), document, and transcode().

Referenced by XMLRBXPedestalsLoader::addRBXSlot().

00245 {
00246   if (!_document) _document = document;
00247   const char * _result = XMLString::transcode( _document -> getElementsByTagName( XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ) -> getFirstChild()-> getNodeValue() );
00248   return _result;
00249 }

string XMLDOMBlock::getTimestamp ( time_t  _time  ) 

Definition at line 281 of file XMLDOMBlock.cc.

Referenced by XMLZeroSuppression::createByCrate(), and XMLHTRPatterns::createByCrate().

00282 {
00283   char timebuf[50];
00284   //strftime( timebuf, 50, "%c", gmtime( &_time ) );
00285   strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &_time ) );
00286   string creationstamp = timebuf;
00287 
00288   return creationstamp;
00289 }

int XMLDOMBlock::init ( string  _root  )  [protected]

Definition at line 106 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh(), document, errHandler, XMLProcessor::getInstance(), parser, the_string, and theProcessor.

Referenced by XMLDOMBlock().

00107 {
00108   theProcessor = XMLProcessor::getInstance();
00109 
00110   //theFileName = xmlFileName;
00111 
00112   // initialize the parser
00113   parser = new XercesDOMParser();
00114   parser->setValidationScheme(XercesDOMParser::Val_Always);    
00115   parser->setDoNamespaces(true);    // optional
00116   
00117   errHandler = (ErrorHandler*) new HandlerBase();
00118   parser->setErrorHandler(errHandler);
00119 
00120   DOMImplementation* impl =  DOMImplementation::getImplementation();
00121   
00122   document = impl->createDocument(
00123                                   0,                      // root element namespace URI.
00124                                   //XMLString::transcode("ROOT"), // root element name
00125                                   XMLProcessor::_toXMLCh(_root), // root element name
00126                                   0);                     // document type object (DTD).
00127 
00128   the_string = 0;
00129 
00130   return 0;
00131 }

int XMLDOMBlock::setTagAttribute ( const string &  tagName,
const string &  attrName,
const string &  attrValue,
int  _item = 0 
)

Definition at line 273 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh(), and document.

Referenced by XMLHTRPatternLoader::XMLHTRPatternLoader(), XMLHTRZeroSuppressionLoader::XMLHTRZeroSuppressionLoader(), XMLLUTLoader::XMLLUTLoader(), and XMLRBXPedestalsLoader::XMLRBXPedestalsLoader().

00274 {
00275   DOMElement * _tag = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ));
00276   _tag -> setAttribute( XMLProcessor::_toXMLCh( attrName ), XMLProcessor::_toXMLCh( attrValue ) );
00277 
00278   return 0;
00279 }

int XMLDOMBlock::setTagValue ( const string &  tagName,
const int tagValue,
int  _item = 0,
DOMDocument *  _document = NULL 
)

Definition at line 258 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh(), and document.

00259 {
00260   if (!_document) _document = document;
00261   _document -> getElementsByTagName( XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( tagValue ) );
00262   return 0;
00263 }

int XMLDOMBlock::setTagValue ( const string &  tagName,
const string &  tagValue,
int  _item = 0,
DOMDocument *  _document = NULL 
)

Definition at line 251 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh(), and document.

Referenced by XMLHTRPatternLoader::addChecksums(), XMLLUTLoader::addChecksums(), XMLLUTLoader::addLUT(), XMLZeroSuppression::addPattern(), XMLHTRPatterns::addPattern(), XMLHTRPatternLoader::addPattern(), XMLRBXPedestalsLoader::addRBXSlot(), XMLHTRZeroSuppressionLoader::addZS(), XMLHTRPatternLoader::XMLHTRPatternLoader(), XMLHTRZeroSuppressionLoader::XMLHTRZeroSuppressionLoader(), XMLLUTLoader::XMLLUTLoader(), and XMLRBXPedestalsLoader::XMLRBXPedestalsLoader().

00252 {
00253   if (!_document) _document = document;
00254   _document -> getElementsByTagName( XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( tagValue ) );
00255   return 0;
00256 }

int XMLDOMBlock::write ( string  target = "stdout"  ) 

Definition at line 230 of file XMLDOMBlock.cc.

References theProcessor.

Referenced by XMLZeroSuppression::createByCrate(), XMLHTRPatterns::createByCrate(), XMLLUTLoader::createLoader(), and XMLHTRPatternLoader::createLoader().

00231 {
00232   theProcessor -> write( this, target );
00233 
00234   return 0;
00235 }


Friends And Related Function Documentation

friend class XMLProcessor [friend]

Definition at line 37 of file XMLDOMBlock.h.


Member Data Documentation

DOMDocument* XMLDOMBlock::document [protected]

Definition at line 68 of file XMLDOMBlock.h.

Referenced by XMLHTRPatternLoader::addChecksums(), XMLLUTLoader::addChecksums(), LutXml::addData(), LMapLoader::addLMapHBEFDataset(), LMapLoader::addLMapHODataset(), XMLLUTLoader::addLUT(), LutXml::addLut(), LutXml::addParameter(), HcalHardwareXml::addPart(), XMLZeroSuppression::addPattern(), XMLHTRPatterns::addPattern(), XMLHTRPatternLoader::addPattern(), XMLRBXPedestalsLoader::addRBXSlot(), XMLHTRZeroSuppressionLoader::addZS(), LMapLoader::createLMapHBEFXMLBase(), getDocument(), getNewDocument(), getTagAttribute(), getTagValue(), HcalHardwareXml::HcalHardwareXml(), init(), setTagAttribute(), setTagValue(), and XMLDOMBlock().

ErrorHandler* XMLDOMBlock::errHandler [protected]

Definition at line 67 of file XMLDOMBlock.h.

Referenced by getNewDocument(), init(), XMLDOMBlock(), and ~XMLDOMBlock().

XercesDOMParser* XMLDOMBlock::parser [protected]

Definition at line 66 of file XMLDOMBlock.h.

Referenced by getNewDocument(), init(), XMLDOMBlock(), and ~XMLDOMBlock().

std::string* XMLDOMBlock::the_string [protected]

Definition at line 71 of file XMLDOMBlock.h.

Referenced by getString(), and init().

string XMLDOMBlock::theFileName [protected]

Definition at line 69 of file XMLDOMBlock.h.

Referenced by XMLZeroSuppression::createByCrate(), XMLHTRPatterns::createByCrate(), getNewDocument(), and XMLDOMBlock().

XMLProcessor* XMLDOMBlock::theProcessor [protected]

Definition at line 65 of file XMLDOMBlock.h.

Referenced by getNewDocument(), getString(), init(), write(), and XMLDOMBlock().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:35:54 2009 for CMSSW by  doxygen 1.5.4