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

Description: More...

#include <src/DbContainerObj.h>

Inheritance diagram for pool::DbContainerObj:
Collaboration diagram for pool::DbContainerObj:

Public Types

typedef DbAccessObj< DbObject *, DbObjectHolderBase
 Type definitions.
typedef std::map< DbObject *, DbObjectHolder * > Keys
typedef Keys::iterator iterator
typedef Keys::const_iterator const_iterator

Public Member Functions

 DbContainerObj (DbDatabase &dbH, const std::string &nam, const DbType &dbtyp, DbAccessMode mod)
 Standard constructor of a container object using the Database handle as a clustering hint.
virtual ~DbContainerObj ()
 Standard destructor.
const IDbContainerinfo () const
 Access to internals.
IDbContainerinfo ()
const DbTypeInfoobjectShape (const Guid &nam)
 Retrieve persistent type information by name.
DbDatabasedatabase ()
 Handle to Database (CONST)
const Tokentoken () const
 Access the token of the container object.
bool isOpen () const
 Flag if container was opened.
bool isReadOnly () const
 Check if database is in read-only mode.
void cancelTransaction ()
 Cancel transaction flag.
uint64_t size ()
 Size of the Database container (=# of objects)
StatusCode open (const DbTypeInfo *typ)
 Open the container.
StatusCode checkAccess ()
 Check if we can access the container.
StatusCode close ()
 Close the container.
StatusCode retire ()
 Retire the container.
StatusCode transAct (Transaction::Action)
 Execute Database Transaction Action.
StatusCode setOption (const DbOption &opt)
 Pass options to the implementation.
StatusCode getOption (DbOption &refOpt)
 Access options.
StatusCode store (const void *object, DbContainer &cntH, ShapeH shape)
 Store object in location.
StatusCode allocate (DbContainer &cntH, const void *object, ShapeH shape, Token::OID_t &oid)
 In place allocation of object location.
StatusCode load (void **ptr, ShapeH shape, const Token::OID_t &linkH, Token::OID_t &oid, bool any_next)
 Select object in the container identified by its handle.
StatusCode next (Token::OID_t &linkH)
 Fetch next object address to set token.
const std::string & name () const
 Access the instance name.
void setName (const std::string &n)
 Access the instance name.
DbAccessMode mode () const
 Access mode.
void setMode (DbAccessMode m)
 Set Access mode.
const DbTypetype () const
const IOODatabasedb () const
 Allow access to the Database implementation.
int refCount () const
 Access reference counter.
int addRef () const
 Add reference count.
int release () const
 Remove reference count.
size_t size () const
 Object size.
void clearEntries ()
 Object cleanup: remove all entries.
const DbObjectHolderfind (const DbObject *&key) const
 Find object by key (CONST)
StatusCode add (const DbObject *&key, DbObjectHolder *val)
 Add entry to container.
StatusCode remove (const DbObjectHolder *val)
 Remove entry from container.
iterator begin ()
iterator end ()
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 Member Functions

bool hasAccess ()
 Check database access.
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

IDbContainerm_info
 Pointer to interface of the technology dependent part.
const Tokenm_tokH
 Container token.
DbDatabase m_dbH
 Handle to hosting Database.
bool m_isOpen
 Flag indication StatusCode of technology dependent container.
std::atomic< int > m_refCount
 Reference counter.
DbAccessMode m_mode
 Access mode.
std::string m_name
 Name of the instance.
DbType m_type
 Database type.
Keys m_keys
 Key entry buffer.
IOODatabasem_pool
 Pointer to specific pool implementation.
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

Description:

Implementation independent part of a container object objects.

There is a ring of protection around the object. The object can only be accessed through its handle, the technology dependent code and the DbDatabaseObj object hosting the container. This should ensure proper reference counting and inhibit non existing references flying around.

Author
M.Frank
Version
1.0

Definition at line 49 of file DbContainerObj.h.

Member Typedef Documentation

◆ Base

Type definitions.

Definition at line 50 of file DbAccessObj.h.

◆ const_iterator

typedef Keys::const_iterator pool::DbAccessObj< DbObject *, DbObjectHolder >::const_iterator
inherited

Definition at line 53 of file DbAccessObj.h.

◆ iterator

typedef Keys::iterator pool::DbAccessObj< DbObject *, DbObjectHolder >::iterator
inherited

Definition at line 52 of file DbAccessObj.h.

◆ Keys

typedef std::map< DbObject *, DbObjectHolder* > pool::DbAccessObj< DbObject *, DbObjectHolder >::Keys
inherited

Definition at line 51 of file DbAccessObj.h.

Constructor & Destructor Documentation

◆ DbContainerObj()

pool::DbContainerObj::DbContainerObj ( DbDatabase & dbH,
const std::string & nam,
const DbType & dbtyp,
DbAccessMode mod )

Standard constructor of a container object using the Database handle as a clustering hint.

Parameters
dbH[IN] Valid handle to database object
nam[IN] Name of the container to be opened.
dbtyp[IN] Database type (including minor type)
mod[IN] Access mode.
Returns
Status code indicating success or failure.

◆ ~DbContainerObj()

virtual pool::DbContainerObj::~DbContainerObj ( )
virtual

Standard destructor.

Member Function Documentation

◆ add()

StatusCode pool::DbAccessObj< DbObject *, DbObjectHolder >::add ( const DbObject * & key,
DbObjectHolder * val )
inlineinherited

Add entry to container.

Definition at line 138 of file DbAccessObj.h.

138 {
140 if ( m_keys.end() == i ) {
141 m_keys.insert(std::make_pair(key, val));
142 val->addRef();
143 return StatusCode::SUCCESS;
144 }
145 return StatusCode::FAILURE;
146 }
Description:
Definition DbAccessObj.h:47
int addRef() const
Add reference count.
Definition DbAccessObj.h:91
const TYPE * find(const KEY &key) const
Find object by key (CONST)

◆ addRef()

int pool::DbAccessObj< DbObject *, DbObjectHolder >::addRef ( ) const
inlineinherited

Add reference count.

Definition at line 91 of file DbAccessObj.h.

91 {
92#ifdef DEBUG_REFCOUNTS
93 std::cout << typeid(*this).name()
94 << " "
95 << m_name
96 << " Refcount:"
97 << m_refCount+1
98 << std::endl;
99#endif
100 return ++m_refCount;
101 }
const std::string & name() const
Access the instance name.
Definition DbAccessObj.h:76

◆ allocate()

StatusCode pool::DbContainerObj::allocate ( DbContainer & cntH,
const void * object,
ShapeH shape,
Token::OID_t & oid )

In place allocation of object location.

◆ begin()

iterator pool::DbAccessObj< DbObject *, DbObjectHolder >::begin ( )
inlineinherited

Definition at line 159 of file DbAccessObj.h.

159{ return m_keys.begin(); }

◆ cancelTransaction()

void pool::DbContainerObj::cancelTransaction ( )
inline

Cancel transaction flag.

Definition at line 92 of file DbContainerObj.h.

92{ }

◆ checkAccess()

StatusCode pool::DbContainerObj::checkAccess ( )

Check if we can access the container.

◆ clearEntries()

void pool::DbAccessObj< DbObject *, DbObjectHolder >::clearEntries ( )
inlineinherited

Object cleanup: remove all entries.

Definition at line 123 of file DbAccessObj.h.

123 {
124 for( auto k : m_keys ) k.second->release();
125 m_keys.clear();
126 }
int release() const
Remove reference count.

◆ close()

StatusCode pool::DbContainerObj::close ( )

Close the container.

◆ database()

DbDatabase & pool::DbContainerObj::database ( )
inline

Handle to Database (CONST)

Definition at line 83 of file DbContainerObj.h.

83{ return m_dbH; }
DbDatabase m_dbH
Handle to hosting Database.

◆ db()

const IOODatabase * pool::DbAccessObj< DbObject *, DbObjectHolder >::db ( ) const
inlineinherited

Allow access to the Database implementation.

Definition at line 86 of file DbAccessObj.h.

86{ return m_pool; }

◆ end()

iterator pool::DbAccessObj< DbObject *, DbObjectHolder >::end ( )
inlineinherited

Definition at line 161 of file DbAccessObj.h.

161{ return m_keys.end(); }

◆ find()

const DbObjectHolder * pool::DbAccessObj< DbObject *, DbObjectHolder >::find ( const DbObject * & key) const
inlineinherited

Find object by key (CONST)

Definition at line 128 of file DbAccessObj.h.

128 {
130 return (m_keys.end() == i) ? 0 : (*i).second;
131 }

◆ getOption()

StatusCode pool::DbContainerObj::getOption ( DbOption & refOpt)

Access options.

◆ hasAccess()

bool pool::DbContainerObj::hasAccess ( )
private

Check database access.

◆ info() [1/2]

IDbContainer * pool::DbContainerObj::info ( )
inline

Definition at line 79 of file DbContainerObj.h.

79{ return m_info; }
IDbContainer * m_info
Pointer to interface of the technology dependent part.

◆ info() [2/2]

const IDbContainer * pool::DbContainerObj::info ( ) const
inline

Access to internals.

Definition at line 78 of file DbContainerObj.h.

78{ return m_info; }

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

◆ isOpen()

bool pool::DbContainerObj::isOpen ( ) const
inline

Flag if container was opened.

Definition at line 87 of file DbContainerObj.h.

87{ return m_isOpen; }
bool m_isOpen
Flag indication StatusCode of technology dependent container.

◆ isReadOnly()

bool pool::DbContainerObj::isReadOnly ( ) const
inline

Check if database is in read-only mode.

Definition at line 89 of file DbContainerObj.h.

◆ load()

StatusCode pool::DbContainerObj::load ( void ** ptr,
ShapeH shape,
const Token::OID_t & linkH,
Token::OID_t & oid,
bool any_next )

Select object in the container identified by its handle.

◆ mode()

DbAccessMode pool::DbAccessObj< DbObject *, DbObjectHolder >::mode ( ) const
inlineinherited

Access mode.

Definition at line 80 of file DbAccessObj.h.

80{ return m_mode; }

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

◆ name()

const std::string & pool::DbAccessObj< DbObject *, DbObjectHolder >::name ( ) const
inlineinherited

Access the instance name.

Definition at line 76 of file DbAccessObj.h.

76{ return m_name; }

◆ next()

StatusCode pool::DbContainerObj::next ( Token::OID_t & linkH)

Fetch next object address to set token.

◆ objectShape()

const DbTypeInfo * pool::DbContainerObj::objectShape ( const Guid & nam)

Retrieve persistent type information by name.

◆ open()

StatusCode pool::DbContainerObj::open ( const DbTypeInfo * typ)

Open the container.

◆ refCount()

int pool::DbAccessObj< DbObject *, DbObjectHolder >::refCount ( ) const
inlineinherited

Access reference counter.

Definition at line 89 of file DbAccessObj.h.

89{ return m_refCount; }

◆ release()

int pool::DbAccessObj< DbObject *, DbObjectHolder >::release ( ) const
inlineinherited

Remove reference count.

Definition at line 103 of file DbAccessObj.h.

103 {
104 int count = --m_refCount;
105#ifdef DEBUG_REFCOUNTS
106 std::cout << typeid(*this).name()
107 << " "
108 << m_name
109 << " Refcount:"
110 << count
111 << std::endl;
112#endif
113 if ( count == 0 ) {
114 delete this;
115 }
116 return count;
117 }

◆ remove()

StatusCode pool::DbAccessObj< DbObject *, DbObjectHolder >::remove ( const DbObjectHolder * val)
inlineinherited

Remove entry from container.

Definition at line 148 of file DbAccessObj.h.

148 {
149 for (iterator j = m_keys.begin(); j != m_keys.end(); ++j ) {
150 if ( (*j).second == val ) {
151 TYPE* p = (*j).second;
152 m_keys.erase(j);
153 p->release();
154 return StatusCode::SUCCESS;
155 }
156 }
157 return StatusCode::FAILURE;
158 }

◆ retire()

StatusCode pool::DbContainerObj::retire ( )

Retire the container.

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

◆ setMode()

void pool::DbAccessObj< DbObject *, DbObjectHolder >::setMode ( DbAccessMode m)
inlineinherited

Set Access mode.

Definition at line 82 of file DbAccessObj.h.

82{ m_mode = m; }

◆ setName()

void pool::DbAccessObj< DbObject *, DbObjectHolder >::setName ( const std::string & n)
inlineinherited

Access the instance name.

Definition at line 78 of file DbAccessObj.h.

78{ m_name = n; }

◆ setOption()

StatusCode pool::DbContainerObj::setOption ( const DbOption & opt)

Pass options to the implementation.

◆ size() [1/2]

size_t pool::DbAccessObj< DbObject *, DbObjectHolder >::size ( ) const
inlineinherited

Object size.

Definition at line 119 of file DbAccessObj.h.

119 {
120 return m_keys.size();
121 }
size_t size() const
Object size.

◆ size() [2/2]

uint64_t pool::DbContainerObj::size ( )

Size of the Database container (=# of objects)

◆ store()

StatusCode pool::DbContainerObj::store ( const void * object,
DbContainer & cntH,
ShapeH shape )

Store object in location.

◆ token()

const Token * pool::DbContainerObj::token ( ) const
inline

Access the token of the container object.

Definition at line 85 of file DbContainerObj.h.

85{ return m_tokH; }
const Token * m_tokH
Container token.

◆ transAct()

StatusCode pool::DbContainerObj::transAct ( Transaction::Action )

Execute Database Transaction Action.

◆ type()

const DbType & pool::DbAccessObj< DbObject *, DbObjectHolder >::type ( ) const
inlineinherited

Definition at line 84 of file DbAccessObj.h.

84{ return m_type; }

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_dbH

DbDatabase pool::DbContainerObj::m_dbH
private

Handle to hosting Database.

Definition at line 56 of file DbContainerObj.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_info

IDbContainer* pool::DbContainerObj::m_info
private

Pointer to interface of the technology dependent part.

Definition at line 52 of file DbContainerObj.h.

◆ m_isOpen

bool pool::DbContainerObj::m_isOpen
private

Flag indication StatusCode of technology dependent container.

Definition at line 58 of file DbContainerObj.h.

◆ m_keys

Keys pool::DbAccessObj< DbObject *, DbObjectHolder >::m_keys
privateinherited

Key entry buffer.

Definition at line 64 of file DbAccessObj.h.

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

DbAccessMode pool::DbAccessObj< DbObject *, DbObjectHolder >::m_mode
privateinherited

Access mode.

Definition at line 58 of file DbAccessObj.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::DbAccessObj< DbObject *, DbObjectHolder >::m_name
privateinherited

Name of the instance.

Definition at line 60 of file DbAccessObj.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_pool

IOODatabase* pool::DbAccessObj< DbObject *, DbObjectHolder >::m_pool
privateinherited

Pointer to specific pool implementation.

Definition at line 66 of file DbAccessObj.h.

◆ m_refCount

std::atomic<int> pool::DbAccessObj< DbObject *, DbObjectHolder >::m_refCount
mutableprivateinherited

Reference counter.

Definition at line 56 of file DbAccessObj.h.

◆ m_tokH

const Token* pool::DbContainerObj::m_tokH
private

Container token.

Definition at line 54 of file DbContainerObj.h.

◆ m_type

DbType pool::DbAccessObj< DbObject *, DbObjectHolder >::m_type
privateinherited

Database type.

Definition at line 62 of file DbAccessObj.h.


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