ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
pool::DbContainerObj Class Reference

#include <src/DbContainerObj.h>

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

Public Types

typedef DbAccessObj< DbObject *, DbObjectHolderBase
 Type definitions. More...
 
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. More...
 
virtual ~DbContainerObj ()
 Standard destructor. More...
 
const IDbContainerinfo () const
 Access to internals. More...
 
IDbContainerinfo ()
 
const DbTypeInfoobjectShape (const Guid &nam)
 Retrieve persistent type information by name. More...
 
DbStatus addShape (const DbTypeInfo *typ)
 Add persistent type. Returns error if the type is not supported. More...
 
DbDatabasedatabase ()
 Handle to Database (CONST) More...
 
const Tokentoken () const
 Access the token of the container object. More...
 
bool updatesPending () const
 Query the pending transaction stack. More...
 
bool isOpen () const
 Flag if container was opened. More...
 
bool isReadOnly () const
 Check if database is in read-only mode. More...
 
void cancelTransaction ()
 Cancel transaction flag. More...
 
uint64_t size ()
 Size of the Database container (=# of objects) More...
 
DbStatus open (const DbTypeInfo *typ)
 Open the container. More...
 
DbStatus close ()
 Close the container. More...
 
DbStatus retire ()
 Retire the container. More...
 
DbStatus transAct (Transaction::Action)
 Execute Database Transaction Action. More...
 
DbStatus setOption (const DbOption &opt)
 Pass options to the implementation. More...
 
DbStatus getOption (DbOption &refOpt)
 Access options. More...
 
DbStatus remove (ObjHandle &objH)
 Remove the transient representation of the object from memory. More...
 
DbStatus destroy (const Token::OID_t &linkH)
 Destroy an existing persistent object identified by its handle. More...
 
DbStatus save (DbObjectHandle< DbObject > &objH, const DbTypeInfo *typ)
 Add an object to the container identified by its handle. More...
 
void * allocate (unsigned long siz, DbContainer &cntH, ShapeH shape)
 In place allocation of raw memory. More...
 
DbStatus allocate (DbContainer &cntH, const void *object, ShapeH shape, Token::OID_t &oid)
 In place allocation of object location. More...
 
DbStatus free (void *ptr, DbContainer &cntH)
 In place free of raw memory. More...
 
DbStatus save (DbContainer &cntH, const void *object, ShapeH shape, Token::OID_t &linkH)
 Save new object in the container and return its handle. More...
 
DbStatus update (DbContainer &cntH, const void *object, ShapeH shape, const Token::OID_t &linkH)
 Update an object to the container identified by its handle. More...
 
DbStatus update (DbContainer &cntH, const void *object, ShapeH shape, const DbObjectHandle< DbObject > &objH)
 Update existing object in the container. More...
 
DbStatus 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. More...
 
DbStatus update (DbSelect &sel)
 Perform UPDATE select. More...
 
DbStatus destroy (DbSelect &sel)
 Perform DELETE statement. More...
 
DbStatus select (DbSelect &sel)
 Perform selection. The statement belongs to the container afterwards. More...
 
DbStatus fetch (DbSelect &sel)
 Fetch next object address of the selection to set token. 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...
 
DbStatus clearEntries ()
 Object cleanup: remove all entries. More...
 
const DbObjectHolderfind (const DbObject * &key) const
 Find object by key (CONST) More...
 
DbObjectHolderfind (const DbObject * &key)
 Find object by key. More...
 
DbStatus add (const DbObject * &key, DbObjectHolder *val)
 Add entry to container. More...
 
DbStatus remove (const DbObjectHolder *val)
 Remove entry from container. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Private Types

typedef DbObjectHandle< DbObjectObjHandle
 

Private Member Functions

bool hasAccess ()
 Check database access. More...
 

Private Attributes

IDbContainerm_info
 Pointer to interface of the technology dependent part. More...
 
const Tokenm_tokH
 Container token. More...
 
DbDatabase m_dbH
 Handle to hosting Database. More...
 
bool m_isOpen
 Flag indication DbStatus of technology dependent container. More...
 
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

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 50 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.

◆ ObjHandle

Definition at line 52 of file DbContainerObj.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()

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

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

int pool::DbAccessObj< DbObject * , DbObjectHolder >::addRef
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  }

◆ addShape()

DbStatus pool::DbContainerObj::addShape ( const DbTypeInfo typ)

Add persistent type. Returns error if the type is not supported.

