Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
XMLFileCatalog.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIUTILS_XMLFILECATALOG_H
12 #define GAUDIUTILS_XMLFILECATALOG_H
13 
15 #include "xercesc/dom/DOMDocument.hpp"
16 #include "xercesc/dom/DOMElement.hpp"
17 #include "xercesc/parsers/XercesDOMParser.hpp"
18 #include "xercesc/sax/ErrorHandler.hpp"
19 
20 #include <memory>
21 
22 // Forward declarations
23 class IMessageSvc;
24 
25 /*
26  * Gaudi namespace declaration
27  */
28 namespace Gaudi {
29 
37  class XMLFileCatalog : public implements<IFileCatalog> {
38  protected:
39  typedef const std::string& CSTR;
40 
41  public:
44 
46  std::string createFID() const override;
49  CSTR connectInfo() const override { return m_file; }
51  void init() override;
53  void commit() override;
55  void rollback() override {
56  if ( dirty() ) init();
57  }
59  bool readOnly() const override { return m_rdOnly; }
61  bool dirty() const override { return m_update; }
63  bool existsPFN( CSTR pfn ) const override { return element( pfn, false ) != 0; }
65  std::string lookupPFN( CSTR fid ) const override { return lookupFID( fid ); }
67  bool existsLFN( CSTR lfn ) const override { return element( lfn, false ) != 0; }
69  std::string lookupLFN( CSTR lfn ) const override { return lookupFID( lfn ); }
71  bool existsFID( CSTR fid ) const override { return element( fid, false ) != 0; }
73  void getPFN( CSTR fid, Files& files ) const override;
75  void getLFN( CSTR fid, Files& files ) const override;
77  void getFID( Strings& fids ) const override;
79  void deleteFID( CSTR FileID ) const override;
81  void registerPFN( CSTR fid, CSTR pfn, CSTR ftype ) const override;
83  void registerLFN( CSTR fid, CSTR lfn ) const override;
85  void registerFID( CSTR fid ) const override;
87  void renamePFN( CSTR pfn, CSTR new_pfn ) const override;
89  void deletePFN( CSTR pfn ) const override;
91  void getMetaData( CSTR fid, Attributes& attr ) const override;
93  std::string getMetaDataItem( CSTR fid, CSTR name ) const override;
95  void setMetaData( CSTR fid, CSTR name, CSTR value ) const override;
97  void dropMetaData( CSTR fid ) const override { dropMetaData( fid, "*" ); }
99  void dropMetaData( CSTR fid, CSTR attr ) const override;
100 
101  private:
102  xercesc::DOMDocument* getDoc( bool throw_if_no_exists = true ) const;
103  std::string getfile( bool create );
104  void printError( CSTR msg, bool throw_exc = true ) const;
105  std::string lookupFID( CSTR lfn ) const;
106  xercesc::DOMNode* element( CSTR fid, bool print_err = true ) const;
107  xercesc::DOMNode* child( xercesc::DOMNode* par, CSTR tag, CSTR attr = "", CSTR val = "" ) const;
109  bool m_rdOnly = false;
110  mutable bool m_update = false;
111  xercesc::DOMDocument* m_doc = nullptr;
116  };
119 } /* End namespace Gaudi */
120 #endif /* GAUDIUTILS_XMLFILECATALOG_H */
Gaudi::XMLFileCatalog::deletePFN
void deletePFN(CSTR pfn) const override
remove a PFN
Definition: XMLFileCatalog.cpp:338
std::string
STL class.
IMessageSvc
Definition: IMessageSvc.h:47
Gaudi::XMLFileCatalog::m_parser
std::unique_ptr< xercesc::XercesDOMParser > m_parser
Definition: XMLFileCatalog.h:112
Gaudi::XMLFileCatalog::existsFID
bool existsFID(CSTR fid) const override
Return the status of a FileID.
Definition: XMLFileCatalog.h:71
std::pair
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:270
Gaudi::XMLFileCatalog::XMLFileCatalog
XMLFileCatalog(CSTR url, IMessageSvc *m)
Create a catalog file, initialization of XercesC.
Definition: XMLFileCatalog.cpp:189
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
Gaudi::XMLFileCatalog::setMetaData
void setMetaData(CSTR fid, CSTR name, CSTR value) const override
Insert/update metadata item.
Definition: XMLFileCatalog.cpp:280
Gaudi::XMLFileCatalog::deleteFID
void deleteFID(CSTR FileID) const override
Delete FileID Node from the catalog.
Definition: XMLFileCatalog.cpp:315
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:257
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:251
Gaudi::XMLFileCatalog::commit
void commit() override
Save DOM catalog to file.
Definition: XMLFileCatalog.cpp:447
Gaudi::XMLFileCatalog::connectInfo
CSTR connectInfo() const override
Access to connect string.
Definition: XMLFileCatalog.h:49
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:115
compareOutputFiles.par
par
Definition: compareOutputFiles.py:486
Gaudi::XMLFileCatalog::getfile
std::string getfile(bool create)
Definition: XMLFileCatalog.cpp:474
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:419
TimingHistograms.name
name
Definition: TimingHistograms.py:25
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:108
Gaudi::XMLFileCatalog::dropMetaData
void dropMetaData(CSTR fid) const override
Drop all metadata of one FID.
Definition: XMLFileCatalog.h:97
Gaudi::XMLFileCatalog::dirty
bool dirty() const override
Check if the catalog should be updated.
Definition: XMLFileCatalog.h:61
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:111
Gaudi::XMLFileCatalog::i_registerFID
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
Definition: XMLFileCatalog.cpp:353
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:109
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:309
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:59
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:199
BoostArrayProperties.Strings
Strings
Definition: BoostArrayProperties.py:35
implements
Base class used to implement the interfaces.
Definition: implements.h:19
Gaudi::XMLFileCatalog::rollback
void rollback() override
Save DOM catalog to file.
Definition: XMLFileCatalog.h:55
Gaudi::XMLFileCatalog::CSTR
const std::string & CSTR
Definition: XMLFileCatalog.h:39
Gaudi::XMLFileCatalog::lookupPFN
std::string lookupPFN(CSTR fid) const override
Lookup file identifier by physical file name.
Definition: XMLFileCatalog.h:65
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:389
Gaudi::XMLFileCatalog
Definition: XMLFileCatalog.h:37
Gaudi::XMLFileCatalog::init
void init() override
Parse the DOM tree of the XML catalog.
Definition: XMLFileCatalog.cpp:205
Gaudi::createGuidAsString
std::string createGuidAsString()
Helper function creating file identifier using the UUID mechanism.
Gaudi::XMLFileCatalog::renamePFN
void renamePFN(CSTR pfn, CSTR new_pfn) const override
rename a PFN
Definition: XMLFileCatalog.cpp:330
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:263
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:194
IFileCatalog.h
Gaudi::XMLFileCatalog::getMetaDataItem
std::string getMetaDataItem(CSTR fid, CSTR name) const override
Access metadata item.
Definition: XMLFileCatalog.cpp:296
Gaudi::XMLFileCatalog::lookupLFN
std::string lookupLFN(CSTR lfn) const override
Lookup file identifier by logical file name.
Definition: XMLFileCatalog.h:69
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:110
std::unique_ptr< xercesc::XercesDOMParser >
Gaudi::XMLFileCatalog::registerFID
void registerFID(CSTR fid) const override
Create a FileID and Node.
Definition: XMLFileCatalog.cpp:321
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:114
Gaudi::XMLFileCatalog::m_errHdlr
std::unique_ptr< xercesc::ErrorHandler > m_errHdlr
Definition: XMLFileCatalog.h:113
Gaudi::XMLFileCatalog::getFID
void getFID(Strings &fids) const override
Dump all file Identifiers.
Definition: XMLFileCatalog.cpp:245
Gaudi::XMLFileCatalog::existsPFN
bool existsPFN(CSTR pfn) const override
Return the status of a physical file name.
Definition: XMLFileCatalog.h:63
Gaudi::XMLFileCatalog::lookupFID
std::string lookupFID(CSTR lfn) const
Definition: XMLFileCatalog.cpp:230
Gaudi::XMLFileCatalog::existsLFN
bool existsLFN(CSTR lfn) const override
Return the status of a logical file name.
Definition: XMLFileCatalog.h:67
Gaudi::XMLFileCatalog::createFID
std::string createFID() const override
Catalog interface
Definition: XMLFileCatalog.cpp:192