ATLAS Offline Software
Loading...
Searching...
No Matches
SessionTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef POOLSVC_SESSIONTOOL_H
6#define POOLSVC_SESSIONTOOL_H
7
9#include "Database.h"
11
12#include <map>
13#include <memory>
14#include <set>
15#include <string>
16
17namespace Gaudi {
18 class IFileCatalog;
19}
20
22class Placement;
23class Token;
24
27class SessionTool : virtual public AthAlgTool
28{
29public:
31 explicit SessionTool(const std::string& type,
32 const std::string& name,
33 const IInterface* parent);
34
36 virtual ~SessionTool();
37
38 SessionTool (const SessionTool&) = delete;
40
41 virtual void setupFC( Gaudi::IFileCatalog& fileCatalog, int ageLimit = -1 );
42
54 virtual void* readObject( const Token& token, void* object = 0 );
55
65 virtual Token* registerForWrite( const Placement& place, const void* object, const RootType& type );
66
68 void registerDatabaseHandler( DatabaseHandler* dbHandler, const std::string& lfn = "" );
69
72
74 DatabaseHandler* lookupByFID( const std::string& fid );
75
77 DatabaseHandler* lookupByPFN( const std::string& pfn );
78
80 DatabaseHandler* lookupByLFN( const std::string& lfn );
81
85 virtual bool disconnectAll();
86
88 virtual bool startTransaction( Io::IoFlag type = Io::READ );
89
91 virtual bool commit();
92
94 virtual bool commitAndHold();
95
97 virtual Io::IoFlag openMode() const { return m_transactionType; }
98
100 virtual std::unique_ptr<Database> databaseHandle( const std::string& dbName,
102
104 virtual Gaudi::IFileCatalog& fileCatalog();
105
107 DatabaseHandler* connect( long technology,
108 Io::IoFlag transType,
109 const std::string& fid,
110 const std::string& pfn );
111
113 void disconnect( DatabaseHandler* database );
114
116 std::string fidForPfn( long technology, const std::string& pfn );
117
118 bool attributeOfType( long technology,
119 const std::string& attributeName,
120 void* data,
121 const std::type_info& typeInfo,
122 const std::string& option );
123
124 bool setAttributeOfType( long technology,
125 const std::string& attributeName,
126 const void* data,
127 const std::type_info& typeInfo,
128 const std::string& option );
129
130 void closeSession();
131 StatusCode finalize() override final;
132
133private:
135 MicroSessionManager& microSessionManager( long technology );
136
137 Gaudi::IFileCatalog* m_catalog;
145 std::map< std::string, std::set< std::string > > m_fidToLfns;
146};
147
148#endif
TTypeAdapter RootType
Definition RootType.h:211
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DatabaseHandler is a class taking care of the micro-connections and the micro transactions for a give...
MicroSessionManager is a class taking care of starting sessions for a given major technology and mana...
This class holds all the necessary information to guide the writing of an object in a physical place.
Definition Placement.h:20
std::map< std::string, DatabaseHandler * > m_pfnToDb
Gaudi::IFileCatalog * m_catalog
std::string fidForPfn(long technology, const std::string &pfn)
Fetches the FID by trying to temporatily connect to a database.
std::map< long, std::unique_ptr< MicroSessionManager > > m_technologies
DatabaseHandler * connect(long technology, Io::IoFlag transType, const std::string &fid, const std::string &pfn)
Connects to a database.
DatabaseHandler * lookupByPFN(const std::string &pfn)
Looks up a database by its physical file name.
virtual ~SessionTool()
Destructor.
virtual Io::IoFlag openMode() const
Returns the transaction type.
Definition SessionTool.h:97
SessionTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
void closeSession()
virtual void * readObject(const Token &token, void *object=0)
Retrieves an object from persistent store and return with type information The handle to the reflecti...
virtual Token * registerForWrite(const Placement &place, const void *object, const RootType &type)
registerForWrite registers an object for writing to the persistent medium higher level interactions w...
SessionTool & operator=(const SessionTool &)=delete
bool setAttributeOfType(long technology, const std::string &attributeName, const void *data, const std::type_info &typeInfo, const std::string &option)
std::set< DatabaseHandler * > m_databases
MicroSessionManager & microSessionManager(long technology)
Returns the technology given a technology type.
virtual bool disconnectAll()
Explicitly disconnects all the databases.
virtual bool commit()
Commits the transaction.
bool attributeOfType(long technology, const std::string &attributeName, void *data, const std::type_info &typeInfo, const std::string &option)
SessionTool(const SessionTool &)=delete
StatusCode finalize() override final
virtual Gaudi::IFileCatalog & fileCatalog()
Returns the file catalog in use.
Io::IoFlag m_transactionType
virtual bool startTransaction(Io::IoFlag type=Io::READ)
Starts a new transaction. Returns the success of the operation.
void deregisterDatabaseHandler(DatabaseHandler *dbHandler)
Deregisters a database.
void disconnect(DatabaseHandler *database)
Disconnects from a database.
std::map< std::string, DatabaseHandler * > m_fidToDb
DatabaseHandler * lookupByFID(const std::string &fid)
Looks up a database by its file id.
std::map< std::string, DatabaseHandler * > m_lfnToDb
virtual std::unique_ptr< Database > databaseHandle(const std::string &dbName, Database::Specification::NameType dbNameType)
Creates and returns a new database handle object.
DatabaseHandler * lookupByLFN(const std::string &lfn)
Looks up a database by its logical file name.
void registerDatabaseHandler(DatabaseHandler *dbHandler, const std::string &lfn="")
Registers a database.
virtual void setupFC(Gaudi::IFileCatalog &fileCatalog, int ageLimit=-1)
virtual bool commitAndHold()
Commits and holds the transaction.
std::map< std::string, std::set< std::string > > m_fidToLfns
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition Token.h:22
STL class.
STL class.
STL class.
=============================================================================
STL namespace.
NameType
Enumeration type specifying the database name field, wherever the latter is used in methods accessing...
#define private
Definition testRead.cxx:27