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

Description: More...

#include <src/DbContainerObj.h>

Inheritance diagram for DbContainerObj:
Collaboration diagram for DbContainerObj:

Public Member Functions

 DbContainerObj (DbDatabase &dbH, const std::string &nam, const DbType &dbtyp, Io::IoFlag mod)
 Standard constructor of a container object using the Database handle as a clustering hint.
virtual ~DbContainerObj ()
 Standard destructor.
const ITechContainer * info () const
 Access to internals.
ITechContainer * info ()
const DbTypeInfo * objectShape (const Guid &nam)
 Retrieve persistent type information by name.
DbDatabase & database ()
 Handle to Database (CONST).
const Token * token () 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, const DbTypeInfo *tinfo)
 Store object in location.
StatusCode allocate (DbContainer &cntH, const void *object, const DbTypeInfo *tinfo, Token::OID_t &oid)
 In place allocation of object location.
StatusCode load (void **ptr, const DbTypeInfo *tinfo, 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.
Io::IoFlag mode () const
 Access mode.
void setMode (Io::IoFlag m)
 Set Access mode.
const DbType & type () const
const ITechFactory * techFactory () const
 Allow access to the Database implementation.
ITechFactory * techFactory ()
int refCount () const
 Access reference counter.
int addRef () const
 Add reference count.
int release () const
 Remove reference count.
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

ITechContainer * m_info
 Pointer to interface of the technology dependent part.
const Token * m_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.
Io::IoFlag m_mode
 Access mode.
std::string m_name
 Name of the instance.
DbType m_type
 Database type.
ITechFactory * m_factory
 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

Definition at line 29 of file DbContainerObj.h.

Constructor & Destructor Documentation

◆ DbContainerObj()

DbContainerObj::DbContainerObj ( DbDatabase & dbH,
const std::string & nam,
const DbType & dbtyp,
Io::IoFlag 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 DbContainerObj::~DbContainerObj ( )
virtual

Standard destructor.

Member Function Documentation

◆ addRef()

int DbAccessObjBase::addRef ( ) const
inlineinherited

Add reference count.

Definition at line 66 of file DbAccessObj.h.

66 {
67#ifdef DEBUG_REFCOUNTS
68 std::cout << typeid(*this).name()
69 << " "
70 << m_name
71 << " Refcount:"
72 << m_refCount+1
73 << std::endl;
74#endif
75 return ++m_refCount;
76 }
std::string m_name
Name of the instance.
Definition DbAccessObj.h:37
std::atomic< int > m_refCount
Reference counter.
Definition DbAccessObj.h:33

◆ allocate()

StatusCode DbContainerObj::allocate ( DbContainer & cntH,
const void * object,
const DbTypeInfo * tinfo,
Token::OID_t & oid )

In place allocation of object location.

◆ cancelTransaction()

void DbContainerObj::cancelTransaction ( )
inline

Cancel transaction flag.

Definition at line 72 of file DbContainerObj.h.

72{ }

◆ checkAccess()

StatusCode DbContainerObj::checkAccess ( )

Check if we can access the container.

◆ close()

StatusCode DbContainerObj::close ( )

Close the container.

◆ database()

DbDatabase & DbContainerObj::database ( )
inline

Handle to Database (CONST).

Definition at line 63 of file DbContainerObj.h.

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

◆ getOption()

StatusCode DbContainerObj::getOption ( DbOption & refOpt)

Access options.

◆ hasAccess()

bool DbContainerObj::hasAccess ( )
private

Check database access.

◆ info() [1/2]

ITechContainer * DbContainerObj::info ( )
inline

Definition at line 59 of file DbContainerObj.h.

59{ return m_info; }
ITechContainer * m_info
Pointer to interface of the technology dependent part.

◆ info() [2/2]

const ITechContainer * DbContainerObj::info ( ) const
inline

Access to internals.

Definition at line 58 of file DbContainerObj.h.

58{ 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)
int outputLevel(const IMessageSvc *ims, const std::string &source)

◆ isOpen()

bool DbContainerObj::isOpen ( ) const
inline

Flag if container was opened.

Definition at line 67 of file DbContainerObj.h.

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

◆ isReadOnly()

bool DbContainerObj::isReadOnly ( ) const
inline

Check if database is in read-only mode.

Definition at line 69 of file DbContainerObj.h.

70 { return !(mode() == Io::WRITE || mode() == Io::APPEND); }
Io::IoFlag mode() const
Access mode.
Definition DbAccessObj.h:55

◆ load()

StatusCode DbContainerObj::load ( void ** ptr,
const DbTypeInfo * tinfo,
const Token::OID_t & linkH,
Token::OID_t & oid,
bool any_next )

Select object in the container identified by its handle.

◆ mode()

Io::IoFlag DbAccessObjBase::mode ( ) const
inlineinherited

Access mode.

Definition at line 55 of file DbAccessObj.h.

55{ return m_mode; }
Io::IoFlag m_mode
Access mode.
Definition DbAccessObj.h:35

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

const std::string & DbAccessObjBase::name ( ) const
inlineinherited

Access the instance name.

Definition at line 51 of file DbAccessObj.h.

51{ return m_name; }

◆ next()

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

Fetch next object address to set token.

◆ objectShape()

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

Retrieve persistent type information by name.

◆ open()

StatusCode DbContainerObj::open ( const DbTypeInfo * typ)

Open the container.

◆ refCount()

int DbAccessObjBase::refCount ( ) const
inlineinherited

Access reference counter.

Definition at line 64 of file DbAccessObj.h.

64{ return m_refCount; }

◆ release()

int DbAccessObjBase::release ( ) const
inlineinherited

Remove reference count.

Definition at line 78 of file DbAccessObj.h.

78 {
79 int count = --m_refCount;
80#ifdef DEBUG_REFCOUNTS
81 std::cout << typeid(*this).name()
82 << " "
83 << m_name
84 << " Refcount:"
85 << count
86 << std::endl;
87#endif
88 if ( count == 0 ) {
89 delete this;
90 }
91 return count;
92 }
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148

◆ retire()

StatusCode 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 DbAccessObjBase::setMode ( Io::IoFlag m)
inlineinherited

Set Access mode.

Definition at line 57 of file DbAccessObj.h.

◆ setName()

void DbAccessObjBase::setName ( const std::string & n)
inlineinherited

Access the instance name.

Definition at line 53 of file DbAccessObj.h.

◆ setOption()

StatusCode DbContainerObj::setOption ( const DbOption & opt)

Pass options to the implementation.

◆ size()

uint64_t DbContainerObj::size ( )

Size of the Database container (=# of objects).

◆ store()

StatusCode DbContainerObj::store ( const void * object,
DbContainer & cntH,
const DbTypeInfo * tinfo )

Store object in location.

◆ techFactory() [1/2]

ITechFactory * DbAccessObjBase::techFactory ( )
inlineinherited

Definition at line 62 of file DbAccessObj.h.

62{ return m_factory; }
ITechFactory * m_factory
Pointer to specific pool implementation.
Definition DbAccessObj.h:41

◆ techFactory() [2/2]

const ITechFactory * DbAccessObjBase::techFactory ( ) const
inlineinherited

Allow access to the Database implementation.

Definition at line 61 of file DbAccessObj.h.

61{ return m_factory; }

◆ token()

const Token * DbContainerObj::token ( ) const
inline

Access the token of the container object.

Definition at line 65 of file DbContainerObj.h.

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

◆ transAct()

StatusCode DbContainerObj::transAct ( Transaction::Action )

Execute Database Transaction Action.

◆ type()

const DbType & DbAccessObjBase::type ( ) const
inlineinherited

Definition at line 59 of file DbAccessObj.h.

59{ return m_type; }
DbType m_type
Database type.
Definition DbAccessObj.h:39

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 DbContainerObj::m_dbH
private

Handle to hosting Database.

Definition at line 36 of file DbContainerObj.h.

◆ m_factory

ITechFactory* DbAccessObjBase::m_factory
privateinherited

Pointer to specific pool implementation.

Definition at line 41 of file DbAccessObj.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

ITechContainer* DbContainerObj::m_info
private

Pointer to interface of the technology dependent part.

Definition at line 32 of file DbContainerObj.h.

◆ m_isOpen

bool DbContainerObj::m_isOpen
private

Flag indication StatusCode of technology dependent container.

Definition at line 38 of file DbContainerObj.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

Io::IoFlag DbAccessObjBase::m_mode
privateinherited

Access mode.

Definition at line 35 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 DbAccessObjBase::m_name
privateinherited

Name of the instance.

Definition at line 37 of file DbAccessObj.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_refCount

std::atomic<int> DbAccessObjBase::m_refCount
mutableprivateinherited

Reference counter.

Definition at line 33 of file DbAccessObj.h.

◆ m_tokH

const Token* DbContainerObj::m_tokH
private

Container token.

Definition at line 34 of file DbContainerObj.h.

◆ m_type

DbType DbAccessObjBase::m_type
privateinherited

Database type.

Definition at line 39 of file DbAccessObj.h.


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