ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaPOOL
PoolSvc
utilities
pool_insertFileToCatalog.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 <memory>
6
7
#include "
CxxUtils/checker_macros.h
"
8
#include "
PoolSvc/FileCatalogUtils.h
"
9
#include "GaudiKernel/Bootstrap.h"
10
#include "GaudiKernel/ISvcLocator.h"
11
#include "
StorageSvc/SimpleUtilityBase.h
"
12
13
14
class
ATLAS_NOT_THREAD_SAFE
InsertFileToCatalogApplication
:
public
SimpleUtilityBase
{
15
public
:
16
InsertFileToCatalogApplication
(
int
argc,
char
* argv[] );
17
18
bool
parseArguments
();
19
void
execute
();
20
void
printSyntax
();
21
22
private
:
23
std::string
m_catalogFN
;
24
};
25
26
27
28
InsertFileToCatalogApplication::InsertFileToCatalogApplication
(
int
argc,
char
* argv[] )
29
:
SimpleUtilityBase
( argc, argv )
30
{
31
initGaudi
();
32
}
33
34
35
bool
36
InsertFileToCatalogApplication::parseArguments
()
37
{
38
unsigned
int
excludedArgument = 0;
39
for
(
unsigned
int
iArg = 0; iArg <
m_args
.size(); ++iArg ) {
40
if
( iArg > 0 && iArg == excludedArgument )
41
continue
;
42
const
std::string& arg =
m_args
[iArg];
43
if
( arg ==
"-u"
) {
44
unsigned
int
nextArgumentIndex = iArg + 1;
45
if
( nextArgumentIndex <
m_args
.size() ) {
46
excludedArgument = nextArgumentIndex;
47
m_catalogFN
=
m_args
[nextArgumentIndex];
48
}
49
}
50
else
if
( arg ==
"-t"
) {
51
unsigned
int
nextArgumentIndex = iArg + 1;
52
if
( nextArgumentIndex <
m_args
.size() ) {
53
excludedArgument = nextArgumentIndex;
54
m_technologyName
=
m_args
[nextArgumentIndex];
55
}
56
}
57
else
{
58
m_fileNames
.push_back( arg );
59
}
60
}
61
return
SimpleUtilityBase::parseArguments
();
62
}
63
64
void
65
InsertFileToCatalogApplication::execute
()
66
{
67
startSession();
68
readFileGUIDs
();
69
70
// Open the file catalog and insert the pfn/fid/technology
71
SmartIF<Gaudi::IFileCatalogMgr> catalogMgr = Gaudi::svcLocator()->service<Gaudi::IFileCatalogMgr>(
"Gaudi::MultiFileCatalog"
);
72
SmartIF<Gaudi::IFileCatalog> catalog( catalogMgr );
73
FileCatalogUtils::addCatalog
( *catalogMgr,
m_catalogFN
,
true
);
74
catalog->init();
75
76
for
(
const
auto
& fp :
m_fidAndPfn
) {
77
std::string fid = fp.first;
// can't be const
78
FileCatalogUtils::registerPFN
(*catalog, fp.second,
m_technologyName
, fid);
79
}
80
catalog->commit();
81
}
82
83
84
void
85
InsertFileToCatalogApplication::printSyntax
()
86
{
87
std::cout <<
"Syntax : "
<<
m_executableName
<<
" [-u fileCatalog] [-t technologyType] files"
<< std::endl;
88
}
89
90
91
92
int
main
ATLAS_NOT_THREAD_SAFE
(
int
argc,
char
* argv[] )
93
{
94
InsertFileToCatalogApplication
app( argc, argv );
95
return
app.
run
();
96
}
main
int main(int, char **)
Main class for all the CppUnit test classes.
Definition
CppUnit_testdriver.cxx:21
FileCatalogUtils.h
SimpleUtilityBase.h
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition
checker_macros.h:212
InsertFileToCatalogApplication
Definition
pool_insertFileToCatalog.cxx:14
InsertFileToCatalogApplication::parseArguments
bool parseArguments()
Definition
pool_insertFileToCatalog.cxx:36
InsertFileToCatalogApplication::m_catalogFN
std::string m_catalogFN
Definition
pool_insertFileToCatalog.cxx:23
InsertFileToCatalogApplication::printSyntax
void printSyntax()
Definition
pool_insertFileToCatalog.cxx:85
InsertFileToCatalogApplication::InsertFileToCatalogApplication
InsertFileToCatalogApplication(int argc, char *argv[])
Definition
pool_insertFileToCatalog.cxx:28
InsertFileToCatalogApplication::execute
void execute()
Definition
pool_insertFileToCatalog.cxx:65
SimpleUtilityBase::execute
virtual void execute()
Definition
SimpleUtilityBase.h:34
SimpleUtilityBase::run
virtual int run()
SimpleUtilityBase::m_executableName
std::string m_executableName
Definition
SimpleUtilityBase.h:41
SimpleUtilityBase::SimpleUtilityBase
SimpleUtilityBase(int argc=0, char *argv[]=0)
constructor taking commandline parmeters
SimpleUtilityBase::printSyntax
virtual void printSyntax()
Definition
SimpleUtilityBase.h:35
SimpleUtilityBase::m_args
std::vector< std::string > m_args
Definition
SimpleUtilityBase.h:45
SimpleUtilityBase::ATLAS_NOT_THREAD_SAFE
virtual void startSession ATLAS_NOT_THREAD_SAFE()
SimpleUtilityBase::m_fileNames
std::vector< std::string > m_fileNames
Definition
SimpleUtilityBase.h:46
SimpleUtilityBase::parseArguments
virtual bool parseArguments()
SimpleUtilityBase::m_fidAndPfn
std::vector< std::pair< std::string, std::string > > m_fidAndPfn
Definition
SimpleUtilityBase.h:47
SimpleUtilityBase::initGaudi
static bool initGaudi()
initialize the Gaudi framework for standalone executables
SimpleUtilityBase::m_technologyName
std::string m_technologyName
Definition
SimpleUtilityBase.h:42
SimpleUtilityBase::readFileGUIDs
virtual void readFileGUIDs()
FileCatalogUtils::registerPFN
void registerPFN(Gaudi::IFileCatalog &fc, const std::string &pfn, const std::string &ftype, std::string &fid)
Register PFN, assign new FID if not given. Throws if the PFN is already registered.
Definition
FileCatalogUtils.cxx:41
FileCatalogUtils::addCatalog
std::string addCatalog(Gaudi::IFileCatalogMgr &mgr, const std::string &connect, bool forWriting=false)
Add new catalog, identified by name, to the existing ones, optionally as the write catalog.
Definition
FileCatalogUtils.cxx:52
Generated on
for ATLAS Offline Software by
1.17.0