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
17 #include "StorageSvc/DbObject.h"
19 #include "StorageSvc/Transaction.h"
20 
21 #include <cstdint>
22 
23 /*
24  * POOL namespace declaration
25  */
26 namespace pool {
27 
28  // Forward declarations
29  class IOODatabase;
30  class IDbContainer;
31  class DbSelect;
32  class DbDatabase;
33  class DbTypeInfo;
34  class DbContainerObj;
35  class DbTransaction;
36  class DbOption;
37  template <class T> class DbObjectHandle;
38 
39  typedef const class Shape *ShapeH;
40 
51  class DbContainer : public DbHandleBase<DbContainerObj> {
52  private:
57  const Token::OID_t& linkH,
58  const DbTypeInfo* typ,
59  bool any_next);
62  Token::OID_t& linkH,
63  const DbTypeInfo* typ);
66  const DbTypeInfo* typ);
69  const DbTypeInfo* typ);
74 
75  public:
77  DbContainer(const DbType& typ=POOL_StorageType) { m_type=typ; }
79  DbContainer(const DbContainer& c) : Base() { switchPtr(c.m_ptr); }
83  virtual ~DbContainer() { switchPtr(0); }
86  if ( &copy != this ) {
87  m_type = copy.m_type;
88  switchPtr( copy.m_ptr );
89  }
90  return *this;
91  }
93  DbContainer& operator=(const int /* nuller */ ) {
94  switchPtr(0);
95  return *this;
96  }
98  int refCount() const;
100  const std::string& name() const;
110  const IDbContainer* info() const;
113  const DbTypeInfo* objectShape(const Guid& nam);
115  const Token* token() const;
118 
120 
130  const std::string& nam,
131  const DbTypeInfo* typ,
132  const DbType& dbtyp,
133  DbAccessMode mod);
134 
136  bool isOpen() const;
140  DbStatus setOption(const DbOption& refOpt);
143 
159 
163  DbStatus allocate(const void* object, ShapeH shape, Token::OID_t& oid);
166  DbStatus save(const void* object, ShapeH shape, Token::OID_t& linkH);
168  DbStatus update(const void* object, ShapeH shape, const Token::OID_t& linkH);
172  DbStatus load(void** ptr, ShapeH shape, const Token::OID_t& lH);
174 
179  void* allocate(unsigned long siz, const DbTypeInfo* typ);
182  DbStatus free(void* ptr);
184  template <class T> DbStatus remove( const DbObjectHandle<T>& objH)
185  { DbObjectHandle<DbObject> oH(objH.ptr()); return _remove(oH); }
187  template <class T> DbStatus destroy(const DbObjectHandle<T>& objH)
188  { DbObjectHandle<DbObject> oH(objH.ptr()); return _destroy(oH); }
190  template <class T> DbStatus save( DbObjectHandle<T>& objH,
191  const DbTypeInfo* typ)
192  { DbObjectHandle<DbObject> oH(objH.ptr()); return _save(oH, typ); }
194  template <class T> DbStatus update( const DbObjectHandle<T>& objH,
195  const DbTypeInfo* typ)
196  { DbObjectHandle<DbObject> oH(objH.ptr()); return _update(oH, typ); }
198  template <class T> DbStatus load( DbObjectHandle<T>& objH,
199  const Token::OID_t& linkH,
200  const DbTypeInfo* typ)
201  { return _load(objH, linkH, typ, false); }
203  template <class T> DbStatus loadNext(DbObjectHandle<T>& objH,
204  Token::OID_t& linkH,
205  const DbTypeInfo* typ)
206  { return _loadNext(objH, linkH, typ); }
208  };
209 } // End namespace pool
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:47
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)
Perform selection. The statement belongs to the container afterwards.
pool::DbContainer::DbContainer
DbContainer(const DbType &typ=POOL_StorageType)
Constructor with initializing arguments.
Definition: DbContainer.h:77
pool::DbContainer::operator=
DbContainer & operator=(const DbContainer &copy)
Assignment operator.
Definition: DbContainer.h:85
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:190
pool::DbContainer::token
const Token * token() const
Access the token of the container object.
pool::DbContainer::destroy
DbStatus destroy(const DbObjectHandle< T > &objH)
Destroy the persistent representation of the object.
Definition: DbContainer.h:187
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:198
pool::DbContainer::remove
DbStatus remove(const DbObjectHandle< T > &objH)
Remove the transient representation of the object from memory.
Definition: DbContainer.h:184
pool::IDbContainer
Definition: IDbContainer.h:47
pool::DbContainer::destroy
DbStatus destroy(DbSelect &sel)
Access objects through select staements.
pool::DbContainer::_destroy
DbStatus _destroy(DbObjectHandle< DbObject > &objH)
Destroy the persistent representation of the object.
pool::DbObjectHandle
Definition: DbContainer.h:37
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:203
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:93
pool::DbContainer::update
DbStatus update(DbSelect &sel)
Perform UPDATE statement.
pool::Shape
Definition: Shape.h:35
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
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:81
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::DbType
Definition: DbType.h:31
pool::DbHandleBase< DbContainerObj >::ptr
const T * ptr() const
Access to underlying object.
Definition: DbHandleBase.h:61
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::DbContainer::update
DbStatus update(const void *object, ShapeH shape, const Token::OID_t &linkH)
Update an object to the container identified by its handle.
pool::DbSelect
Definition: DbSelect.h:44
pool::DbHandleBase< DbContainerObj >::m_type
DbType m_type
Data member: Technology type. Sub-classes need access on re-assignment.
Definition: DbHandleBase.h:43
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
pool::DbContainer::info
IDbContainer * info()
pool::DbContainer::update
DbStatus update(const DbObjectHandle< T > &objH, const DbTypeInfo *typ)
Update an object to the container identified by its handle.
Definition: DbContainer.h:194
pool::DbContainer::refCount
int refCount() const
Access reference counter.
DbObject.h
pool::DbContainer::destroy
DbStatus destroy(const Token::OID_t &linkH)
Destroy an existing persistent object identified by its handle.
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::_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:83
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:51
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:20
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
DbHandleBase.h
pool::DbHandleBase
Definition: DbHandleBase.h:24
pool::DbContainer::DbContainer
DbContainer(const DbContainer &c)
Copy constructor.
Definition: DbContainer.h:79
pool::DbContainer::_update
DbStatus _update(const DbObjectHandle< DbObject > &handle, const DbTypeInfo *typ)
Add object to the container.
pool::DbContainer::db
IOODatabase * db()
Allow access to the Database implementation.
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:27
python.PyAthena.obj
obj
Definition: PyAthena.py:135
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.
pool::IOODatabase
Definition: IOODatabase.h:50