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

Base class for all access objects with reference counting and common members but no container functionality. More...

#include <DbAccessObj.h>

Inheritance diagram for pool::DbAccessObjBase:
Collaboration diagram for pool::DbAccessObjBase:

Public Member Functions

 DbAccessObjBase (const std::string &n, Io::IoFlag m, const DbType &t, IOODatabase *s=0)
 Constructor with initializing arguments.
virtual ~DbAccessObjBase ()
 Standard destructor.
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 DbTypetype () const
const IOODatabasedb () const
 Allow access to the Database implementation.
IOODatabasedb ()
int refCount () const
 Access reference counter.
int addRef () const
 Add reference count.
int release () const
 Remove reference count.

Private Attributes

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.
IOODatabasem_pool
 Pointer to specific pool implementation.

Detailed Description

Base class for all access objects with reference counting and common members but no container functionality.

Definition at line 49 of file DbAccessObj.h.

Constructor & Destructor Documentation

◆ DbAccessObjBase()

pool::DbAccessObjBase::DbAccessObjBase ( const std::string & n,
Io::IoFlag m,
const DbType & t,
IOODatabase * s = 0 )
inline

Constructor with initializing arguments.

Definition at line 64 of file DbAccessObj.h.

65 : m_refCount(0), m_mode(m), m_name(n), m_type(t), m_pool(s)
66 { if( m_pool ) m_pool->addRef(); }
DbType m_type
Database type.
Definition DbAccessObj.h:58
Io::IoFlag m_mode
Access mode.
Definition DbAccessObj.h:54
IOODatabase * m_pool
Pointer to specific pool implementation.
Definition DbAccessObj.h:60
std::string m_name
Name of the instance.
Definition DbAccessObj.h:56
std::atomic< int > m_refCount
Reference counter.
Definition DbAccessObj.h:52

◆ ~DbAccessObjBase()

virtual pool::DbAccessObjBase::~DbAccessObjBase ( )
inlinevirtual

Standard destructor.

Definition at line 68 of file DbAccessObj.h.

68{ releasePtr( m_pool ); }
void releasePtr(T *&p)
Release a pointer.

Member Function Documentation

◆ addRef()

int pool::DbAccessObjBase::addRef ( ) const
inline

Add reference count.

Definition at line 85 of file DbAccessObj.h.

85 {
86#ifdef DEBUG_REFCOUNTS
87 std::cout << typeid(*this).name()
88 << " "
89 << m_name
90 << " Refcount:"
91 << m_refCount+1
92 << std::endl;
93#endif
94 return ++m_refCount;
95 }

◆ db() [1/2]

IOODatabase * pool::DbAccessObjBase::db ( )
inline

Definition at line 81 of file DbAccessObj.h.

81{ return m_pool; }

◆ db() [2/2]

const IOODatabase * pool::DbAccessObjBase::db ( ) const
inline

Allow access to the Database implementation.

Definition at line 80 of file DbAccessObj.h.

80{ return m_pool; }

◆ mode()

Io::IoFlag pool::DbAccessObjBase::mode ( ) const
inline

Access mode.

Definition at line 74 of file DbAccessObj.h.

74{ return m_mode; }

◆ name()

const std::string & pool::DbAccessObjBase::name ( ) const
inline

Access the instance name.

Definition at line 70 of file DbAccessObj.h.

70{ return m_name; }

◆ refCount()

int pool::DbAccessObjBase::refCount ( ) const
inline

Access reference counter.

Definition at line 83 of file DbAccessObj.h.

83{ return m_refCount; }

◆ release()

int pool::DbAccessObjBase::release ( ) const
inline

Remove reference count.

Definition at line 97 of file DbAccessObj.h.

97 {
98 int count = --m_refCount;
99#ifdef DEBUG_REFCOUNTS
100 std::cout << typeid(*this).name()
101 << " "
102 << m_name
103 << " Refcount:"
104 << count
105 << std::endl;
106#endif
107 if ( count == 0 ) {
108 delete this;
109 }
110 return count;
111 }
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148

◆ setMode()

void pool::DbAccessObjBase::setMode ( Io::IoFlag m)
inline

Set Access mode.

Definition at line 76 of file DbAccessObj.h.

◆ setName()

void pool::DbAccessObjBase::setName ( const std::string & n)
inline

Access the instance name.

Definition at line 72 of file DbAccessObj.h.

◆ type()

const DbType & pool::DbAccessObjBase::type ( ) const
inline

Definition at line 78 of file DbAccessObj.h.

78{ return m_type; }

Member Data Documentation

◆ m_mode

Io::IoFlag pool::DbAccessObjBase::m_mode
private

Access mode.

Definition at line 54 of file DbAccessObj.h.

◆ m_name

std::string pool::DbAccessObjBase::m_name
private

Name of the instance.

Definition at line 56 of file DbAccessObj.h.

◆ m_pool

IOODatabase* pool::DbAccessObjBase::m_pool
private

Pointer to specific pool implementation.

Definition at line 60 of file DbAccessObj.h.

◆ m_refCount

std::atomic<int> pool::DbAccessObjBase::m_refCount
mutableprivate

Reference counter.

Definition at line 52 of file DbAccessObj.h.

◆ m_type

DbType pool::DbAccessObjBase::m_type
private

Database type.

Definition at line 58 of file DbAccessObj.h.


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