ATLAS Offline Software
Loading...
Searching...
No Matches
pool::PersistencySvc::UserDatabase Class Reference

UserDatabase is an implementation of the IDatabase interface. More...

#include <UserDatabase.h>

Inheritance diagram for pool::PersistencySvc::UserDatabase:

Public Types

enum  OpenMode { CLOSED , READ , UPDATE }
 Current open mode enumeration. More...

Public Member Functions

 UserDatabase (TechnologyDispatcher &technologyDispatcher, const DatabaseConnectionPolicy &policy, IFileCatalog &fileCatalog, ITransaction &transaction, DatabaseRegistry &registry, const std::string &name, DatabaseSpecification::NameType nameType)
 Constructor.
virtual ~UserDatabase ()
 Destructor.
DatabaseHandlerdatabaseHandler ()
 Returns the database handler.
virtual void connectForRead () override
 Connects explicitly to the database for read operations.
virtual void connectForRead (const DatabaseConnectionPolicy &policy) override
virtual void connectForWrite () override
 Connects explicitly to the database for write/update operations.
virtual void connectForWrite (const DatabaseConnectionPolicy &policy) override
virtual void disconnect () override
 Disconnects from the database.
virtual IDatabase::OpenMode openMode () const override
 Returns the opening mode. It can be used to check whether the database is connected.
virtual const std::string & fid () override
 Returns the file identifier of this database.
virtual const std::string & pfn () override
 Returns the physical file name of this database.
virtual bool setTechnology (long technology) override
 Sets the technology identifier for this database.
virtual long technology () const override
 Returns the technology identifier for this database.
virtual std::vector< std::string > containers () override
 Returns the names of the containers in this database.
virtual IContainercontainerHandle (const std::string &name) override
 Returns a pointer to a container object. The user acquires ownership of that object.
virtual const ITechnologySpecificAttributestechnologySpecificAttributes () const override
 Returns the object holding the technology specific attributes.
virtual ITechnologySpecificAttributestechnologySpecificAttributes () override
template<class T>
attribute (const std::string &attributeName, const std::string &option="")
 Templated method to retrieve an attribute.
template<class T>
bool setAttribute (const std::string &attributeName, const T &atttibuteValue, const std::string &option="")
 Templated method to set an attribute.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Protected Member Functions

virtual bool attributeOfType (const std::string &attributeName, void *data, const std::type_info &typeInfo, const std::string &option) override
 The actual method returning the attribute data given a name.
virtual bool setAttributeOfType (const std::string &attributeName, const void *data, const std::type_info &typeInfo, const std::string &option) override
 The actual method setting the attribute data given a name.

Private Member Functions

bool checkInRegistry ()
 Checks in the registry if the database handler already exists.
void setTechnologyIdentifier (const std::string &sTechnology)
 Converts a technology string to the technology (long) identifier.
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

TechnologyDispatcherm_technologyDispatcher
 Reference to the technology dispatcher.
const DatabaseConnectionPolicym_policy
 Reference to the policy.
IFileCatalogm_catalog
 Reference to the file catalog.
ITransactionm_transaction
 Reference to the global transaction.
DatabaseRegistrym_registry
 Reference to the database registry.
std::string m_name
 The database name.
DatabaseSpecification::NameType m_nameType
 The database name spacification.
long m_technology
 The technology identifier of the database.
bool m_technologySet
 Checks if the technology identifier has been set.
DatabaseHandlerm_databaseHandler
 The underlying database handler.
IDatabase::OpenMode m_openMode
 Current open mode.
bool m_alreadyConnected
 Flag indicating whether a connection has been already made once.
std::string m_the_fid
 Other names used.
std::string m_the_pfn
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

UserDatabase is an implementation of the IDatabase interface.

Definition at line 32 of file UserDatabase.h.

Member Enumeration Documentation

◆ OpenMode

enum pool::IDatabase::OpenMode
inherited

Current open mode enumeration.

Enumerator
CLOSED 
READ 
UPDATE 

Definition at line 28 of file IDatabase.h.

