| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

XMLFileCatalog.h
Go to the documentation of this file.
1 #ifndef GAUDIUTILS_XMLFILECATALOG_H
2 #define GAUDIUTILS_XMLFILECATALOG_H
3
4 #include "GaudiUtils/IFileCatalog.h"
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 {
20
28 class XMLFileCatalog : public implements<IFileCatalog>
29 {
30 protected:
31 typedef const std::string& CSTR;
32
33 public:
35 XMLFileCatalog( CSTR url, IMessageSvc* m );
37 ~XMLFileCatalog() override = default;
38
40 std::string createFID() const override;
43 CSTR connectInfo() const override { return m_file; }
45 void init() override;
47 void commit() override;
49 void rollback() override
50 {
51 if ( dirty() ) init();
52 }
54 bool readOnly() const override { return m_rdOnly; }
56 bool dirty() const override { return m_update; }
58 bool existsPFN( CSTR pfn ) const override { return element( pfn, false ) != 0; }
60 std::string lookupPFN( CSTR fid ) const override { return lookupFID( fid ); }
62 bool existsLFN( CSTR lfn ) const override { return element( lfn, false ) != 0; }
64 std::string lookupLFN( CSTR lfn ) const override { return lookupFID( lfn ); }
66 bool existsFID( CSTR fid ) const override { return element( fid, false ) != 0; }
68 void getPFN( CSTR fid, Files& files ) const override;
70 void getLFN( CSTR fid, Files& files ) const override;
72 void getFID( Strings& fids ) const override;
74 void deleteFID( CSTR FileID ) const override;
76 void registerPFN( CSTR fid, CSTR pfn, CSTR ftype ) const override;
78 void registerLFN( CSTR fid, CSTR lfn ) const override;
80 void registerFID( CSTR fid ) const override;
82 void getMetaData( CSTR fid, Attributes& attr ) const override;
84 std::string getMetaDataItem( CSTR fid, CSTR name ) const override;
86 void setMetaData( CSTR fid, CSTR name, CSTR value ) const override;
88 void dropMetaData( CSTR fid ) const override { dropMetaData( fid, "*" ); }
90 void dropMetaData( CSTR fid, CSTR attr ) const override;
91
92 private:
93 xercesc::DOMDocument* getDoc( bool throw_if_no_exists = true ) const;
94 std::string getfile( bool create );
95 void printError( CSTR msg, bool throw_exc = true ) const;
96 std::string lookupFID( CSTR lfn ) const;
97 xercesc::DOMNode* element( CSTR fid, bool print_err = true ) const;
98 xercesc::DOMNode* child( xercesc::DOMNode* par, CSTR tag, CSTR attr = "", CSTR val = "" ) const;
99 std::pair<xercesc::DOMElement*, xercesc::DOMElement*> i_registerFID( CSTR fid ) const;
100 bool m_rdOnly;
101 mutable bool m_update;
102 xercesc::DOMDocument* m_doc;
103 std::unique_ptr<xercesc::XercesDOMParser> m_parser;
104 std::unique_ptr<xercesc::ErrorHandler> m_errHdlr;
105 std::string m_file;
106 IMessageSvc* m_msgSvc;
107 };
109 std::string createGuidAsString();
110 } /* End namespace Gaudi */
111 #endif /* GAUDIUTILS_XMLFILECATALOG_H */
Gaudi::XMLFileCatalog::getMetaDataItem
std::string getMetaDataItem(CSTR fid, CSTR name) const override
Access metadata item.
Definition: XMLFileCatalog.cpp:316
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:54
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:105
implements
Base class used to implement the interfaces.
Definition: implements.h:9
Gaudi::XMLFileCatalog::registerPFN
void registerPFN(CSTR fid, CSTR pfn, CSTR ftype) const override
Create a FileID and Node of the physical file name with all the attributes.
Definition: XMLFileCatalog.cpp:394
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
Gaudi::XMLFileCatalog::rollback
void rollback() override
Save DOM catalog to file.
Definition: XMLFileCatalog.h:49
Gaudi::XMLFileCatalog::lookupPFN
std::string lookupPFN(CSTR fid) const override
Lookup file identifier by physical file name.
Definition: XMLFileCatalog.h:60
Gaudi::XMLFileCatalog::lookupFID
std::string lookupFID(CSTR lfn) const
Definition: XMLFileCatalog.cpp:243
Gaudi::XMLFileCatalog::getfile
std::string getfile(bool create)
Definition: XMLFileCatalog.cpp:484
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331
Gaudi::XMLFileCatalog::m_parser
std::unique_ptr< xercesc::XercesDOMParser > m_parser
Definition: XMLFileCatalog.h:103
std::string
STL class.
Gaudi::XMLFileCatalog::CSTR
const std::string & CSTR
Definition: XMLFileCatalog.h:31
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:437
Gaudi::XMLFileCatalog::lookupLFN
std::string lookupLFN(CSTR lfn) const override
Lookup file identifier by logical file name.
Definition: XMLFileCatalog.h:64
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:288
Gaudi::XMLFileCatalog::existsPFN
bool existsPFN(CSTR pfn) const override
Return the status of a physical file name.
Definition: XMLFileCatalog.h:58
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:94
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
Gaudi::XMLFileCatalog::getMetaData
void getMetaData(CSTR fid, Attributes &attr) const override
Dump all MetaData of the catalog for a given file ID.
Definition: XMLFileCatalog.cpp:280
Gaudi::XMLFileCatalog::m_errHdlr
std::unique_ptr< xercesc::ErrorHandler > m_errHdlr
Definition: XMLFileCatalog.h:104
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:102
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200
Gaudi::XMLFileCatalog::connectInfo
CSTR connectInfo() const override
Access to connect string.
Definition: XMLFileCatalog.h:43
IFileCatalog.h
Gaudi::XMLFileCatalog::existsLFN
bool existsLFN(CSTR lfn) const override
Return the status of a logical file name.
Definition: XMLFileCatalog.h:62
Gaudi::XMLFileCatalog::getLFN
void getLFN(CSTR fid, Files &files) const override
Dump all logical file names of the catalog associate to the FileID.
Definition: XMLFileCatalog.cpp:273
Gaudi::XMLFileCatalog::XMLFileCatalog
XMLFileCatalog(CSTR url, IMessageSvc *m)
Create a catalog file, initialization of XercesC.
Definition: XMLFileCatalog.cpp:192
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:100
std::pair
Gaudi::XMLFileCatalog::~XMLFileCatalog
~XMLFileCatalog() override=default
Destructor,.
Gaudi::XMLFileCatalog::existsFID
bool existsFID(CSTR fid) const override
Return the status of a FileID.
Definition: XMLFileCatalog.h:66
Gaudi::XMLFileCatalog::setMetaData
void setMetaData(CSTR fid, CSTR name, CSTR value) const override
Insert/update metadata item.
Definition: XMLFileCatalog.cpp:299
std::unique_ptr< xercesc::XercesDOMParser >
Gaudi::createGuidAsString
std::string createGuidAsString()
Helper function creating file identifier using the UUID mechanism.
Gaudi::XMLFileCatalog::registerLFN
void registerLFN(CSTR fid, CSTR lfn) const override
Create a FileID and Node of the logical file name with all the attributes.
Definition: XMLFileCatalog.cpp:425
Gaudi::XMLFileCatalog::commit
void commit() override
Save DOM catalog to file.
Definition: XMLFileCatalog.cpp:454
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
Gaudi::XMLFileCatalog::i_registerFID
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
Definition: XMLFileCatalog.cpp:357
Gaudi::XMLFileCatalog::init
void init() override
Parse the DOM tree of the XML catalog.
Definition: XMLFileCatalog.cpp:215
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:106
Gaudi::XMLFileCatalog::registerFID
void registerFID(CSTR fid) const override
Create a FileID and Node.
Definition: XMLFileCatalog.cpp:345
Gaudi::XMLFileCatalog::getPFN
void getPFN(CSTR fid, Files &files) const override
Dump all physical file names of the catalog and their attributes associate to the FileID...
Definition: XMLFileCatalog.cpp:266
Gaudi::XMLFileCatalog
This class constitutes the core of the XML based FileCatalog API for POOL.
Definition: XMLFileCatalog.h:28
Gaudi::XMLFileCatalog::dirty
bool dirty() const override
Check if the catalog should be updated.
Definition: XMLFileCatalog.h:56
Gaudi::XMLFileCatalog::createFID
std::string createFID() const override
Catalog interface.
Definition: XMLFileCatalog.cpp:198
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:101
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::XMLFileCatalog::getFID
void getFID(Strings &fids) const override
Dump all file Identifiers.
Definition: XMLFileCatalog.cpp:259
Gaudi::XMLFileCatalog::dropMetaData
void dropMetaData(CSTR fid) const override
Drop all metadata of one FID.
Definition: XMLFileCatalog.h:88
Gaudi::XMLFileCatalog::deleteFID
void deleteFID(CSTR FileID) const override
Delete FileID Node from the catalog.
Definition: XMLFileCatalog.cpp:338