18 const std::string& name,
45 throw std::runtime_error(
"PFN \"" +
m_name +
"\" is not existing (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
50 throw std::runtime_error(
"FID \"" +
m_name +
"\" is not existing in the catalog (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
57 throw std::runtime_error(
"LFN \"" +
m_name +
"\" is not existing in the catalog (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
65 throw std::runtime_error(
"Unknown database name type (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
79 throw std::runtime_error(
"Could not connect to the file (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
87 throw std::runtime_error(
"Could not open a database for read object. (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
95 throw std::runtime_error(
"Could not open a database for write outside an update transaction. (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
100 throw std::runtime_error(
"Could not open a database for write that is already connected for read. (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
103 bool dbRegistered =
false;
110 throw std::runtime_error(
"The back end technology has not been specified (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
123 throw std::runtime_error(
"Could not find the FID \"" +
m_name +
"\" in the file catalog (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
130 throw std::runtime_error(
"Could not find the LFN \"" +
m_name +
"\" in the file catalog (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
138 throw std::runtime_error(
"Unknown database name type (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
147 throw std::runtime_error(
"Could not connect to the file (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
156 long minorTechnology,
160 throw std::runtime_error(
"Could not open a database for write object. (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
183 std::string technology;
187 if( technology.empty() ) {
189 ATH_MSG_DEBUG(
"Retrying 'connect' using assumed PFN " <<
m_name <<
" as LFN (no tech found in PFC)" );
206 std::string
pfn, tech;
210 <<
"' (GUID " <<
m_the_fid <<
") - this is not supported and may even lead to a crash!" );
245 std::string technology;
260 DbType dbType( technology );
296 throw std::runtime_error(
"Only PFN, LFN and FID database types are currently supported (APR: \" Database::checkInRegistry \" from \" PersistencySvc \")" );
316 const std::type_info& typeInfo,
317 const std::string& option ) {
319 else return m_databaseHandler->attribute( attributeName, data, typeInfo, option );
324 const std::type_info& typeInfo,
325 const std::string& option ) {
327 else return m_databaseHandler->setAttribute( attributeName, data, typeInfo, option );
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
static const long long int INVALID
static const std::string & emptyString
static const Attributes_t empty
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Container * containerHandle(const std::string &name)
Returns a pointer to a container object. The user acquires ownership of that object.
Specification::NameType m_nameType
The database name spacification.
long m_technology
The technology identifier of the database.
Io::IoFlag m_openMode
Current open mode.
bool checkInRegistry()
Checks in the registry if the database handler already exists.
void disconnect()
Disconnects from the database.
Io::IoFlag openMode() const
Returns the opening mode. It can be used to check whether the database is connected.
void connectForRead()
Connects explicitly to the database for read operations.
bool setAttributeOfType(const std::string &attributeName, const void *data, const std::type_info &typeInfo, const std::string &option)
Database(SessionTool &session, const std::string &name, const Specification::NameType nameType)
Constructor.
const std::string & fid()
Returns the file identifier of this database.
const std::string & pfn()
Returns the physical file name of this database.
std::vector< std::string > containers()
Returns the names of the containers in this database.
FileDescriptor * fileDescriptor()
std::string m_name
The database name.
bool setTechnology(long technology)
Sets the technology identifier for this database.
SessionTool & m_session
Reference to the session.
void connectForWrite()
Connects explicitly to the database for write/update operations.
void * readObject(const Token &token, void *object=0)
Reads an object given a token.
std::string m_the_fid
Other names used.
bool attributeOfType(const std::string &attributeName, void *data, const std::type_info &typeInfo, const std::string &option)
DatabaseHandler * m_databaseHandler
The underlying database handler.
bool m_alreadyConnected
Flag indicating whether a connection has been already made once.
Token * writeObject(const std::string &containerName, long minorTechnology, const void *object, const RootType &type)
Writes an object and returns a token.
Io::IoFlag m_transactionType
Transaction type (read/update).
Gaudi::IFileCatalog & m_catalog
Reference to the file catalog.
bool m_technologySet
Checks if the technology identifier has been set.
Keeps information about storage technology.
static DbType getType(const std::string &name)
Access known storage type object by name.
int majorType() const
Access to major type.
const std::string storageName() const
Human readable storage type.
This class provides a token that identifies in a unique way objects on the persistent storage.
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.
void lookupFileByPFN(const Gaudi::IFileCatalog &fc, const std::string &pfn, std::string &fid, std::string &tech)
Get FID and filetype for a given PFN.
void getFirstPFN(const Gaudi::IFileCatalog &fc, const std::string &fid, std::string &pfn, std::string &tech)
Get the first PFN + filetype for the given FID.
static const DbType ROOT_StorageType
NameType
Enumeration type specifying the database name field, wherever the latter is used in methods accessing...