ATLAS Offline Software
Loading...
Searching...
No Matches
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
9#include "GaudiKernel/Bootstrap.h"
10#include "GaudiKernel/ISvcLocator.h"
12
13using namespace pool;
14
16public:
17 InsertFileToCatalogApplication( int argc, char* argv[] );
18
19 bool parseArguments();
20 void execute();
21 void printSyntax();
22
23private:
24 std::string m_catalogFN;
25};
26
27
28
30 : SimpleUtilityBase( argc, argv )
31{
32 initGaudi();
33}
34
35
36bool
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 }
63}
64
65void
67{
68 startSession();
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
85void
87{
88 std::cout << "Syntax : " << executableName << " [-u fileCatalog] [-t technologyType] files" << std::endl;
89}
90
91
92
93int main ATLAS_NOT_THREAD_SAFE ( int argc, char* argv[] )
94{
95 InsertFileToCatalogApplication app( argc, argv );
96 return app.run();
97}
int main(int, char **)
Main class for all the CppUnit test classes.
Define macros for attributes used to control the static checker.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
InsertFileToCatalogApplication(int argc, char *argv[])
static bool initGaudi()
initialize the Gaudi framework for standalone executables
std::vector< std::string > fileNames
virtual void startSession ATLAS_NOT_THREAD_SAFE()
std::vector< std::string > args
virtual void readFileGUIDs()
SimpleUtilityBase(int argc=0, char *argv[]=0)
constructor taking commandline parmeters
virtual bool parseArguments()
std::vector< std::pair< std::string, std::string > > fidAndPfn
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.
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.
Framework include files.
Definition libname.h:15