ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
pool::DbAccessObj< KEY, TYPE > Class Template Reference

#include <StorageSvc/DbAccessObj.h>

Collaboration diagram for pool::DbAccessObj< KEY, TYPE >:

Public Types

typedef DbAccessObj< KEY, TYPEBase
 Type definitions. More...
 
typedef std::map< KEY, TYPE * > Keys
 
typedef Keys::iterator iterator
 
typedef Keys::const_iterator const_iterator
 

Public Member Functions

 DbAccessObj (const std::string &n, DbAccessMode m, const DbType &t, IOODatabase *s=0)
 Constructor with initializing arguments. More...
 
virtual ~DbAccessObj ()
 Standard destructor. More...
 
const std::string & name () const
 Access the instance name. More...
 
void setName (const std::string &n)
 Access the instance name. More...
 
DbAccessMode mode () const
 Access mode. More...
 
void setMode (DbAccessMode m)
 Set Access mode. More...
 
const DbTypetype () const
 
const IOODatabasedb () const
 Allow access to the Database implementation. More...
 
IOODatabasedb ()
 
int refCount () const
 Access reference counter. More...
 
int addRef () const
 Add reference count. More...
 
int release () const
 Remove reference count. More...
 
size_t size () const
 Object size. More...
 
DbStatus clearEntries ()
 Object cleanup: remove all entries. More...
 
const TYPEfind (const KEY &key) const
 Find object by key (CONST) More...
 
TYPEfind (const KEY &key)
 Find object by key. More...
 
DbStatus add (const KEY &key, TYPE *val)
 Add entry to container. More...
 
DbStatus remove (const TYPE *val)
 Remove entry from container. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Private Attributes

std::atomic< int > m_refCount
 Reference counter. More...
 
DbAccessMode m_mode
 Access mode. More...
 
std::string m_name
 Name of the instance. More...
 
DbType m_type
 Database type. More...
 
Keys m_keys
 Key entry buffer. More...
 
IOODatabasem_pool
 Pointer to specific pool implementation. More...
 

Detailed Description

template<class KEY, class TYPE>
class pool::DbAccessObj< KEY, TYPE >

Description:

Templated base class for "abstarct" container objects. These abstarct containers are: DnSessions, DbDomainObjs, DbDatabaseObjs and DbContainerObjs.

Author
M.Frank
Version
1.0

Definition at line 47 of file DbAccessObj.h.

Member Typedef Documentation

◆ Base

template<class KEY , class TYPE >
typedef DbAccessObj< KEY , TYPE > pool::DbAccessObj< KEY, TYPE >::Base

Type definitions.

Definition at line 50 of file DbAccessObj.h.

◆ const_iterator

template<class KEY , class TYPE >
typedef Keys::const_iterator pool::DbAccessObj< KEY, TYPE >::const_iterator

Definition at line 53 of file DbAccessObj.h.

◆ iterator

template<class KEY , class TYPE >
typedef Keys::iterator pool::DbAccessObj< KEY, TYPE >::iterator

Definition at line 52 of file DbAccessObj.h.

◆ Keys

template<class KEY , class TYPE >
typedef std::map< KEY, TYPE* > pool::DbAccessObj< KEY, TYPE >::Keys

Definition at line 51 of file DbAccessObj.h.

Constructor & Destructor Documentation

◆ DbAccessObj()

template<class KEY , class TYPE >
pool::DbAccessObj< KEY, TYPE >::DbAccessObj ( const std::string &  n,
DbAccessMode  m,
const DbType t,
IOODatabase s = 0 
)
inline

Constructor with initializing arguments.

Definition at line 70 of file DbAccessObj.h.

71  : m_refCount(0), m_mode(m), m_name(n), m_type(t), m_pool(s)
72  { if( m_pool ) m_pool->addRef(); }

◆ ~DbAccessObj()

template<class KEY , class TYPE >
virtual pool::DbAccessObj< KEY, TYPE >::~DbAccessObj ( )
inlinevirtual

Standard destructor.

Definition at line 74 of file DbAccessObj.h.

74 { releasePtr( m_pool ); }

Member Function Documentation

◆ add()

