#ifndef TXmlOdb_hxx_seen #define TXmlOdb_hxx_seen /// Acknowledgements: This class derives from the XML ODB access class developed by /// /// Konstantin Olchanski /// /// in the rootana package which is part of the Midas Data /// Acquisition:- /// /// https://midas.psi.ch/ /// /// The code has been snchronised with revision 66 of Subversion repository:- /// svn://ladd00.triumf.ca/rootana/trunk rootana /// The T2K group should monitor changes to that code looking for enhancements /// and should report back any code improvements we make to Konstantin. #include #include "TXMLNode.h" #include "TXMLAttr.h" #include "TDOMParser.h" namespace COMET { class IXmlOdb; }; /// Access to ODB saved in XML format inside midas .mid files class COMET::IXmlOdb { TDOMParser* fParser; ///< XML parser for the XML-encoded ODB data TXMLNode* fOdb; ///< Pointer to the root of the ODB tree public: /// Contructor from a string IXmlOdb(const char*buf,Int_t bufLength); /// Contructor from a file IXmlOdb(const char* filename); /// Destructor virtual ~IXmlOdb(); /// Validity check Bool_t IsValid() const { return fParser; } // Print methods // ************* /// Print out the contents of the ODB subtree void DumpTree(TXMLNode*node, Int_t print_level, Int_t dir_level, std::string node_path) const; /// Print out contents of the ODB void Print(const Option_t* opt = "") const; // Navigation methods // ****************** /// Get ROOT node TXMLNode* GetRootNode() const { return fOdb; } /// Same as FindPath(), but also index into an array TXMLNode* FindArrayPath(TXMLNode*node,const char* path,const char* type,Int_t index) const; /// Find node with given name anywhere inside the given ODB tree TXMLNode* FindNode(TXMLNode*node,const char*name) const; /// Follow the ODB path through the XML DOM tree TXMLNode* FindPath(TXMLNode*node,const char* path) const; // Value retrevial methods // *********************** /// Return the value of the named attribute const char* GetAttrValue(const TXMLNode*node,const char*attrName) const; // Navigation + value retrevial methods // ************************************ Int_t odbReadAny( const char*path, Int_t index, Int_t tid,void* buf, Int_t bufsize=0) const; Int_t odbReadArraySize(const char*path) const; Bool_t odbReadBool( const char*path, Bool_t defaultValue = false,Int_t index=0) const; double odbReadDouble( const char*path, double defaultValue = 0., Int_t index=0) const; Int_t odbReadInt( const char*path, Int_t defaultValue = 0, Int_t index=0) const; UInt_t odbReadUint32( const char*path, UInt_t defaultValue = 0, Int_t index=0) const; const char* odbReadString( const char*path, const char* defaultValue = "", Int_t index=0) const; private: std::string Indent(Int_t level) const; /// Clear ODB statistics. void ClearStats() const; /// ODB statistics. Multable, only defined after and used by call to Print() mutable Int_t fStatsNumDir; mutable Int_t fStatsNumKey; mutable Int_t fStatsNumKeyArray; mutable Int_t fStatsNumText; mutable Int_t fStatsNumValue; mutable Int_t fStatsNumOther; /// Release XML parser void ReleaseXMLParser() { delete fParser; fParser = NULL; fOdb = NULL; } }; #endif