20 const std::string& name,
55 throw std::runtime_error(
"PFN \"" +
m_name +
"\" is not existing (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
61 throw std::runtime_error(
"FID \"" +
m_name +
"\" is not existing in the catalog (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
68 throw std::runtime_error(
"LFN \"" +
m_name +
"\" is not existing in the catalog (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
76 throw std::runtime_error(
"Unknown database name type (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
90 throw std::runtime_error(
"Could not connect to the file (APR: \" Database::connectForRead \" from \" PersistencySvc \")" );
101 throw std::runtime_error(
"Could not open a database for read object. (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
112 throw std::runtime_error(
"Could not open a database for write outside an update transaction. (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
117 throw std::runtime_error(
"Could not open a database for write that is already connected for read. (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
121 bool dbRegistered =
false;
128 throw std::runtime_error(
"The back end technology has not been specified (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
141 throw std::runtime_error(
"Could not find the FID \"" +
m_name +
"\" in the file catalog (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
148 throw std::runtime_error(
"Could not find the LFN \"" +
m_name +
"\" in the file catalog (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
156 throw std::runtime_error(
"Unknown database name type (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
165 throw std::runtime_error(
"Could not connect to the file (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
176 long minorTechnology,
181 throw std::runtime_error(
"Could not open a database for write object. (APR: \" Database::connectForWrite \" from \" PersistencySvc \")" );
213 std::string technology;
217 if( technology.empty() ) {
219 ATH_MSG_DEBUG(
"Retrying 'connect' using assumed PFN " <<
m_name <<
" as LFN (no tech found in PFC)" );
236 std::string
pfn, tech;
240 <<
"' (GUID " <<
m_the_fid <<
") - this is not supported and may even lead to a crash!" );
278 std::string technology;
303std::vector< std::string >
340 throw std::runtime_error(
"Only PFN, LFN and FID database types are currently supported (APR: \" Database::checkInRegistry \" from \" PersistencySvc \")" );
364 const std::type_info& typeInfo,
365 const std::string& option )
368 else return m_databaseHandler->attribute( attributeName, data, typeInfo, option );
375 const std::type_info& typeInfo,
376 const std::string& option )
379 else return m_databaseHandler->setAttribute( attributeName, data, typeInfo, option );
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
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.
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.
DatabaseRegistry & m_registry
Reference to the database registry.
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.
pool::FileDescriptor * fileDescriptor()
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.
This class provides a token that identifies in a unique way objects on the persistent storage.
const std::string storageName() const
Human readable storage type.
int majorType() const
Access to major type.
static DbType getType(const std::string &name)
Access known storage type object by name.
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...