ATLAS Offline Software
DbContainer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //====================================================================
6 // DbContainer handle definitions
7 //--------------------------------------------------------------------
8 //
9 // Package : StorageSvc (The POOL project)
10 // @author M.Frank
11 //====================================================================
12 #ifndef POOL_DBCONTAINER_H
13 #define POOL_DBCONTAINER_H
14 
15 // Framework include files
18 #include "StorageSvc/Transaction.h"
19 
20 #include <cstdint>
21 
22 /*
23  * POOL namespace declaration
24  */
25 namespace pool {
26 
27  // Forward declarations
28  class IDbContainer;
29  class DbSelect;
30  class DbDatabase;
31  class DbTypeInfo;
32  class DbContainerObj;
33  class DbTransaction;
34  class DbOption;
35 
36  typedef const class Shape *ShapeH;
37 
48  class DbContainer : public DbHandleBase<DbContainerObj> {
49  private:
54  const Token::OID_t& linkH,
55  const DbTypeInfo* typ,
56  bool any_next);
59  Token::OID_t& linkH,
60  const DbTypeInfo* typ);
63  const DbTypeInfo* typ);
66 
67  public:
69  explicit DbContainer(const DbType& typ=POOL_StorageType) { m_type=typ; }
71  DbContainer(const DbContainer& c) : Base() { switchPtr(c.m_ptr); }
75  virtual ~DbContainer() { switchPtr(0); }
78  if ( &copy != this ) {
79  m_type = copy.m_type;
80  switchPtr( copy.m_ptr );
81  }
82  return *this;
83  }
85  DbContainer& operator=(const int /* nuller */ ) {
86  switchPtr(0);
87  return *this;
88  }
90  int refCount() const;
92  const std::string& name() const;
100  const IDbContainer* info() const;
103  const DbTypeInfo* objectShape(const Guid& nam);
105  const Token* token() const;
108 
110 
120  const std::string& nam,
121  const DbTypeInfo* typ,
122  const DbType& dbtyp,
123  DbAccessMode mod);
124 
126 
133  const std::string& nam,
134  const DbType& dbtyp);
135 
137  bool isOpen() const;
141  DbStatus setOption(const DbOption& refOpt);
144 
156 
160  DbStatus allocate(const void* object, ShapeH shape, Token::OID_t& oid);
163  DbStatus save(const void* object, ShapeH shape, Token::OID_t& linkH);
165  DbStatus load(void** ptr, ShapeH shape, const Token::OID_t& lH);
167 
172  void* allocate(unsigned long siz, const DbTypeInfo* typ);
175  DbStatus free(void* ptr);
177  template <class T> DbStatus remove( const DbObjectHandle<T>& objH)
178  { DbObjectHandle<DbObject> oH(objH.ptr()); return _remove(oH); }
180  template <class T> DbStatus save( DbObjectHandle<T>& objH,
181  const DbTypeInfo* typ)
182  { DbObjectHandle<DbObject> oH(objH.ptr()); return _save(oH, typ); }
184  template <class T> DbStatus load( DbObjectHandle<T>& objH,
185  const Token::OID_t& linkH,
186  const DbTypeInfo* typ)
187  { return _load(objH, linkH, typ, false); }
189  template <class T> DbStatus loadNext(DbObjectHandle<T>& objH,
190  Token::OID_t& linkH,
191  const DbTypeInfo* typ)
192  { return _loadNext(objH, linkH, typ); }
194  };
195 } // End namespace pool
196 
197 
198 // operator new for the creation of objects using clustering hint
199 inline
200 void* operator new (size_t size, pool::DbContainer& cntH, const pool::DbTypeInfo* typ) {
201  return cntH.allocate(size, typ);
202 }
203 
204 // C++ exception enabled compilation needs this delete operator
205 inline
206 void operator delete (void *ptr, pool::DbContainer& cntH) {
207  cntH.free(ptr);
208 }
209 
210 #endif // POOL_DBCONTAINER_H
pool::DbContainer::close
DbStatus close()
Close the container the handle points to.
pool::DbAccessMode
int DbAccessMode
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:36
pool::DbContainer::switchPtr
void switchPtr(DbContainerObj *obj)
Assign transient object properly (including reference counting)
pool::DbStatus
Definition: DbStatus.h:67
Transaction.h
pool::DbContainer::info
const IDbContainer * info() const
Let the implementation access the internals.
pool::DbContainer::setOption
DbStatus setOption(const DbOption &refOpt)
Pass options to the implementation.
pool::DbContainer::select
DbStatus select(DbSelect &sel)
Access objects through select staements.
pool::DbContainer::DbContainer
DbContainer(const DbType &typ=POOL_StorageType)
Constructor with initializing arguments.
Definition: DbContainer.h:69
pool::DbContainer::operator=
DbContainer & operator=(const DbContainer &copy)
Assignment operator.
Definition: DbContainer.h:77
pool
pool namespace
Definition: libname.h:15
pool::DbContainer::save
DbStatus save(DbObjectHandle< T > &objH, const DbTypeInfo *typ)
Add an object to the container identified by its handle.
Definition: DbContainer.h:180
pool::DbContainer::token
const Token * token() const
Access the token of the container object.
pool::DbContainer::load
DbStatus load(DbObjectHandle< T > &objH, const Token::OID_t &linkH, const DbTypeInfo *typ)
Load object in the container identified by its handle.
Definition: DbContainer.h:184
pool::DbContainer::remove
DbStatus remove(const DbObjectHandle< T > &objH)
Remove the transient representation of the object from memory.
Definition: DbContainer.h:177
pool::IDbContainer
Definition: IDbContainer.h:46
pool::DbObjectHandle::ptr
const T * ptr() const
Access to underlying object.
Definition: DbHandleBase.h:65
pool::DbObjectHandle
Definition: DbHeap.h:26
pool::DbContainer::loadNext
DbStatus loadNext(DbObjectHandle< T > &objH, Token::OID_t &linkH, const DbTypeInfo *typ)
Load object in the container identified by its handle.
Definition: DbContainer.h:189
pool::DbContainer::getOption
DbStatus getOption(DbOption &refOpt)
Access options.
pool::DbContainer::objectShape
const DbTypeInfo * objectShape(const Guid &nam)
Retrieve persistent type information by name.
pool::DbContainer::operator=
DbContainer & operator=(const int)
Assignment operator to reset the handle easily using 0.
Definition: DbContainer.h:85
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
pool::DbContainer::_save
DbStatus _save(DbObjectHandle< DbObject > &objH, const DbTypeInfo *typ)
Internal add of an object entry identified by its handle.
pool::DbContainerObj
Definition: DbContainerObj.h:50
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Token::OID_t
Definition: Token.h:24
pool::ShapeH
const class Shape * ShapeH
Definition: DbContainerObj.h:27
pool::DbContainer::DbContainer
DbContainer(DbContainerObj *ptr)
Constructor taking transient object.
Definition: DbContainer.h:73
pool::DbContainer::size
uint64_t size()
Access to the size of the container.
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
pool::DbContainer::isOpen
bool isOpen() const
Check if the container was opened.
pool::DbHandleBase< DbContainerObj >::ptr
const DbContainerObj * ptr() const
Access to underlying object.
Definition: DbHandleBase.h:65
pool::DbType
Definition: DbType.h:30
pool::DbContainer::allocate
DbStatus allocate(const void *object, ShapeH shape, Token::OID_t &oid)
Access objects using pointer and shape.
pool::DbOption
Definition: DbOption.h:36
sel
sel
Definition: SUSYToolsTester.cxx:92
pool::DbContainer::_loadNext
DbStatus _loadNext(DbObjectHandle< DbObject > &objH, Token::OID_t &linkH, const DbTypeInfo *typ)
Load next object in the container identified by its link handle.
pool::DbContainer::containedIn
DbDatabase & containedIn()
Access to the Database the container resides in.
pool::DbContainer::fetch
DbStatus fetch(DbSelect &sel)
Fetch next object address of the selection to set token.
pool::DbSelect
Definition: DbSelect.h:43
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
pool::DbContainer::info
IDbContainer * info()
pool::DbContainer::refCount
int refCount() const
Access reference counter.
pool::DbContainer::save
DbStatus save(const void *object, ShapeH shape, Token::OID_t &linkH)
Save new object in the container and return its handle.
pool::DbContainer::checkAccess
DbStatus checkAccess(DbDatabase &dbH, const std::string &nam, const DbType &dbtyp)
Check if we can access the residing in <file> container for reading with the given type.
pool::DbContainer::_remove
DbStatus _remove(DbObjectHandle< DbObject > &objH)
Remove the transient representation of the object from memory.
pool::Transaction::Action
Action
Definition: Transaction.h:34
pool::DbContainer::~DbContainer
virtual ~DbContainer()
Standard Destructor.
Definition: DbContainer.h:75
pool::DbContainer::open
DbStatus open(DbDatabase &dbH, const std::string &nam, const DbTypeInfo *typ, const DbType &dbtyp, DbAccessMode mod)
Open the container residing in <file> with given name and access mode.
pool::DbContainer
Definition: DbContainer.h:48
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:25
DbObjectHandle.h
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
pool::DbHandleBase
Definition: DbHandleBase.h:31
pool::DbContainer::DbContainer
DbContainer(const DbContainer &c)
Copy constructor.
Definition: DbContainer.h:71
pool::DbContainer::name
const std::string & name() const
Name of the container the handle is supposed to point to.
calibdata.copy
bool copy
Definition: calibdata.py:26
pool::DbHandleBase< DbContainerObj >::m_type
DbType m_type
Data member: Technology type. Sub-classes need access on re-assignment.
Definition: DbHandleBase.h:40
python.PyAthena.obj
obj
Definition: PyAthena.py:132
pool::DbDatabase
Definition: DbDatabase.h:53
pool::DbContainer::load
DbStatus load(void **ptr, ShapeH shape, const Token::OID_t &lH)
Select object in the container identified by its handle.
pool::DbContainer::free
DbStatus free(void *ptr)
In place free of raw memory.
Token.h
This file contains the class definition for the Token class (migrated from POOL).
pool::DbContainer::_load
DbStatus _load(DbObjectHandle< DbObject > &objH, const Token::OID_t &linkH, const DbTypeInfo *typ, bool any_next)
Load object in the container identified by its link handle.
pool::DbContainer::openMode
DbAccessMode openMode() const
Mode of the handle (READ,WRITE,...)
python.compressB64.c
def c
Definition: compressB64.py:93
pool::DbTypeInfo
Definition: DbTypeInfo.h:47
pool::DbContainer::transAct
DbStatus transAct(Transaction::Action action)
Execute Database Transaction Action.