CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Private Attributes

CalibrationXML Class Reference

#include <CalibrationXML.h>

List of all members.

Public Types

typedef
XERCES_CPP_NAMESPACE::DOMDocument 
DOMDocument
typedef
XERCES_CPP_NAMESPACE::DOMElement 
DOMElement
typedef
XERCES_CPP_NAMESPACE::DOMNode 
DOMNode
typedef
XERCES_CPP_NAMESPACE::HandlerBase 
HandlerBase
typedef
XERCES_CPP_NAMESPACE::XercesDOMParser 
XercesDOMParser
typedef
XERCES_CPP_NAMESPACE::XMLPlatformUtils 
XMLPlatformUtils
typedef
XERCES_CPP_NAMESPACE::XMLString 
XMLString

Public Member Functions

DOMElementcalibrationDOM ()
 CalibrationXML ()
void closeFile ()
void openFile (const std::string &xmlFileName)
void saveFile (const std::string &xmlFileName)
 ~CalibrationXML ()

Static Public Member Functions

static DOMElementaddChild (DOMNode *dom, const std::string &name)
template<class T >
static T readAttribute (DOMElement *dom, const std::string &name)
template<class T >
static void writeAttribute (DOMElement *dom, const std::string &name, const T &value)

Private Attributes

DOMDocumentdoc
HandlerBaseerrHandler
DOMElementm_calibrationDOM
std::string m_xmlFileName
XercesDOMParserparser

Detailed Description

Definition at line 12 of file CalibrationXML.h.


Member Typedef Documentation

typedef XERCES_CPP_NAMESPACE::DOMDocument CalibrationXML::DOMDocument

Definition at line 15 of file CalibrationXML.h.

typedef XERCES_CPP_NAMESPACE::DOMElement CalibrationXML::DOMElement

Definition at line 16 of file CalibrationXML.h.

typedef XERCES_CPP_NAMESPACE::DOMNode CalibrationXML::DOMNode

Definition at line 17 of file CalibrationXML.h.

typedef XERCES_CPP_NAMESPACE::HandlerBase CalibrationXML::HandlerBase

Definition at line 18 of file CalibrationXML.h.

typedef XERCES_CPP_NAMESPACE::XercesDOMParser CalibrationXML::XercesDOMParser

Definition at line 19 of file CalibrationXML.h.

typedef XERCES_CPP_NAMESPACE::XMLPlatformUtils CalibrationXML::XMLPlatformUtils

Definition at line 20 of file CalibrationXML.h.

typedef XERCES_CPP_NAMESPACE::XMLString CalibrationXML::XMLString

Definition at line 21 of file CalibrationXML.h.


Constructor & Destructor Documentation

XERCES_CPP_NAMESPACE_USE CalibrationXML::CalibrationXML ( )

Definition at line 22 of file CalibrationXML.cc.

                               : errHandler(0), parser(0)
{

}
CalibrationXML::~CalibrationXML ( )

Definition at line 27 of file CalibrationXML.cc.

References errHandler, and parser.

{
//TODO: delete!!!!      
if(errHandler) delete errHandler;
if(parser)  { 
              delete parser;
              XMLPlatformUtils::Terminate();
            }
}

Member Function Documentation

DOMElement * CalibrationXML::addChild ( DOMNode dom,
const std::string &  name 
) [static]

Helper static function to add a child in a DOM Element with indentation

Definition at line 123 of file CalibrationXML.cc.

References tablePrinter::indent(), and testEve_cfg::level.

Referenced by CalibratedHistogramXML::write().

{ 
          DOMNode *n1 = dom;
          int level=0;
          std::string indent="\n";
          while(n1 && level < 100)
          {
           level++;
           indent+="  ";
           n1 = n1->getParentNode();
          } 
          if(dom->getFirstChild()==0)
             dom->appendChild(dom->getOwnerDocument()->createTextNode(XMLString::transcode(indent.c_str()))); 
         
          DOMElement * child = (DOMElement *)dom->appendChild(dom->getOwnerDocument()->createElement(XMLString::transcode(name.c_str()))); 
          dom->appendChild(dom->getOwnerDocument()->createTextNode(XMLString::transcode(indent.c_str())));           
          return child;
}  
DOMElement* CalibrationXML::calibrationDOM ( ) [inline]

