ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
pool::PersistencySvc::UserDatabase Class Reference

#include <UserDatabase.h>

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

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. More...
 
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. More...
 

Private Member Functions

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

Private Attributes

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

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,
30  UPDATE } OpenMode;

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  }

◆ 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 }

◆ 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 }

◆ 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; }

◆ 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  }

◆ 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.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
pool::IDatabase::OpenMode
OpenMode
Current open mode enumeration.
Definition: IDatabase.h:28
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
pool::ITechnologySpecificAttributes::setAttributeOfType
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.
pool::ITechnologySpecificAttributes::attributeOfType
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.
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
pool::IDatabase::CLOSED
@ CLOSED
Definition: IDatabase.h:28
pool::IDatabase::READ
@ READ
Definition: IDatabase.h:29
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:163
pool::IDatabase::UPDATE
@ UPDATE
Definition: IDatabase.h:30
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
get_generator_info.error
error
Definition: get_generator_info.py:40
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
error
Definition: IImpactPoint3dEstimator.h:70
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
python.SystemOfUnits.ms
float ms
Definition: SystemOfUnits.py:148