◆ allocate() [1/2]

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

In place allocation of object location.

◆ allocate() [2/2]

void* pool::DbContainerObj::allocate ( unsigned long  siz,
DbContainer cntH,
ShapeH  shape 
)

In place allocation of raw memory.

◆ begin() [1/2]

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

Definition at line 163 of file DbAccessObj.h.

163 { return m_keys.begin(); }

◆ begin() [2/2]

Definition at line 164 of file DbAccessObj.h.

164 { return m_keys.begin(); }

◆ cancelTransaction()

void pool::DbContainerObj::cancelTransaction ( )
inline

Cancel transaction flag.

Definition at line 99 of file DbContainerObj.h.

99 { }

◆ clearEntries()

DbStatus pool::DbAccessObj< DbObject * , DbObjectHolder >::clearEntries
inlineinherited

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  }

◆ close()

DbStatus pool::DbContainerObj::close ( )

Close the container.

◆ database()

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

Handle to Database (CONST)

Definition at line 88 of file DbContainerObj.h.

88 { return m_dbH; }

◆ db() [1/2]

Definition at line 87 of file DbAccessObj.h.

87 { return m_pool; }

◆ db() [2/2]

Allow access to the Database implementation.

Definition at line 86 of file DbAccessObj.h.

86 { return m_pool; }

◆ destroy() [1/2]

DbStatus pool::DbContainerObj::destroy ( const Token::OID_t linkH)

Destroy an existing persistent object identified by its handle.

◆ destroy() [2/2]

DbStatus pool::DbContainerObj::destroy ( DbSelect sel)

Perform DELETE statement.

◆ end() [1/2]

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

Definition at line 165 of file DbAccessObj.h.

165 { return m_keys.end(); }

◆ end() [2/2]

Definition at line 166 of file DbAccessObj.h.

166 { return m_keys.end(); }

◆ fetch()

DbStatus pool::DbContainerObj::fetch ( DbSelect sel)

Fetch next object address of the selection to set token.

◆ find() [1/2]

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

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]

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

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  }

◆ free()

DbStatus pool::DbContainerObj::free ( void *  ptr,
DbContainer cntH 
)

In place free of raw memory.

◆ getOption()

DbStatus 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 82 of file DbContainerObj.h.

82 { return m_info; }

◆ info() [2/2]

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

Access to internals.

Definition at line 81 of file DbContainerObj.h.

81 { return m_info; }

◆ isOpen()

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

Flag if container was opened.

Definition at line 94 of file DbContainerObj.h.

94 { return m_isOpen; }

◆ isReadOnly()

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

Check if database is in read-only mode.

Definition at line 96 of file DbContainerObj.h.

97  { return !(mode()&pool::UPDATE) && !(mode()&pool::CREATE); }

◆ load()

DbStatus 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
inlineinherited

Access mode.

Definition at line 80 of file DbAccessObj.h.

80 { return m_mode; }

◆ name()

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

Access the instance name.

Definition at line 76 of file DbAccessObj.h.

76 { return m_name; }

◆ objectShape()

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

Retrieve persistent type information by name.

◆ open()

DbStatus pool::DbContainerObj::open ( const DbTypeInfo typ)

Open the container.

◆ refCount()

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

Access reference counter.

Definition at line 89 of file DbAccessObj.h.

89 { return m_refCount; }

◆ release()

int pool::DbAccessObj< DbObject * , DbObjectHolder >::release
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() [1/2]

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

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  }

◆ remove() [2/2]

DbStatus pool::DbContainerObj::remove ( ObjHandle objH)

Remove the transient representation of the object from memory.

◆ retire()

DbStatus pool::DbContainerObj::retire ( )

Retire the container.

◆ save() [1/2]

DbStatus pool::DbContainerObj::save ( DbContainer cntH,
const void *  object,
ShapeH  shape,
Token::OID_t linkH 
)

Save new object in the container and return its handle.

Parameters
cntH[IN] Handle to container object.
linkH[OUT] Internal OID to identify object.
Returns
DbStatus code indicating success or failure.

◆ save() [2/2]

DbStatus pool::DbContainerObj::save ( DbObjectHandle< DbObject > &  objH,
const DbTypeInfo typ 
)

Add an object to the container identified by its handle.

◆ select()

DbStatus pool::DbContainerObj::select ( DbSelect sel)

Perform selection. The statement belongs to the container afterwards.

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