Return the root DOM Element of the opened XML calibration file

Definition at line 47 of file CalibrationXML.h.

References m_calibrationDOM.

Referenced by AlgorithmCalibration< T, CO >::dom().

{ return m_calibrationDOM;}
void CalibrationXML::closeFile ( ) [inline]

Definition at line 37 of file CalibrationXML.h.

References errHandler, and parser.

Referenced by AlgorithmCalibration< T, CO >::AlgorithmCalibration().

        {
          if(errHandler) delete errHandler;
          if(parser) {  delete parser; XMLPlatformUtils::Terminate(); } 
          errHandler=0;
          parser=0;
        }       
void CalibrationXML::openFile ( const std::string &  xmlFileName)

Open an XML file

Definition at line 181 of file ErrorStreamSource.cc.

References ErrorStreamSource::fin_, recoMuon::in, pos, and prof2calltree::prefix.

Referenced by AlgorithmCalibration< T, CO >::dom().

{
  fin_.close();
  fin_.clear();
  size_t pos = fileName.find(':');
  if (pos!=string::npos) {
    string prefix = fileName.substr(0,pos);
    if (prefix!="file") return false;
    pos++;
  }
  else pos=0;

  fin_.open(fileName.substr(pos).c_str(),ios::in|ios::binary);
  return fin_.is_open();
}
template<class T >
static T CalibrationXML::readAttribute ( DOMElement dom,
const std::string &  name 
) [inline, static]

Helper static function to read an attribute in a DOM Element

Definition at line 68 of file CalibrationXML.h.

References cmsPerfSuiteHarvest::release, and relativeConstraints::value.

        {
            XMLCh* nameStr  = XMLString::transcode(name.c_str());
            char * valueStr = XMLString::transcode(dom->getAttribute(nameStr));
            std::istringstream buffer(valueStr);
            T value;
            buffer >> value;
            XMLString::release(&nameStr);
            XMLString::release(&valueStr);
            return value;
        }
void CalibrationXML::saveFile ( const std::string &  xmlFileName)

Save DOM to file

Definition at line 113 of file CalibrationXML.cc.

References doc.

{
    DOMImplementation * theImpl = DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("Core"));
    DOMWriter         *   theSerializer = ((DOMImplementation*)theImpl)->createDOMWriter();
    theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
    XMLFormatTarget* myFormTarget = new LocalFileFormatTarget(XMLString::transcode(xmlFileName.c_str()));
    theSerializer->writeNode(myFormTarget, *doc);
     delete myFormTarget;
          
}
template<class T >
static void CalibrationXML::writeAttribute ( DOMElement dom,
const std::string &  name,
const T &  value 
) [inline, static]

Helper static function to write an attribute in a DOM Element

Definition at line 54 of file CalibrationXML.h.

References cmsPerfSuiteHarvest::release, and relativeConstraints::value.

Referenced by CalibratedHistogramXML::write().

        {
            std::ostringstream buffer;
            buffer << value;
            XMLCh * nameStr = XMLString::transcode(name.c_str());
            XMLCh * valueStr = XMLString::transcode(buffer.str().c_str());
            dom->setAttribute(nameStr, valueStr );
            XMLString::release(&nameStr);
            XMLString::release(&valueStr);
        }

Member Data Documentation

Definition at line 88 of file CalibrationXML.h.

Referenced by saveFile().

Definition at line 89 of file CalibrationXML.h.

Referenced by closeFile(), and ~CalibrationXML().

Definition at line 87 of file CalibrationXML.h.

Referenced by calibrationDOM().

std::string CalibrationXML::m_xmlFileName [private]

Definition at line 86 of file CalibrationXML.h.

Definition at line 90 of file CalibrationXML.h.

Referenced by closeFile(), and ~CalibrationXML().