The Gaudi Framework  v32r2 (46d42edc)
XMLFileCatalog.h
Go to the documentation of this file.
1 #ifndef GAUDIUTILS_XMLFILECATALOG_H
2 #define GAUDIUTILS_XMLFILECATALOG_H
3 
5 #include "xercesc/dom/DOMDocument.hpp"
6 #include "xercesc/dom/DOMElement.hpp"
7 #include "xercesc/parsers/XercesDOMParser.hpp"
8 #include "xercesc/sax/ErrorHandler.hpp"
9 
10 #include <memory>
11 
12 // Forward declarations
13 class IMessageSvc;
14 
15 /*
16  * Gaudi namespace declaration
17  */
18 namespace Gaudi {
19 
27  class XMLFileCatalog : public implements<IFileCatalog> {
28  protected:
29  typedef const std::string& CSTR;
30 
31  public:
34 
36  std::string createFID() const override;
39  CSTR connectInfo() const override { return m_file; }
41  void init() override;
43  void commit() override;
45  void rollback() override {
46  if ( dirty() ) init();
47  }
49  bool readOnly() const override { return m_rdOnly; }
51  bool dirty() const override { return m_update; }
53  bool existsPFN( CSTR pfn ) const override { return element( pfn, false ) != 0; }
55  std::string lookupPFN( CSTR fid ) const override { return lookupFID( fid ); }
57  bool existsLFN( CSTR lfn ) const override { return element( lfn, false ) != 0; }
59  std::string lookupLFN( CSTR lfn ) const override { return lookupFID( lfn ); }
61  bool existsFID( CSTR fid ) const override { return element( fid, false ) != 0; }
63  void getPFN( CSTR fid, Files& files ) const override;
65  void getLFN( CSTR fid, Files& files ) const override;
67  void getFID( Strings& fids ) const override;
69  void deleteFID( CSTR FileID ) const override;
71  void registerPFN( CSTR fid, CSTR pfn, CSTR ftype ) const override;
73  void registerLFN( CSTR fid, CSTR lfn ) const override;
75  void registerFID( CSTR fid ) const override;
77  void renamePFN( CSTR pfn, CSTR new_pfn ) const override;
79  void deletePFN( CSTR pfn ) const override;
81  void getMetaData( CSTR fid, Attributes& attr ) const override;
83  std::string getMetaDataItem( CSTR fid, CSTR name ) const override;
85  void setMetaData( CSTR fid, CSTR name, CSTR value ) const override;
87  void dropMetaData( CSTR fid ) const override { dropMetaData( fid, "*" ); }
89  void dropMetaData( CSTR fid, CSTR attr ) const override;
90 
91  private:
92  xercesc::DOMDocument* getDoc( bool throw_if_no_exists = true ) const;
93  std::string getfile( bool create );
94  void printError( CSTR msg, bool throw_exc = true ) const;
95  std::string lookupFID( CSTR lfn ) const;
96  xercesc::DOMNode* element( CSTR fid, bool print_err = true ) const;
97  xercesc::DOMNode* child( xercesc::DOMNode* par, CSTR tag, CSTR attr = "", CSTR val = "" ) const;
99  bool m_rdOnly = false;
100  mutable bool m_update = false;
101  xercesc::DOMDocument* m_doc = nullptr;
106  };
109 } /* End namespace Gaudi */
110 #endif /* GAUDIUTILS_XMLFILECATALOG_H */
void registerPFN(CSTR fid, CSTR pfn, CSTR ftype) const override
Create a FileID and Node of the physical file name with all the attributes.
std::string getMetaDataItem(CSTR fid, CSTR name) const override
Access metadata item.
bool dirty() const override
Check if the catalog should be updated.
void registerLFN(CSTR fid, CSTR lfn) const override
Create a FileID and Node of the logical file name with all the attributes.
Base class used to implement the interfaces.
Definition: implements.h:9
void registerFID(CSTR fid) const override
Create a FileID and Node.
void rollback() override
Save DOM catalog to file.
void getFID(Strings &fids) const override
Dump all file Identifiers.
std::string lookupPFN(CSTR fid) const override
Lookup file identifier by physical file name.
void getMetaData(CSTR fid, Attributes &attr) const override
Dump all MetaData of the catalog for a given file ID.
std::string getfile(bool create)
void setMetaData(CSTR fid, CSTR name, CSTR value) const override
Insert/update metadata item.
void renamePFN(CSTR pfn, CSTR new_pfn) const override
rename a PFN
std::string lookupFID(CSTR lfn) const
std::unique_ptr< xercesc::XercesDOMParser > m_parser
void dropMetaData(CSTR fid) const override
Drop all metadata of one FID.
bool existsFID(CSTR fid) const override
Return the status of a FileID.
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
STL class.
const std::string & CSTR
void getLFN(CSTR fid, Files &files) const override
Dump all logical file names of the catalog associate to the FileID.
void deletePFN(CSTR pfn) const override
remove a PFN
std::string lookupLFN(CSTR lfn) const override
Lookup file identifier by logical file name.
constexpr double m
Definition: SystemOfUnits.h:92
std::unique_ptr< xercesc::ErrorHandler > m_errHdlr
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:37
xercesc::DOMDocument * m_doc
void getPFN(CSTR fid, Files &files) const override
Dump all physical file names of the catalog and their attributes associate to the FileID.
CSTR connectInfo() const override
Access to connect string.
XMLFileCatalog(CSTR url, IMessageSvc *m)
Create a catalog file, initialization of XercesC.
bool existsPFN(CSTR pfn) const override
Return the status of a physical file name.
std::string createGuidAsString()
Helper function creating file identifier using the UUID mechanism.
bool readOnly() const override
Check if the catalog is read-only.
void deleteFID(CSTR FileID) const override
Delete FileID Node from the catalog.
std::string createFID() const override
Catalog interface.
void commit() override
Save DOM catalog to file.
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
void init() override
Parse the DOM tree of the XML catalog.
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
IMessageSvc * m_msgSvc
bool existsLFN(CSTR lfn) const override
Return the status of a logical file name.
This class constitutes the core of the XML based FileCatalog API for POOL.
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
void printError(CSTR msg, bool throw_exc=true) const