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
using namespace
pool
;
14
15
class
ATLAS_NOT_THREAD_SAFE
InsertFileToCatalogApplication
:
public
SimpleUtilityBase
{
16
public
:
17
InsertFileToCatalogApplication
(
int
argc,
char
* argv[] );
18
19
bool
parseArguments
();
20
void
execute
();
21
void
printSyntax
();
22
23
private
:
24
std::string
m_catalogFN
;
25
};
26
27
28
29
InsertFileToCatalogApplication::InsertFileToCatalogApplication
(
int
argc,
char
* argv[] )
30
:
SimpleUtilityBase
( argc, argv )
31
{
32
initGaudi
();
33
}
34
35
36
bool
37
InsertFileToCatalogApplication::parseArguments
()
38
{
39
unsigned
int
excludedArgument = 0;
40
for
(
unsigned
int
iArg = 0; iArg <
args
.size(); ++iArg ) {
41
if
( iArg > 0 && iArg == excludedArgument )
42
continue
;
43
const
std::string& arg =
args
[iArg];
44
if
( arg ==
"-u"
) {
45
unsigned
int
nextArgumentIndex = iArg + 1;
46
if
( nextArgumentIndex <
args
.size() ) {
47
excludedArgument = nextArgumentIndex;
48
m_catalogFN
=
args
[nextArgumentIndex];
49
}
50
}
51
else
if
( arg ==
"-t"
) {
52
unsigned
int
nextArgumentIndex = iArg + 1;
53
if
( nextArgumentIndex <
args
.size() ) {
54
excludedArgument = nextArgumentIndex;
55
technologyName
=
args
[nextArgumentIndex];
56
}
57
}
58
else
{
59
fileNames
.push_back( arg );
60
}
61
}
62
return
SimpleUtilityBase::parseArguments
();
63
}
64
65
void
66
InsertFileToCatalogApplication::execute
()
67
{
68
startSession();
69
readFileGUIDs
();
70
71
// Open the file catalog and insert the pfn/fid/technology
72
SmartIF<Gaudi::IFileCatalogMgr> catalogMgr = Gaudi::svcLocator()->service<Gaudi::IFileCatalogMgr>(
"Gaudi::MultiFileCatalog"
);
73
SmartIF<Gaudi::IFileCatalog> catalog( catalogMgr );
74
FileCatalogUtils::addCatalog
( *catalogMgr,
m_catalogFN
,
true
);
75
catalog->init();
76
77
for
(
const
auto
& fp :
fidAndPfn
) {
78
std::string fid = fp.first;
// can't be const
79
FileCatalogUtils::registerPFN
(*catalog, fp.second,
technologyName
, fid);
80
}
81
catalog->commit();
82
}
83
84
85
void
86
InsertFileToCatalogApplication::printSyntax
()
87
{
88
std::cout <<
"Syntax : "
<<
executableName
<<
" [-u fileCatalog] [-t technologyType] files"
<< std::endl;
89
}
90
91
92
93
int
main
ATLAS_NOT_THREAD_SAFE
(
int
argc,
char
* argv[] )
94
{
95
InsertFileToCatalogApplication
app( argc, argv );
96
return
app.
run
();
97
}
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:15
InsertFileToCatalogApplication::parseArguments
bool parseArguments()
Definition
pool_insertFileToCatalog.cxx:37
InsertFileToCatalogApplication::m_catalogFN
std::string m_catalogFN
Definition
pool_insertFileToCatalog.cxx:24
InsertFileToCatalogApplication::printSyntax
void printSyntax()
Definition
pool_insertFileToCatalog.cxx:86
InsertFileToCatalogApplication::InsertFileToCatalogApplication
InsertFileToCatalogApplication(int argc, char *argv[])
Definition
pool_insertFileToCatalog.cxx:29
InsertFileToCatalogApplication::execute
void execute()
Definition
pool_insertFileToCatalog.cxx:66
pool::SimpleUtilityBase::initGaudi
static bool initGaudi()
initialize the Gaudi framework for standalone executables
pool::SimpleUtilityBase::fileNames
std::vector< std::string > fileNames
Definition
SimpleUtilityBase.h:48
pool::SimpleUtilityBase::ATLAS_NOT_THREAD_SAFE
virtual void startSession ATLAS_NOT_THREAD_SAFE()
pool::SimpleUtilityBase::executableName
std::string executableName
Definition
SimpleUtilityBase.h:43
pool::SimpleUtilityBase::technologyName
std::string technologyName
Definition
SimpleUtilityBase.h:44
pool::SimpleUtilityBase::args
std::vector< std::string > args
Definition
SimpleUtilityBase.h:47
pool::SimpleUtilityBase::readFileGUIDs
virtual void readFileGUIDs()
pool::SimpleUtilityBase::run
virtual int run()
pool::SimpleUtilityBase::SimpleUtilityBase
SimpleUtilityBase(int argc=0, char *argv[]=0)
constructor taking commandline parmeters
pool::SimpleUtilityBase::printSyntax
virtual void printSyntax()
Definition
SimpleUtilityBase.h:37
pool::SimpleUtilityBase::parseArguments
virtual bool parseArguments()
pool::SimpleUtilityBase::fidAndPfn
std::vector< std::pair< std::string, std::string > > fidAndPfn
Definition
SimpleUtilityBase.h:49
pool::SimpleUtilityBase::execute
virtual void execute()
Definition
SimpleUtilityBase.h:36
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:44
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:56
pool
Framework include files.
Definition
libname.h:15
Generated on
for ATLAS Offline Software by
1.17.0