template<class KEY , class TYPE >
DbStatus pool::DbAccessObj< KEY, TYPE >::add ( const KEY &  key,
TYPE val 
)
inline

Add entry to container.

Definition at line 142 of file DbAccessObj.h.

142  {
143  iterator i = m_keys.find(key);
144  if ( m_keys.end() == i ) {
145  m_keys.insert(std::make_pair(key, val));
146  val->addRef();
147  return Success;
148  }
149  return Error;
150  }

◆ addRef()

template<class KEY , class TYPE >
int pool::DbAccessObj< KEY, TYPE >::addRef ( ) const
inline

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  }

◆ begin() [1/2]

template<class KEY , class TYPE >
iterator pool::DbAccessObj< KEY, TYPE >::begin ( )
inline

Definition at line 163 of file DbAccessObj.h.

163 { return m_keys.begin(); }

◆ begin() [2/2]

template<class KEY , class TYPE >
const_iterator pool::DbAccessObj< KEY, TYPE >::begin ( ) const
inline

Definition at line 164 of file DbAccessObj.h.

164 { return m_keys.begin(); }

◆ clearEntries()

template<class KEY , class TYPE >
DbStatus pool::DbAccessObj< KEY, TYPE >::clearEntries ( )
inline

Object cleanup: remove all entries.

Definition at line 123 of file DbAccessObj.h.

123  {
124  Keys k = m_keys;
125  for(iterator j = k.begin(); j != k.end(); ++j ) {
126  (*j).second->release();
127  }
128  m_keys.clear();
129  return Success;
130  }

◆ db() [1/2]

template<class KEY , class TYPE >
IOODatabase* pool::DbAccessObj< KEY, TYPE >::db ( )
inline

Definition at line 87 of file DbAccessObj.h.

87 { return m_pool; }

◆ db() [2/2]

template<class KEY , class TYPE >
const IOODatabase* pool::DbAccessObj< KEY, TYPE >::db ( ) const
inline

Allow access to the Database implementation.

Definition at line 86 of file DbAccessObj.h.

86 { return m_pool; }

◆ end() [1/2]

template<class KEY , class TYPE >
iterator pool::DbAccessObj< KEY, TYPE >::end ( )
inline

Definition at line 165 of file DbAccessObj.h.

165 { return m_keys.end(); }

◆ end() [2/2]

template<class KEY , class TYPE >
const_iterator pool::DbAccessObj< KEY, TYPE >::end ( ) const
inline

Definition at line 166 of file DbAccessObj.h.

166 { return m_keys.end(); }

◆ find() [1/2]

template<class KEY , class TYPE >
TYPE* pool::DbAccessObj< KEY, TYPE >::find ( const KEY &  key)
inline

Find object by key.

Definition at line 137 of file DbAccessObj.h.

137  {
138  iterator i = m_keys.find(key);
139  return (m_keys.end() == i) ? 0 : (*i).second;
140  }

◆ find() [2/2]

template<class KEY , class TYPE >
const TYPE* pool::DbAccessObj< KEY, TYPE >::find ( const KEY &  key) const
inline

Find object by key (CONST)

Definition at line 132 of file DbAccessObj.h.

132  {
133  const_iterator i = m_keys.find(key);
134  return (m_keys.end() == i) ? 0 : (*i).second;
135  }

◆ mode()

template<class KEY , class TYPE >
DbAccessMode pool::DbAccessObj< KEY, TYPE >::mode ( ) const
inline

Access mode.

Definition at line 80 of file DbAccessObj.h.

80 { return m_mode; }

◆ name()

template<class KEY , class TYPE >
const std::string& pool::DbAccessObj< KEY, TYPE >::name ( ) const
inline

Access the instance name.

Definition at line 76 of file DbAccessObj.h.

76 { return m_name; }

◆ refCount()

template<class KEY , class TYPE >
int pool::DbAccessObj< KEY, TYPE >::refCount ( ) const
inline

Access reference counter.

Definition at line 89 of file DbAccessObj.h.

89 { return m_refCount; }

◆ release()

template<class KEY , class TYPE >
int pool::DbAccessObj< KEY, TYPE >::release ( ) const
inline

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