DbStatus pool::DbContainerObj::setOption ( const DbOption opt)

Pass options to the implementation.

◆ size()

uint64_t pool::DbContainerObj::size ( )

Size of the Database container (=# of objects)

◆ token()

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

Access the token of the container object.

Definition at line 90 of file DbContainerObj.h.

90 { return m_tokH; }

◆ transAct()

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

Execute Database Transaction Action.

◆ type()

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

Definition at line 84 of file DbAccessObj.h.

84 { return m_type; }

◆ update() [1/3]

DbStatus pool::DbContainerObj::update ( DbContainer cntH,
const void *  object,
ShapeH  shape,
const DbObjectHandle< DbObject > &  objH 
)

Update existing object in the container.

Parameters
cntH[IN] Valid handle to container
objH[IN] Object handle
Returns
Status code indicating success or failure.

◆ update() [2/3]

DbStatus pool::DbContainerObj::update ( DbContainer cntH,
const void *  object,
ShapeH  shape,
const Token::OID_t linkH 
)

Update an object to the container identified by its handle.

Parameters
cntH[IN] Handle to container object.
linkH[IN] Internal OID to identify object.
Returns
DbStatus code indicating success or failure.

◆ update() [3/3]

DbStatus pool::DbContainerObj::update ( DbSelect sel)

Perform UPDATE select.

◆ updatesPending()

bool pool::DbContainerObj::updatesPending ( ) const

Query the pending transaction stack.

Member Data Documentation

◆ m_dbH

DbDatabase pool::DbContainerObj::m_dbH
private

Handle to hosting Database.

Definition at line 59 of file DbContainerObj.h.

◆ m_info

IDbContainer* pool::DbContainerObj::m_info
private

Pointer to interface of the technology dependent part.

Definition at line 55 of file DbContainerObj.h.

◆ m_isOpen

bool pool::DbContainerObj::m_isOpen
private

Flag indication DbStatus of technology dependent container.

Definition at line 61 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_mode

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

Access mode.

Definition at line 58 of file DbAccessObj.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_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 57 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:
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
pool::DbAccessObj< DbObject *, DbObjectHolder >::m_mode
DbAccessMode m_mode
Access mode.
Definition: DbAccessObj.h:58
pool::DbContainerObj::m_tokH
const Token * m_tokH
Container token.
Definition: DbContainerObj.h:57
pool::CREATE
@ CREATE
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:70
pool::DbAccessObj< DbObject *, DbObjectHolder >::m_type
DbType m_type
Database type.
Definition: DbAccessObj.h:62
pool::DbContainerObj::m_info
IDbContainer * m_info
Pointer to interface of the technology dependent part.
Definition: DbContainerObj.h:55
pool::UPDATE
@ UPDATE
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:69
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
pool::DbAccessObj< DbObject *, DbObjectHolder >::m_refCount
std::atomic< int > m_refCount
Reference counter.
Definition: DbAccessObj.h:56
pool::DbAccessObj< DbObject *, DbObjectHolder >::mode
DbAccessMode mode() const
Access mode.
Definition: DbAccessObj.h:80
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
pool::DbAccessObj< DbObject *, DbObjectHolder >::const_iterator
Keys::const_iterator const_iterator
Definition: DbAccessObj.h:53
pool::DbAccessObj< DbObject *, DbObjectHolder >::m_keys
Keys m_keys
Key entry buffer.
Definition: DbAccessObj.h:64
pool::DbAccessObj< DbObject *, DbObjectHolder >::m_name
std::string m_name
Name of the instance.
Definition: DbAccessObj.h:60
pool::DbAccessObj< DbObject *, DbObjectHolder >::iterator
Keys::iterator iterator
Definition: DbAccessObj.h:52
TYPE
#define TYPE(CODE, TYP, IOTYP)
pool::DbAccessObj< DbObject *, DbObjectHolder >::Keys
std::map< DbObject *, DbObjectHolder * > Keys
Definition: DbAccessObj.h:51
pool::DbContainerObj::m_isOpen
bool m_isOpen
Flag indication DbStatus of technology dependent container.
Definition: DbContainerObj.h:61
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::DbAccessObj< DbObject *, DbObjectHolder >::m_pool
IOODatabase * m_pool
Pointer to specific pool implementation.
Definition: DbAccessObj.h:66
pool::DbContainerObj::m_dbH
DbDatabase m_dbH
Handle to hosting Database.
Definition: DbContainerObj.h:59
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37