ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaPOOL
PoolSvc
src
IFileCatalog.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "GaudiUtils/IFileCatalog.h"
6
#include "GaudiUtils/IFileCatalogMgr.h"
7
#include "GaudiKernel/SmartIF.h"
8
#include "GaudiKernel/Bootstrap.h"
9
#include "GaudiKernel/ISvcLocator.h"
10
#include "GaudiKernel/IMessageSvc.h"
11
12
#include "
PoolSvc/IFileCatalog.h
"
13
#include "
StorageSvc/DbPrint.h
"
14
15
#include <exception>
16
#include <algorithm>
17
18
using namespace
pool
;
19
20
pool::IFileCatalog::IFileCatalog
()
21
:
AthMessaging
(
Gaudi
::svcLocator()->service<IMessageSvc>(
"MessageSvc"
).
get
(),
"APRFileCatalog"
),
22
m_mgr
(
Gaudi
::svcLocator()->service<
Gaudi
::IFileCatalogMgr>(
"Gaudi::MultiFileCatalog"
)),
23
m_fc
(
m_mgr
)
24
{
25
// set the output level of this service
26
setLevel
(
DbPrint::getOutputLvl
() );
27
// set the output level of the XMLCatalog component - works only if the Gaudi AppMgr was initialized
28
Gaudi::svcLocator()->service<IMessageSvc>(
"MessageSvc"
)
29
->setOutputLevel(
"XMLCatalog"
,
DbPrint::getOutputLvl
() );
30
}
31
32
33
void
pool::IFileCatalog::
34
getFirstPFN
(
const
std::string& fid, std::string& pfn, std::string& tech )
const
35
{
36
Files
pfns_techs;
37
getPFNs
( fid, pfns_techs );
38
if
( pfns_techs.empty() ) {
39
pfn.clear();
40
tech.clear();
41
}
else
{
42
pfn = pfns_techs[0].first;
43
tech = pfns_techs[0].second;
44
}
45
}
46
47
49
void
pool::IFileCatalog::
50
lookupFileByPFN
(
const
std::string& pfn, std::string& fid, std::string& tech )
const
51
{
52
fid =
lookupPFN
( pfn );
53
if
( !fid.empty() ) {
54
Files
pfns_techs;
55
getPFNs
( fid, pfns_techs );
56
tech.clear();
57
for
(
const
auto
& attr_pair: pfns_techs ) {
58
if
( attr_pair.first == pfn )
59
tech = attr_pair.second;
60
}
61
}
62
}
63
64
66
void
pool::IFileCatalog::
67
registerPFN
(
const
std::string& pfn,
const
std::string& ftype, std::string& fid )
68
{
69
if
(
existsPFN
(pfn) ) {
70
throw
std::runtime_error(
"PFN '"
+ pfn +
"' already registered (APR: \" registerPFN \" from \" FileCatalog \")"
);
71
}
72
if
( fid.empty() ) fid =
m_fc
->createFID();
73
ATH_MSG_DEBUG
(
"Registering PFN="
<< pfn <<
" of type="
<< ftype <<
" GUID="
<< fid);
74
m_fc
->registerPFN(fid, pfn, ftype);
75
}
76
77
78
// ------------------------- Catalog Manager interface
79
81
void
pool::IFileCatalog::addCatalog
(
const
std::string& connect,
bool
forWriting )
82
{
83
std::string url;
84
if
( connect.empty() ) {
85
url =
"file:PoolFileCatalog.xml"
;
86
}
else
{
87
auto
pos = connect.find(
"file:"
);
88
url = (pos==std::string::npos)?
"file:"
+ connect : connect.substr(pos);
89
}
90
Catalogs
& cats =
m_mgr
->catalogs();
91
auto
i = std::find_if( cats.begin(), cats.end(),
92
[&](
const
Gaudi::IFileCatalog* f )
93
{ return url == f->connectInfo(); } );
94
if
( i==cats.end() ) {
95
// add a new catalog
96
const
std::string fullconnectstr =
"xmlcatalog_"
+ url;
97
ATH_MSG_DEBUG
(
"addCatalog(\""
<< fullconnectstr <<
"\")"
);
98
m_mgr
->addCatalog( fullconnectstr );
99
}
100
if
( forWriting ) {
101
m_mgr
->setWriteCatalog(
m_mgr
->findCatalog( url,
true
) );
102
}
103
}
104
105
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
DbPrint.h
IFileCatalog.h
AthMessaging::setLevel
void setLevel(MSG::Level lvl)
Change the current logging level.
Definition
AthMessaging.cxx:28
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
pool::DbPrint::getOutputLvl
static MSG::Level getOutputLvl()
pool::IFileCatalog::addCatalog
void addCatalog(const std::string &connect, bool forWriting=false)
Add new catalog identified by name to the existing ones.
Definition
IFileCatalog.cxx:81
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:47
pool::IFileCatalog::lookupFileByPFN
void lookupFileByPFN(const std::string &pfn, std::string &fid, std::string &tech) const
Get FID and filetype for a given PFN.
Definition
IFileCatalog.cxx:50
pool::IFileCatalog::m_fc
SmartIF< Gaudi::IFileCatalog > m_fc
Definition
IFileCatalog.h:91
pool::IFileCatalog::IFileCatalog
IFileCatalog()
Definition
IFileCatalog.cxx:20
pool::IFileCatalog::existsPFN
bool existsPFN(const std::string &pfn) const
Return the status of a PFName.
Definition
IFileCatalog.h:56
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.
Definition
IFileCatalog.cxx:34
pool::IFileCatalog::m_mgr
SmartIF< Gaudi::IFileCatalogMgr > m_mgr
Definition
IFileCatalog.h:90
pool::IFileCatalog::Files
Gaudi::IFileCatalog::Files Files
Definition
IFileCatalog.h:23
pool::IFileCatalog::Catalogs
Gaudi::IFileCatalogMgr::Catalogs Catalogs
Definition
IFileCatalog.h:25
pool::IFileCatalog::registerPFN
void registerPFN(const std::string &pfn, const std::string &ftype, std::string &fid)
Register PFN, assign new FID if not given.
Definition
IFileCatalog.cxx:67
pool::IFileCatalog::lookupPFN
std::string lookupPFN(const std::string &pfn) const
Lookup file identifier by physical file name.
Definition
IFileCatalog.h:59
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition
hcg.cxx:132
Gaudi
=============================================================================
Definition
CaloGPUClusterAndCellDataMonitorOptions.h:273
pool
Framework include files.
Definition
libname.h:15
Generated on
for ATLAS Offline Software by
1.17.0