ATLAS Offline Software
IFileCatalog.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef APR_IFILECATALOG_H
6 #define APR_IFILECATALOG_H
7 
8 #include "GaudiUtils/IFileCatalog.h"
9 #include "GaudiUtils/IFileCatalogMgr.h"
10 #include "GaudiKernel/SmartIF.h"
11 
13 #include "GaudiKernel/IMessageSvc.h"
14 
15 #include <iostream>
16 
17 namespace pool {
18 
19  namespace FileCatalog {
20  typedef std::string FileID;
21  }
22 
23  class IFileCatalog : public AthMessaging {
24  public:
25 
28  typedef Gaudi::IFileCatalogMgr::Catalogs Catalogs;
29 
30 
33 
34  // ------------------------------ Catalog interface
35 
37  std::string createFID() const;
38 
39  void connect() { /* not doing anything in Gaudi FC */ }
40  void disconnect() { /* not doing anything in Gaudi FC */ }
42  const std::string& connectInfo() const { return m_fc->connectInfo(); }
43 
45  void start() { init(); }
47  void init() { m_fc->init(); }
49  void commit() { m_fc->commit(); }
51  void rollback() { m_fc->rollback(); }
53  bool readOnly() const { return m_fc->readOnly(); }
55  bool dirty() const { return m_fc->dirty(); }
56 
58  void getFIDs( Strings& fids ) const { m_fc->getFID(fids); }
59 
61  void getLFNs( const std::string& fid, Files& files ) const { m_fc->getLFN(fid, files); }
62 
64  void getPFNs( const std::string& fid, Files& files ) const { m_fc->getPFN(fid, files); }
65 
67  void getFirstPFN( const std::string& fid, std::string& pfn, std::string& tech ) const;
68 
70  void lookupFileByPFN( const std::string& pfn, std::string& fid, std::string& tech ) const;
71 
73  bool existsPFN( const std::string& pfn ) const { return m_fc->existsPFN(pfn); }
74 
76  std::string lookupPFN( const std::string& pfn ) const { return m_fc->lookupPFN(pfn); }
77 
79  // bool existsLFN( const std::string& lfn ) const = 0;
80 
82  void lookupFileByLFN( const std::string& lfn, std::string& fid ) const { fid = lookupLFN(lfn); }
83  std::string lookupLFN( const std::string& lfn ) const { return m_fc->lookupLFN(lfn); }
84 
86  // bool existsFID( const std::string& fid ) const = 0;
87 
89  void deleteFID( const std::string& FileID ) { m_fc->deleteFID(FileID); }
90 
92  void deletePFN( const std::string& pfn ) { m_fc->deletePFN(pfn); }
93 
95  void registerPFN( const std::string& pfn, const std::string& ftype, std::string& fid );
96 
98  void renamePFN( const std::string& pfn, const std::string& newpfn ) { m_fc->renamePFN(pfn, newpfn); }
99 
101  void addReplicaPFN( const std::string& pfn, const std::string& replica_pfn );
102 
104  void addReplicaFID( const std::string& fid,
105  const std::string& replica_pfn,
106  const std::string& replica_tech = "ROOT_All" );
107 
109  // NOTE! this method requires FID! (and not PFN)
110  void registerLFN( const std::string& fid, const std::string& lfn ) const { m_fc->registerLFN(fid, lfn ); }
111 
112 
113  // ------------------------- Catalog Manager interface
114 
116  void addReadCatalog( const std::string& connect ) { addCatalog(connect); }
117  void addCatalog( const std::string& connect );
118 
120  //void addCatalog( Gaudi::IFileCatalog* cat ) { m_mgr->addCatalog(cat); }
121 
123  void removeCatalog( const std::string& connect ) { m_mgr->removeCatalog(connect); }
124 
126  //void removeCatalog( const Gaudi::IFileCatalog* cat ) { m_mgr->removeCatalog(cat); }
128  Catalogs& catalogs() { return m_mgr->catalogs(); }
130  const Catalogs& catalogs() const { return m_mgr->catalogs(); }
132  //Gaudi::IFileCatalog* writeCatalog( const std::string& fid = "" ) const { return m_mgr->writeCatalog(fid); }
134  //void setWriteCatalog( Gaudi::IFileCatalog* cat ) { m_mgr->setWriteCatalog(cat); }
136  void setWriteCatalog( const std::string& connect );
137 
138 
139  protected:
140  SmartIF<Gaudi::IFileCatalogMgr> m_mgr;
141  SmartIF<Gaudi::IFileCatalog> m_fc;
142  };
143 
144 }
145 
146 #endif
pool::IFileCatalog::connectInfo
const std::string & connectInfo() const
Get the connect string.
Definition: IFileCatalog.h:42
pool::IFileCatalog::lookupFileByPFN
void lookupFileByPFN(const std::string &pfn, std::string &fid, std::string &tech) const
Get FID and filetype for a given PFN.
pool::IFileCatalog::Files
Gaudi::IFileCatalog::Files Files
Definition: IFileCatalog.h:26
pool::IFileCatalog::IFileCatalog
IFileCatalog()
pool::IFileCatalog::registerPFN
void registerPFN(const std::string &pfn, const std::string &ftype, std::string &fid)
Register PFN, assign new FID if not given.
pool::FileCatalog::FileID
std::string FileID
Definition: IFileCatalog.h:20
pool::IFileCatalog::addReplicaFID
void addReplicaFID(const std::string &fid, const std::string &replica_pfn, const std::string &replica_tech="ROOT_All")
adding replica to an existing FID
pool::IFileCatalog::deletePFN
void deletePFN(const std::string &pfn)
Delete PFN from the catalog (delete entire FID entry if it was the last PFN)
Definition: IFileCatalog.h:92
pool
pool namespace
Definition: libname.h:15
pool::IFileCatalog::m_mgr
SmartIF< Gaudi::IFileCatalogMgr > m_mgr
Definition: IFileCatalog.h:140
pool::IFileCatalog::renamePFN
void renamePFN(const std::string &pfn, const std::string &newpfn)
Rename PFN.
Definition: IFileCatalog.h:98
pool::IFileCatalog::disconnect
void disconnect()
Definition: IFileCatalog.h:40
pool::IFileCatalog::registerLFN
void registerLFN(const std::string &fid, const std::string &lfn) const
Create a Node for a FileID and DOM Node of the LFN with all the attributes.
Definition: IFileCatalog.h:110
pool::IFileCatalog::commit
void commit()
Save catalog to file.
Definition: IFileCatalog.h:49
AthenaPoolTestRead.Files
Files
Definition: AthenaPoolTestRead.py:10
McUtils::Strings
std::vector< std::string > Strings
Definition: DecayParser.h:30
pool::IFileCatalog::lookupFileByLFN
void lookupFileByLFN(const std::string &lfn, std::string &fid) const
Return the status of a LFName.
Definition: IFileCatalog.h:82
pool::IFileCatalog::rollback
void rollback()
Save catalog to file.
Definition: IFileCatalog.h:51
pool::IFileCatalog
Definition: IFileCatalog.h:23
rerun_display.lfn
lfn
Definition: rerun_display.py:60
pool::IFileCatalog::getFIDs
void getFIDs(Strings &fids) const
Get all FIDs.
Definition: IFileCatalog.h:58
pool::IFileCatalog::lookupPFN
std::string lookupPFN(const std::string &pfn) const
Lookup file identifier by physical file name.
Definition: IFileCatalog.h:76
pool::IFileCatalog::catalogs
const Catalogs & catalogs() const
Access catalog container (CONST)
Definition: IFileCatalog.h:130
pool::IFileCatalog::Catalogs
Gaudi::IFileCatalogMgr::Catalogs Catalogs
Definition: IFileCatalog.h:28
pool::IFileCatalog::m_fc
SmartIF< Gaudi::IFileCatalog > m_fc
Definition: IFileCatalog.h:141
pool::IFileCatalog::start
void start()
redirect to init() for Gaudi FC
Definition: IFileCatalog.h:45
generateReferenceFile.files
files
Definition: generateReferenceFile.py:12
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
pool::IFileCatalog::setWriteCatalog
void setWriteCatalog(const std::string &connect)
Access to the (first) writable file catalog.
pool::IFileCatalog::lookupLFN
std::string lookupLFN(const std::string &lfn) const
Definition: IFileCatalog.h:83
pool::IFileCatalog::addReplicaPFN
void addReplicaPFN(const std::string &pfn, const std::string &replica_pfn)
adding replica to an existing PFN
pool::IFileCatalog::connect
void connect()
Definition: IFileCatalog.h:39
pool::IFileCatalog::removeCatalog
void removeCatalog(const std::string &connect)
Add new catalog identified by reference to the existing ones.
Definition: IFileCatalog.h:123
pool::IFileCatalog::Strings
Gaudi::IFileCatalog::Strings Strings
Definition: IFileCatalog.h:27
pool::FileID
std::string FileID
Definition: FileDescriptor.h:27
pool::IFileCatalog::~IFileCatalog
~IFileCatalog()
Definition: IFileCatalog.h:32
pool::IFileCatalog::getPFNs
void getPFNs(const std::string &fid, Files &files) const
Dump all PFNames of the catalog and their attributes associate to the FileID.
Definition: IFileCatalog.h:64
pool::IFileCatalog::getFirstPFN
void getFirstPFN(const std::string &fid, std::string &pfn, std::string &tech) const
Get the first PFN + filetype for the given FID.
pool::IFileCatalog::addCatalog
void addCatalog(const std::string &connect)
pool::IFileCatalog::dirty
bool dirty() const
Check if the catalog should be updated.
Definition: IFileCatalog.h:55
pool::IFileCatalog::existsPFN
bool existsPFN(const std::string &pfn) const
Return the status of a PFName.
Definition: IFileCatalog.h:73
AthMessaging.h
pool::IFileCatalog::catalogs
Catalogs & catalogs()
Remove catalog identified by reference from the existing ones.
Definition: IFileCatalog.h:128
pool::IFileCatalog::init
void init()
Parse the DOM tree of the XML catalog.
Definition: IFileCatalog.h:47
pool::IFileCatalog::deleteFID
void deleteFID(const std::string &FileID)
Return the status of a FileID.
Definition: IFileCatalog.h:89
pool::IFileCatalog::createFID
std::string createFID() const
Create file identifier using UUID mechanism.
pool::IFileCatalog::readOnly
bool readOnly() const
Check if the catalog is read-only.
Definition: IFileCatalog.h:53
pool::IFileCatalog::addReadCatalog
void addReadCatalog(const std::string &connect)
Add new catalog identified by name to the existing ones.
Definition: IFileCatalog.h:116
pool::IFileCatalog::getLFNs
void getLFNs(const std::string &fid, Files &files) const
Get all logical names for a given FID. Return pairs <LFN,FID>
Definition: IFileCatalog.h:61