28 { CLOSED,
29 READ,
OpenMode
Current open mode enumeration.
Definition IDatabase.h:28

Constructor & Destructor Documentation

◆ UserDatabase()

pool::PersistencySvc::UserDatabase::UserDatabase ( TechnologyDispatcher & technologyDispatcher,
const DatabaseConnectionPolicy & policy,
IFileCatalog & fileCatalog,
ITransaction & transaction,
DatabaseRegistry & registry,
const std::string & name,
DatabaseSpecification::NameType nameType )

Constructor.

◆ ~UserDatabase()

virtual pool::PersistencySvc::UserDatabase::~UserDatabase ( )
virtual

Destructor.

Member Function Documentation

◆ attribute()

template<class T>
T pool::ITechnologySpecificAttributes::attribute ( const std::string & attributeName,
const std::string & option = "" )
inlineinherited

Templated method to retrieve an attribute.

Definition at line 25 of file ITechnologySpecificAttributes.h.

26 {
27 T data;
28 const std::type_info& typeInfo = typeid(T);
29 if ( ! this->attributeOfType( attributeName,
30 static_cast< void* >( &data ),
31 typeInfo,
32 option ) ) {
33 std::ostringstream error;
34 error << "Failed to retrieve attribute " << attributeName << " of type " << typeInfo.name();
35 throw std::runtime_error( error.str() + " (APR: \" ITechnologySpecificAttributes \" from \" PersistencySvc \")");
36 }
37 return data;
38 }
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual bool attributeOfType(const std::string &attributeName, void *data, const std::type_info &typeInfo, const std::string &option)=0
The actual method returning the attribute data given a name.
unsigned long long T

◆ attributeOfType()

virtual bool pool::PersistencySvc::UserDatabase::attributeOfType ( const std::string & attributeName,
void * data,
const std::type_info & typeInfo,
const std::string & option )
overrideprotectedvirtual

The actual method returning the attribute data given a name.

Implements pool::ITechnologySpecificAttributes.

◆ checkInRegistry()

bool pool::PersistencySvc::UserDatabase::checkInRegistry ( )
private

Checks in the registry if the database handler already exists.

◆ connectForRead() [1/2]

virtual void pool::PersistencySvc::UserDatabase::connectForRead ( )
overridevirtual

Connects explicitly to the database for read operations.

Implements pool::IDatabase.

◆ connectForRead() [2/2]

virtual void pool::PersistencySvc::UserDatabase::connectForRead ( const DatabaseConnectionPolicy & policy)
overridevirtual

Implements pool::IDatabase.

◆ connectForWrite() [1/2]

virtual void pool::PersistencySvc::UserDatabase::connectForWrite ( )
overridevirtual

Connects explicitly to the database for write/update operations.

Implements pool::IDatabase.

◆ connectForWrite() [2/2]

virtual void pool::PersistencySvc::UserDatabase::connectForWrite ( const DatabaseConnectionPolicy & policy)
overridevirtual

Implements pool::IDatabase.

◆ containerHandle()

virtual IContainer * pool::PersistencySvc::UserDatabase::containerHandle ( const std::string & name)
overridevirtual

Returns a pointer to a container object. The user acquires ownership of that object.

Implements pool::IDatabase.

◆ containers()

virtual std::vector< std::string > pool::PersistencySvc::UserDatabase::containers ( )
overridevirtual

Returns the names of the containers in this database.

Implements pool::IDatabase.

◆ databaseHandler()

DatabaseHandler & pool::PersistencySvc::UserDatabase::databaseHandler ( )

Returns the database handler.

◆ disconnect()

virtual void pool::PersistencySvc::UserDatabase::disconnect ( )
overridevirtual

Disconnects from the database.

Implements pool::IDatabase.

◆ fid()

virtual const std::string & pool::PersistencySvc::UserDatabase::fid ( )
overridevirtual

Returns the file identifier of this database.

Implements pool::IDatabase.

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ openMode()

virtual IDatabase::OpenMode pool::PersistencySvc::UserDatabase::openMode ( ) const
overridevirtual

Returns the opening mode. It can be used to check whether the database is connected.

Implements pool::IDatabase.

◆ pfn()

virtual const std::string & pool::PersistencySvc::UserDatabase::pfn ( )
overridevirtual

Returns the physical file name of this database.

Implements pool::IDatabase.

◆ setAttribute()

template<class T>
bool pool::ITechnologySpecificAttributes::setAttribute ( const std::string & attributeName,
const T & atttibuteValue,
const std::string & option = "" )
inlineinherited

Templated method to set an attribute.

Definition at line 41 of file ITechnologySpecificAttributes.h.

43 {
44 return this->setAttributeOfType( attributeName,
45 static_cast< const void* >( &atttibuteValue ),
46 typeid(T),
47 option );
48 }
virtual bool setAttributeOfType(const std::string &attributeName, const void *data, const std::type_info &typeInfo, const std::string &option)=0
The actual method setting the attribute data given a name.

◆ setAttributeOfType()

virtual bool pool::PersistencySvc::UserDatabase::setAttributeOfType ( const std::string & attributeName,
const void * data,
const std::type_info & typeInfo,
const std::string & option )
overrideprotectedvirtual

The actual method setting the attribute data given a name.

Implements pool::ITechnologySpecificAttributes.

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setTechnology()

virtual bool pool::PersistencySvc::UserDatabase::setTechnology ( long technology)
overridevirtual

Sets the technology identifier for this database.

This can only be called for newly created databases before the connect method is called. Otherwise false is returned.

Implements pool::IDatabase.

◆ setTechnologyIdentifier()

void pool::PersistencySvc::UserDatabase::setTechnologyIdentifier ( const std::string & sTechnology)
private

Converts a technology string to the technology (long) identifier.

◆ technology()

virtual long pool::PersistencySvc::UserDatabase::technology ( ) const
overridevirtual

Returns the technology identifier for this database.

Implements pool::IDatabase.

◆ technologySpecificAttributes() [1/2]

virtual const ITechnologySpecificAttributes & pool::PersistencySvc::UserDatabase::technologySpecificAttributes ( ) const
overridevirtual

Returns the object holding the technology specific attributes.

Implements pool::IDatabase.

◆ technologySpecificAttributes() [2/2]

virtual ITechnologySpecificAttributes & pool::PersistencySvc::UserDatabase::technologySpecificAttributes ( )
overridevirtual

Implements pool::IDatabase.

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_alreadyConnected

bool pool::PersistencySvc::UserDatabase::m_alreadyConnected
private

Flag indicating whether a connection has been already made once.

Definition at line 127 of file UserDatabase.h.

◆ m_catalog

IFileCatalog& pool::PersistencySvc::UserDatabase::m_catalog
private

Reference to the file catalog.

Definition at line 109 of file UserDatabase.h.

◆ m_databaseHandler

DatabaseHandler* pool::PersistencySvc::UserDatabase::m_databaseHandler
private

The underlying database handler.

Definition at line 123 of file UserDatabase.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_name

std::string pool::PersistencySvc::UserDatabase::m_name
private

The database name.

Definition at line 115 of file UserDatabase.h.

◆ m_nameType

DatabaseSpecification::NameType pool::PersistencySvc::UserDatabase::m_nameType
private

The database name spacification.

Definition at line 117 of file UserDatabase.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_openMode

IDatabase::OpenMode pool::PersistencySvc::UserDatabase::m_openMode
private

Current open mode.

Definition at line 125 of file UserDatabase.h.

◆ m_policy

const DatabaseConnectionPolicy& pool::PersistencySvc::UserDatabase::m_policy
private

Reference to the policy.

Definition at line 107 of file UserDatabase.h.

◆ m_registry

DatabaseRegistry& pool::PersistencySvc::UserDatabase::m_registry
private

Reference to the database registry.

Definition at line 113 of file UserDatabase.h.

◆ m_technology

long pool::PersistencySvc::UserDatabase::m_technology
private

The technology identifier of the database.

Definition at line 119 of file UserDatabase.h.

◆ m_technologyDispatcher

TechnologyDispatcher& pool::PersistencySvc::UserDatabase::m_technologyDispatcher
private

Reference to the technology dispatcher.

Definition at line 105 of file UserDatabase.h.

◆ m_technologySet

bool pool::PersistencySvc::UserDatabase::m_technologySet
private

Checks if the technology identifier has been set.

Definition at line 121 of file UserDatabase.h.

◆ m_the_fid

std::string pool::PersistencySvc::UserDatabase::m_the_fid
private

Other names used.

Definition at line 129 of file UserDatabase.h.

◆ m_the_pfn

std::string pool::PersistencySvc::UserDatabase::m_the_pfn
private

Definition at line 130 of file UserDatabase.h.

◆ m_transaction

ITransaction& pool::PersistencySvc::UserDatabase::m_transaction
private

Reference to the global transaction.

Definition at line 111 of file UserDatabase.h.


The documentation for this class was generated from the following file: