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

The DbStorageSvc class is able to handle user request for. More...

#include <POOLCore/DbStorageSvc.h>

Inheritance diagram for pool::DbStorageSvc:
Collaboration diagram for pool::DbStorageSvc:

Public Member Functions

 DbStorageSvc ()
 Standard Constructor: Constructs an object of type DbStorageSvc.
 DbStorageSvc (const std::string &name)
 Initializing Constructor: Constructs an object of type DbStorageSvc.
virtual ~DbStorageSvc ()
 Standard destructor.
 DbStorageSvc (const DbStorageSvc &)=delete
DbStorageSvcoperator= (const DbStorageSvc &)=delete
virtual unsigned int addRef () override final
 IInterface implementation: Reference Interface instance.
virtual unsigned int release () override final
 IInterface implementation: Release Interface instance.
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.

Private Types

typedef std::vector< const Token * > TokenVec

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::string m_name
 Service Name.
unsigned int m_refCount
 Reference counter.
DbDomain m_domH
 Database domain handle.
int m_ageLimit
 Property: AgeLimit indicating the maximal allowed age of files.
DbType m_type
 Technology type.
IOODatabasem_implementation
 Loaded StorageSvc implementation type (for m_type)
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)

IService interface

virtual StatusCode initialize ()
 IService implementation override: Initilize Service.
virtual StatusCode finalize ()
 IService implementation override: Finalize Service.
virtual const std::string & name () const
 IService implementation: Retrieve name of the service.
virtual StatusCode allocate (FileDescriptor &refDB, const std::string &refCont, int technology, const void *object, ShapeH shapeH, Token *&refpTok) override final
 Register object for write.
virtual StatusCode read (const FileDescriptor &refDB, const Token &persToken, ShapeH shapeH, void **object) override final
 Read a persistent object from the medium.
virtual std::string getContName (FileDescriptor &refDB, Token &persToken) override final
 Get container name for object.
virtual StatusCode getShape (FileDescriptor &refDB, const Guid &objType, ShapeH &shapeH) override final
 Retrieve persistent shape from Storage manager.
virtual ShapeH createShape (const Guid &shapeID) override final
 Create a Shape representation based on a ShapeID.
virtual StatusCode startSession (int mode, int tech) override final
 Start a new Database Session.
virtual StatusCode endSession () override final
 End the Database session.
virtual StatusCode existsConnection (const FileDescriptor &refDB) override final
 Check the existence of a logical Database unit.
virtual StatusCode connect (int mode, FileDescriptor &refDB) override final
 Connect to a logical Database unit.
virtual StatusCode disconnect (FileDescriptor &refDB) override final
 Disconnect from a logical Database unit.
virtual StatusCode openMode (FileDescriptor &refDB, int &mode) override final
 Query the access mode of a Database unit.
virtual StatusCode endTransaction (ConnectionH conn, Transaction::Action typ) override final
 End/Finish an existing Transaction sequence.
virtual StatusCode getDomainOption (DbOption &opt) override final
 Access options for a given database domain.
virtual StatusCode setDomainOption (const DbOption &opt) override final
 Set options for a given database domain.
IOODatabasedb ()
 Access technology implementations.

Detailed Description

The DbStorageSvc class is able to handle user request for.

  • transient objects to become persistent and
  • persistent objects to be made transient. What the storage manager however needs to perform this task are object mappings, which translate between the two representations.

This functionality is defined in the IDbStorageSvc interface and implemented in the DbStorageSvc class. Please refer to the header file POOLCore/IDbStorageSvc for further details.

Author
Markus Frank
Version
1.0

Definition at line 37 of file DbStorageSvc.h.

Member Typedef Documentation

◆ TokenVec

typedef std::vector<const Token*> pool::DbStorageSvc::TokenVec
private

Definition at line 39 of file DbStorageSvc.h.

Constructor & Destructor Documentation

◆ DbStorageSvc() [1/3]

pool::DbStorageSvc::DbStorageSvc ( )

Standard Constructor: Constructs an object of type DbStorageSvc.

◆ DbStorageSvc() [2/3]

pool::DbStorageSvc::DbStorageSvc ( const std::string & name)
explicit

Initializing Constructor: Constructs an object of type DbStorageSvc.

◆ ~DbStorageSvc()

virtual pool::DbStorageSvc::~DbStorageSvc ( )
virtual

Standard destructor.

◆ DbStorageSvc() [3/3]

pool::DbStorageSvc::DbStorageSvc ( const DbStorageSvc & )
delete

Member Function Documentation

◆ addRef()

virtual unsigned int pool::DbStorageSvc::addRef ( )
finaloverridevirtual

IInterface implementation: Reference Interface instance.

Implements pool::IStorageSvc.

◆ allocate()

virtual StatusCode pool::DbStorageSvc::allocate ( FileDescriptor & refDB,
const std::string & refCont,
int technology,
const void * object,
ShapeH shapeH,
Token *& refpTok )
finaloverridevirtual

Register object for write.

Parameters
refDB[IN] Reference to Database descriptor
refCont[IN] Reference to container name
technology[IN]Specialised sub-technology
object[IN] Pointer to persistent data object.
shapeH[IN] Handle to persistent type information
refpTok[OUT] Reference to location for storing the pointer of the persistent object token.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

◆ connect()

virtual StatusCode pool::DbStorageSvc::connect ( int mode,
FileDescriptor & refDB )
finaloverridevirtual

Connect to a logical Database unit.

A connection is equivalent to the triple (OCISession, OCIServer, OCISvcCtx) in ORACLE, a login to a datasource using ODBC, or a single federation for Objectivity. For file based technologies, such as root, MS Access, ODBC/Text etc., this is involves the opening of the requested file.

Parameters
mode[IN] Flag to indicate the accessmode of the session. READ, NEW/CREATE/WRITE, UPDATE, RECREATE.
refDB[I/O] Descriptor of the Database to be opened. On successful return the Database handle is valid.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

◆ createShape()

virtual ShapeH pool::DbStorageSvc::createShape ( const Guid & shapeID)
finaloverridevirtual

Create a Shape representation based on a ShapeID.

Parameters
shapeID[IN] Shape identifier.
Returns
Handle to persistent mapping of a given object type.

Implements pool::IStorageSvc.

◆ db()

IOODatabase * pool::DbStorageSvc::db ( )
private

Access technology implementations.

◆ disconnect()

virtual StatusCode pool::DbStorageSvc::disconnect ( FileDescriptor & refDB)
finaloverridevirtual

Disconnect from a logical Database unit.

The request for disconnect requires, that all pending Transactions are already commited. Otherwise data are lost. On disconnection the access to the Database is finalized, closed. The token will be invalidated may not be used at any longer after disconnection.

Parameters
refDB[IN] Descriptor of the Database access. This handle was retrieved when connecting to the logical Database. On successful return the Database handle will be invalidated.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

◆ endSession()

virtual StatusCode pool::DbStorageSvc::endSession ( )
inlinefinaloverridevirtual

End the Database session.

The request to end a Database session requires, that all pending Transactions and connections are closed. Otherwise internally the close will be forced and potentially data on pending Transactions will be lost.

Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

Definition at line 177 of file DbStorageSvc.h.

178 { return m_domH.close(); }
DbDomain m_domH
Database domain handle.

◆ endTransaction()

virtual StatusCode pool::DbStorageSvc::endTransaction ( ConnectionH conn,
Transaction::Action typ )
finaloverridevirtual

End/Finish an existing Transaction sequence.

At this phase all objects, which were marked for write when the Transaction was started, are either going to be made persistent or scratched. After the Transaction ended, the Transaction context is invalidated and may no longer be used independent wether the Transaction was successful or not.

Parameters
conn[IN] DB connection
typ[IN] Enum indicating an action to be performed. Valid arguments are COMMIT
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

◆ existsConnection()

virtual StatusCode pool::DbStorageSvc::existsConnection ( const FileDescriptor & refDB)
finaloverridevirtual

Check the existence of a logical Database unit.

Parameters
refDB[I/O] Descriptor of the Database to be opened. On successful return the Database handle is valid.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

◆ finalize()

virtual StatusCode pool::DbStorageSvc::finalize ( )
virtual

IService implementation override: Finalize Service.

◆ getContName()

virtual std::string pool::DbStorageSvc::getContName ( FileDescriptor & refDB,
Token & persToken )
finaloverridevirtual

Get container name for object.

Parameters
refDB[IN] Reference to Database descriptor
pToken[IN] Token to the persistent object.
Returns
std::string container name.

Implements pool::IStorageSvc.

◆ getDomainOption()

virtual StatusCode pool::DbStorageSvc::getDomainOption ( DbOption & opt)
inlinefinaloverridevirtual

Access options for a given database domain.

Domain options are global options, which refer to the database technology and not to a particular connection.

Note: The options depend on the underlying implementation and are not normalized.

Parameters
opt[IN] Reference to option object.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

Definition at line 261 of file DbStorageSvc.h.

262 { return m_domH.getOption(opt); }

◆ getShape()

virtual StatusCode pool::DbStorageSvc::getShape ( FileDescriptor & refDB,
const Guid & objType,
ShapeH & shapeH )
finaloverridevirtual

Retrieve persistent shape from Storage manager.

The persistent shape is saved at write time to a Database. To match the transient shape of an object to the persistent shape of the data at the time the data were written should allow for schema evolution and object transformation(s).

Parameters
refDB[IN] Reference to Database descriptor
objType[IN] Shape identifier.
shapeH[OUT] Handle to persistent mapping of a given object type.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

◆ initialize()

virtual StatusCode pool::DbStorageSvc::initialize ( )
virtual

IService implementation override: Initilize Service.

◆ 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 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
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 182 of file AthMessaging.h.

183{ 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 user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ name()

virtual const std::string & pool::DbStorageSvc::name ( ) const
inlinevirtual

IService implementation: Retrieve name of the service.

Definition at line 83 of file DbStorageSvc.h.

83{ return m_name; }
std::string m_name
Service Name.

◆ openMode()

virtual StatusCode pool::DbStorageSvc::openMode ( FileDescriptor & refDB,
int & mode )
finaloverridevirtual

Query the access mode of a Database unit.

Parameters
refDB[IN] Descriptor of the Database to be queried.
mode[OUT] Open mod to the database.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

◆ operator=()

DbStorageSvc & pool::DbStorageSvc::operator= ( const DbStorageSvc & )
delete

◆ read()

virtual StatusCode pool::DbStorageSvc::read ( const FileDescriptor & refDB,
const Token & persToken,
ShapeH shapeH,
void ** object )
finaloverridevirtual

Read a persistent object from the medium.

Reading an object does not create the object.

Parameters
refDB[IN] Reference to Database descriptor
persToken[IN] Reference to persistent token information.
object[OUT] Pointer to persistent data pointer.
shapeH[IN] Desired object shape to be read
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

◆ release()

virtual unsigned int pool::DbStorageSvc::release ( )
finaloverridevirtual

IInterface implementation: Release Interface instance.

Implements pool::IStorageSvc.

◆ setDomainOption()

virtual StatusCode pool::DbStorageSvc::setDomainOption ( const DbOption & opt)
inlinefinaloverridevirtual

Set options for a given database domain.

Domain options are global options, which refer to the database technology and not to a particular connection.

Note: The options depend on the underlying implementation and are not normalized.

Parameters
opt[IN] Reference to option object.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

Definition at line 275 of file DbStorageSvc.h.

276 { return m_domH.setOption(opt); }

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

◆ startSession()

virtual StatusCode pool::DbStorageSvc::startSession ( int mode,
int tech )
finaloverridevirtual

Start a new Database Session.

The Database session handles Databases of one given type. This involves specific handling of a given domain represented by a technology type. All subsequent actions involving Database actions will re-use this technology identifier. The session is a purely logical concept, which typically cannot fail unless the underlying technology requires global initialization calls.

Parameters
mode[IN] Flag to indicate the accessmode of the session. READ, NEW/CREATE/WRITE, UPDATE, RECREATE
tech[IN] Flag indicating the technology type of the Database the user wants to connect to.
Returns
StatusCode code indicating success or failure.

Implements pool::IStorageSvc.

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_ageLimit

int pool::DbStorageSvc::m_ageLimit
private

Property: AgeLimit indicating the maximal allowed age of files.

Definition at line 48 of file DbStorageSvc.h.

◆ m_domH

DbDomain pool::DbStorageSvc::m_domH
private

Database domain handle.

Definition at line 46 of file DbStorageSvc.h.

◆ m_implementation

IOODatabase* pool::DbStorageSvc::m_implementation
private

Loaded StorageSvc implementation type (for m_type)

Definition at line 52 of file DbStorageSvc.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::DbStorageSvc::m_name
private

Service Name.

Definition at line 42 of file DbStorageSvc.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_refCount

unsigned int pool::DbStorageSvc::m_refCount
private

Reference counter.

Definition at line 44 of file DbStorageSvc.h.

◆ m_type

DbType pool::DbStorageSvc::m_type
private

Technology type.

Definition at line 50 of file DbStorageSvc.h.


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