All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
XMLFileCatalog.h
Go to the documentation of this file.
1 #ifndef GAUDIUTILS_XMLFILECATALOG_H
2 #define GAUDIUTILS_XMLFILECATALOG_H
3 
5 #include "xercesc/dom/DOMElement.hpp"
6 #include "xercesc/dom/DOMDocument.hpp"
7 #include "xercesc/sax/ErrorHandler.hpp"
8 #include "xercesc/parsers/XercesDOMParser.hpp"
9 
10 // Forward declarations
11 class IMessageSvc;
12 
13 /*
14  * Gaudi namespace declaration
15  */
16 namespace Gaudi {
17 
25  class XMLFileCatalog : public implements1<IFileCatalog> {
26  protected:
27  typedef const std::string& CSTR;
28 
29  public:
33  virtual ~XMLFileCatalog();
34 
36  virtual std::string createFID() const;
39  virtual CSTR connectInfo() const { return m_file; }
41  virtual void init();
43  virtual void commit();
45  virtual void rollback() { if ( dirty() ) init(); }
47  virtual bool readOnly() const { return m_rdOnly; }
49  virtual bool dirty() const { return m_update; }
51  virtual bool existsPFN(CSTR pfn) const { return element(pfn,false) != 0; }
53  virtual std::string lookupPFN(CSTR fid) const { return lookupFID(fid); }
55  virtual bool existsLFN(CSTR lfn) const { return element(lfn,false) != 0; }
57  virtual std::string lookupLFN(CSTR lfn) const { return lookupFID(lfn); }
59  virtual bool existsFID(CSTR fid) const { return element(fid,false) != 0; }
61  virtual void getPFN(CSTR fid, Files& files) const;
63  virtual void getLFN(CSTR fid, Files& files) const;
65  virtual void getFID(Strings& fids) const;
67  virtual void deleteFID(CSTR FileID) const;
69  virtual void registerPFN(CSTR fid, CSTR pfn, CSTR ftype) const;
71  virtual void registerLFN(CSTR fid, CSTR lfn) const;
73  virtual void registerFID(CSTR fid) const;
75  virtual void getMetaData(CSTR fid, Attributes& attr) const;
77  virtual std::string getMetaDataItem(CSTR fid, CSTR name) const;
79  virtual void setMetaData(CSTR fid, CSTR name, CSTR value) const;
81  virtual void dropMetaData(CSTR fid) const { dropMetaData(fid,"*"); }
83  virtual void dropMetaData(CSTR fid, CSTR attr) const;
84  private:
85  xercesc::DOMDocument* getDoc(bool throw_if_no_exists=true) const;
86  std::string getfile(bool create);
87  void printError(CSTR msg, bool throw_exc=true) const;
88  std::string lookupFID(CSTR lfn) const;
89  xercesc::DOMNode* element(CSTR fid, bool print_err=true) const;
90  xercesc::DOMNode* child(xercesc::DOMNode* par, CSTR tag, CSTR attr="", CSTR val="") const;
91  std::pair<xercesc::DOMElement*, xercesc::DOMElement*> i_registerFID(CSTR fid) const;
92  bool m_rdOnly;
93  mutable bool m_update;
94  xercesc::DOMDocument *m_doc;
95  xercesc::XercesDOMParser *m_parser;
96  xercesc::ErrorHandler *m_errHdlr;
97  std::string m_file;
99  };
101  std::string createGuidAsString();
102 } /* End namespace Gaudi */
103 #endif /* GAUDIUTILS_XMLFILECATALOG_H */
virtual CSTR connectInfo() const
Access to connect string.
virtual void rollback()
Save DOM catalog to file.
virtual std::string lookupLFN(CSTR lfn) const
Lookup file identifier by logical file name.
virtual bool readOnly() const
Check if the catalog is read-only.
xercesc::XercesDOMParser * m_parser
virtual bool existsFID(CSTR fid) const
Return the status of a FileID.
virtual ~XMLFileCatalog()
Destructor,.
virtual bool existsLFN(CSTR lfn) const
Return the status of a logical file name.
std::string lookupFID(CSTR lfn) const
std::string getfile(bool create)
virtual std::string getMetaDataItem(CSTR fid, CSTR name) const
Access metadata item.
virtual void dropMetaData(CSTR fid) const
Drop all metadata of one FID.
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
virtual void setMetaData(CSTR fid, CSTR name, CSTR value) const
Insert/update metadata item.
virtual void registerPFN(CSTR fid, CSTR pfn, CSTR ftype) const
Create a FileID and Node of the physical file name with all the attributes.
Base class used to implement the interfaces.
Definition: implements.h:133
const std::string & CSTR
virtual void init()
Parse the DOM tree of the XML catalog.
virtual bool dirty() const
Check if the catalog should be updated.
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
void printError(CSTR msg, bool throw_exc=true) const
virtual void getFID(Strings &fids) const
Dump all file Identifiers.
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
xercesc::DOMDocument * m_doc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
const std::string CSTR
virtual std::string lookupPFN(CSTR fid) const
Lookup file identifier by physical file name.
virtual void getLFN(CSTR fid, Files &files) const
Dump all logical file names of the catalog associate to the FileID.
virtual void deleteFID(CSTR FileID) const
Delete FileID Node from the catalog.
XMLFileCatalog(CSTR url, IMessageSvc *m)
Create a catalog file, initialization of XercesC.
virtual bool existsPFN(CSTR pfn) const
Return the status of a physical file name.
xercesc::ErrorHandler * m_errHdlr
std::string createGuidAsString()
Create file identifier using UUID mechanism.
virtual void commit()
Save DOM catalog to file.
virtual void getPFN(CSTR fid, Files &files) const
Dump all physical file names of the catalog and their attributes associate to the FileID...
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
IMessageSvc * m_msgSvc
virtual void getMetaData(CSTR fid, Attributes &attr) const
Dump all MetaData of the catalog for a given file ID.
virtual void registerFID(CSTR fid) const
Create a FileID and Node.
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:15
This class constitutes the core of the XML based FileCatalog API for POOL.
virtual std::string createFID() const
Catalog interface.
virtual void registerLFN(CSTR fid, CSTR lfn) const
Create a FileID and Node of the logical file name with all the attributes.