ATLAS Offline Software
Loading...
Searching...
No Matches
PoolTestBase.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef POOLTESTBASE_H
5#define POOLTESTBASE_H
6
7#include <string>
8#include <iostream>
9
10#include "GaudiKernel/System.h"
11#include "GaudiKernel/ISvcLocator.h"
14
15
18public:
19 PoolTestBase() = default;
20 PoolTestBase(const PoolTestBase&) = delete;
22 virtual ~PoolTestBase() = default;
23
25 static void loadLibraries( const std::vector<std::string>& libraries );
27 ToolHandle<ISessionTool> createSession( Gaudi::IFileCatalog& fileCatalog, const std::string& sessionName );
28};
29
30
31inline
32void PoolTestBase::loadLibraries( const std::vector<std::string>& libraries )
33{
34 for( std::vector<std::string>::const_iterator iLibrary = libraries.begin();
35 iLibrary != libraries.end(); ++iLibrary ) {
36 const std::string& library = *iLibrary;
37 std::cout << "Loading library " << library << std::endl;
38
39 System::ImageHandle libhandle;
40 if( System::loadDynamicLib(library, &libhandle) != 1 ) {
41 std::cout << "Error! library loading failed" << std::endl;
42 }
43 }
44}
45
46
47// Sessions created here as Tools (and managed by the ToolSvc) need to be closed by hand with closeSession() to cleanup everything
48inline ToolHandle<ISessionTool>
49PoolTestBase::createSession( Gaudi::IFileCatalog& catalog, const std::string& sessionName )
50{
51 std::cout << "Creating the persistency service" << std::endl;
52 auto dbsession = ToolHandle<ISessionTool>("SessionTool/" + sessionName, Gaudi::svcLocator()->service("ToolSvc"));
53 if( !dbsession.retrieve().isSuccess() ) {
54 throw std::runtime_error( "Could not create DB Session" );
55 }
56 dbsession->setupFC( catalog );
57 return dbsession;
58}
59
60#endif
virtual ~PoolTestBase()=default
static void loadLibraries(const std::vector< std::string > &libraries)
load local dictionary libraries for the test
PoolTestBase & operator=(const PoolTestBase &)=delete
PoolTestBase(const PoolTestBase &)=delete
PoolTestBase()=default
ToolHandle< ISessionTool > createSession(Gaudi::IFileCatalog &fileCatalog, const std::string &sessionName)
create a session tool for the test with @sessionName, attach the catalog to it