template<class KEY , class TYPE >
DbStatus pool::DbAccessObj< KEY, TYPE >::remove ( const TYPE val)
inline

Remove entry from container.

Definition at line 152 of file DbAccessObj.h.

152  {
153  for (iterator j = m_keys.begin(); j != m_keys.end(); ++j ) {
154  if ( (*j).second == val ) {
155  TYPE* p = (*j).second;
156  m_keys.erase(j);
157  p->release();
158  return Success;
159  }
160  }
161  return Error;
162  }

◆ setMode()

template<class KEY , class TYPE >
void pool::DbAccessObj< KEY, TYPE >::setMode ( DbAccessMode  m)
inline

Set Access mode.

Definition at line 82 of file DbAccessObj.h.

82 { m_mode = m; }

◆ setName()

template<class KEY , class TYPE >
void pool::DbAccessObj< KEY, TYPE >::setName ( const std::string &  n)
inline

Access the instance name.

Definition at line 78 of file DbAccessObj.h.

78 { m_name = n; }

◆ size()

template<class KEY , class TYPE >
size_t pool::DbAccessObj< KEY, TYPE >::size ( ) const
inline

Object size.

Definition at line 119 of file DbAccessObj.h.

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

◆ type()

template<class KEY , class TYPE >
const DbType& pool::DbAccessObj< KEY, TYPE >::type ( ) const
inline

Definition at line 84 of file DbAccessObj.h.

84 { return m_type; }

Member Data Documentation

◆ m_keys

template<class KEY , class TYPE >
Keys pool::DbAccessObj< KEY, TYPE >::m_keys
private

Key entry buffer.

Definition at line 64 of file DbAccessObj.h.

◆ m_mode

template<class KEY , class TYPE >
DbAccessMode pool::DbAccessObj< KEY, TYPE >::m_mode
private

Access mode.

Definition at line 58 of file DbAccessObj.h.

◆ m_name

template<class KEY , class TYPE >
std::string pool::DbAccessObj< KEY, TYPE >::m_name
private

Name of the instance.

Definition at line 60 of file DbAccessObj.h.

◆ m_pool

template<class KEY , class TYPE >
IOODatabase* pool::DbAccessObj< KEY, TYPE >::m_pool
private

Pointer to specific pool implementation.

Definition at line 66 of file DbAccessObj.h.

◆ m_refCount

template<class KEY , class TYPE >
std::atomic<int> pool::DbAccessObj< KEY, TYPE >::m_refCount
mutableprivate

Reference counter.

Definition at line 56 of file DbAccessObj.h.

◆ m_type

template<class KEY , class TYPE >
DbType pool::DbAccessObj< KEY, TYPE >::m_type
private

Database type.

Definition at line 62 of file DbAccessObj.h.


The documentation for this class was generated from the following file:
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
pool::DbAccessObj::m_mode
DbAccessMode m_mode
Access mode.
Definition: DbAccessObj.h:58
pool::RefCounter::addRef
int addRef()
Increase the reference count.
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:139
pool::DbAccessObj::m_type
DbType m_type
Database type.
Definition: DbAccessObj.h:62
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
pool::DbAccessObj::m_refCount
std::atomic< int > m_refCount
Reference counter.
Definition: DbAccessObj.h:56
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
pool::DbAccessObj::const_iterator
Keys::const_iterator const_iterator
Definition: DbAccessObj.h:53
pool::DbAccessObj::m_keys
Keys m_keys
Key entry buffer.
Definition: DbAccessObj.h:64
pool::DbAccessObj::m_name
std::string m_name
Name of the instance.
Definition: DbAccessObj.h:60
pool::DbAccessObj::iterator
Keys::iterator iterator
Definition: DbAccessObj.h:52
TYPE
#define TYPE(CODE, TYP, IOTYP)
pool::DbAccessObj::Keys
std::map< KEY, TYPE * > Keys
Definition: DbAccessObj.h:51
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
pool::releasePtr
DbStatus releasePtr(T *&p)
Release a pointer.
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:110
pool::DbAccessObj::m_pool
IOODatabase * m_pool
Pointer to specific pool implementation.
Definition: DbAccessObj.h:66
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37