ATLAS Offline Software
DbContainerImp.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //====================================================================
6 //
7 // Package : StorageSvc (The POOL project)
8 //
9 // @author M.Frank
10 //====================================================================
11 #ifndef POOL_DBCONTAINERIMP_H
12 #define POOL_DBCONTAINERIMP_H 1
13 
16 #include "StorageSvc/DbObject.h"
18 
19 // STL include files
20 #include <map>
21 #include <vector>
22 #include <utility>
23 
24 /*
25  * POOL namespace declaration
26  */
27 namespace pool {
28 
29  // Forward declarations
30  class IDbContainer;
31 
43  class DbContainerImp : virtual public IDbContainer
44  {
45  protected:
46 
48  struct DbAction {
49  const void* object;
50  const Shape* shape;
53 
54  DbAction() : object(nullptr), shape(nullptr), action(NONE) { }
55  DbAction(const void* obj, const Shape* s, const Token::OID_t& l, AccessMode a)
56  : object(obj), shape(s), link(l), action(a) { }
57 
58  const void* dataAtOffset(size_t offset) {
59  return static_cast<const char*>(object) + offset;
60  }
61  };
62 
63  typedef std::vector< DbAction > ActionList;
64 
65  private:
69  size_t m_size;
71  size_t m_writeSize;
74  protected:
76  std::string m_name;
81 
83  virtual ~DbContainerImp();
85  int stackType() const
86  { return m_stackType; }
88  size_t stackSize() const
89  { return m_size; }
91  virtual bool updatesPending() const override
92  { return m_size > 0; }
94  ActionList::value_type* stackEntry(size_t which)
95  { return (which <= m_size) ? &(*(m_stack.begin()+which)) : 0; }
97  virtual DbStatus destroyObject(ActionList::value_type& /* entry */)
98  { return Error; }
100  virtual DbStatus updateObject(ActionList::value_type& /* entry */)
101  { return Error; }
103  virtual DbStatus writeObject(ActionList::value_type& /* entry */)
104  { return Error; }
107 
108  public:
111  virtual void release() override { delete this; }
113  virtual uint64_t size() override;
115  virtual std::string name() const override
116  { return m_name; }
118  virtual uint64_t nextRecordId() override;
120  virtual void useNextRecordId(uint64_t) override {};
122  virtual DbStatus close() override;
123 
125 
129  virtual DbStatus getOption(DbOption& opt) override;
130 
132 
136  virtual DbStatus setOption(const DbOption& opt) override;
137 
141  virtual void* allocate( unsigned long siz,
142  DbContainer& cntH,
143  ShapeH shape) override;
145  virtual DbStatus allocate(DbContainer& cntH,
146  const void* object,
147  ShapeH shape,
148  Token::OID_t& oid) override;
150  virtual DbStatus free( void* ptr,
151  DbContainer& cntH) override;
153  virtual DbStatus update(DbSelect& /* sel */) override { return Error; }
155  virtual DbStatus destroy(DbSelect& /* sel */) override { return Error; }
157  virtual DbStatus fetch(DbSelect& sel) override;
159  virtual DbStatus destroy(const Token::OID_t& lnkH) override;
161 
167  virtual DbStatus update(DbContainer& cntH,
168  const void* object,
169  ShapeH shape,
170  const Token::OID_t& linkH) override;
172 
178  virtual DbStatus update(DbContainer& cntH,
179  const void* object,
180  ShapeH shape,
181  const DbObjectHandle<DbObject>& objH) override;
183  virtual DbStatus save( DbObjectHandle<DbObject>& objH) override;
184 
186 
191  virtual DbStatus save(DbContainer& cntH,
192  const void* object,
193  ShapeH shape,
194  Token::OID_t& linkH) override;
195 
197 
206  virtual DbStatus load( void** ptr, ShapeH shape,
207  const Token::OID_t& lnkH,
208  Token::OID_t& oid,
209  bool any_next) override;
211  virtual DbStatus clearStack();
213  virtual DbStatus fetch(const Token::OID_t& linkH, Token::OID_t& stmt);
214 
216 
222  virtual DbStatus loadObject(void** ptr, ShapeH shape, Token::OID_t& oid) = 0;
223 
224  };
225 } // End namespace pool
226 #endif // POOL_DBCONTAINERIMP_H
pool::DbContainerImp::DbAction
List of actions to execute at commit.
Definition: DbContainerImp.h:48
createCoolChannelIdFile.stmt
stmt
Definition: createCoolChannelIdFile.py:42
pool::DbContainerImp::name
virtual std::string name() const override
Get container name.
Definition: DbContainerImp.h:115
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
pool::DbContainerImp::update
virtual DbStatus update(DbContainer &cntH, const void *object, ShapeH shape, const DbObjectHandle< DbObject > &objH) override
Update existing object in the container.
pool::DbStatus
Definition: DbStatus.h:67
pool::DbContainerImp::commitTransaction
virtual DbStatus commitTransaction()
Execute object modification requests during a transaction.
pool::DbContainerImp::clearStack
virtual DbStatus clearStack()
Clear Transaction stack containing transaction requests.
make_coralServer_rep.opt
opt
Definition: make_coralServer_rep.py:19
pool::DbContainerImp::m_size
size_t m_size
Current size of the transaction stack.
Definition: DbContainerImp.h:69
pool::DbContainerImp::fetch
virtual DbStatus fetch(const Token::OID_t &linkH, Token::OID_t &stmt)
Fetch refined object address. Default implementation returns identity.
pool::DbContainerImp::fetch
virtual DbStatus fetch(DbSelect &sel) override
Fetch next object address of the selection to set token.
pool::DbContainerImp::stackSize
size_t stackSize() const
Access stack size.
Definition: DbContainerImp.h:88
pool::DbContainerImp::DbAction::DbAction
DbAction(const void *obj, const Shape *s, const Token::OID_t &l, AccessMode a)
Definition: DbContainerImp.h:55
pool
pool namespace
Definition: libname.h:15
pool::IDbContainer
Definition: IDbContainer.h:47
pool::DbContainerImp::save
virtual DbStatus save(DbObjectHandle< DbObject > &objH) override
Add single entry to container.
pool::DbObjectHandle
Definition: DbContainer.h:37
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
pool::DbContainerImp::free
virtual DbStatus free(void *ptr, DbContainer &cntH) override
In place deletion of raw memory.
pool::DbContainerImp::update
virtual DbStatus update(DbContainer &cntH, const void *object, ShapeH shape, const Token::OID_t &linkH) override
Update existing object in the container.
pool::DbContainerImp::m_name
std::string m_name
Container name.
Definition: DbContainerImp.h:76
pool::DbContainerImp::nextRecordId
virtual uint64_t nextRecordId() override
Number of next record in the container (=size if no delete is allowed)
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
pool::Shape
Definition: Shape.h:35
pool::DbContainerImp::useNextRecordId
virtual void useNextRecordId(uint64_t) override
Suggest next Record ID for tbe next object written - used only with synced indexes.
Definition: DbContainerImp.h:120
pool::DbContainerImp::updateObject
virtual DbStatus updateObject(ActionList::value_type &)
Update persistent object in the container.
Definition: DbContainerImp.h:100
Token::OID_t
Definition: Token.h:24
pool::DbContainerImp::transAct
virtual DbStatus transAct(Transaction::Action) override
Execute Transaction Action.
pool::ShapeH
const class Shape * ShapeH
Definition: DbContainerObj.h:27
pool::DbContainerImp::writeObject
virtual DbStatus writeObject(ActionList::value_type &)
Commit single entry to container.
Definition: DbContainerImp.h:103
pool::DbOption
Definition: DbOption.h:36
pool::DbContainerImp::~DbContainerImp
virtual ~DbContainerImp()
Standard destructor.
sel
sel
Definition: SUSYToolsTester.cxx:97
pool::DbContainerImp::DbAction::action
AccessMode action
Definition: DbContainerImp.h:52
pool::DbSelect
Definition: DbSelect.h:44
pool::DbContainerImp::save
virtual DbStatus save(DbContainer &cntH, const void *object, ShapeH shape, Token::OID_t &linkH) override
Save new object in the container and return its handle.
pool::DbContainerImp::loadObject
virtual DbStatus loadObject(void **ptr, ShapeH shape, Token::OID_t &oid)=0
Find object by object identifier and load it into memory.
pool::DbContainerImp::close
virtual DbStatus close() override
Close the container and deallocate resources.
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
pool::DbContainerImp::setOption
virtual DbStatus setOption(const DbOption &opt) override
Set options.
pool::DbContainerImp::m_canUpdate
bool m_canUpdate
Flag to indicate if object updates are supported.
Definition: DbContainerImp.h:78
pool::AccessMode
AccessMode
Definition of access modes.
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:65
python.Utils.unixtools.which
def which(filename, env=os.environ)
UNIX-style which ---------------------------------------------------------—.
Definition: unixtools.py:39
pool::DbContainerImp::DbAction::link
Token::OID_t link
Definition: DbContainerImp.h:51
DbObject.h
pool::DbContainerImp::ActionList
std::vector< DbAction > ActionList
Definition: DbContainerImp.h:63
pool::DbContainerImp::DbAction::dataAtOffset
const void * dataAtOffset(size_t offset)
Definition: DbContainerImp.h:58
pool::DbContainerImp::updatesPending
virtual bool updatesPending() const override
Query the pending transaction stack.
Definition: DbContainerImp.h:91
pool::NONE
@ NONE
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:66
pool::DbContainerImp::m_stackType
int m_stackType
Accumulated stack entry types.
Definition: DbContainerImp.h:73
pool::DbContainerImp::size
virtual uint64_t size() override
Size of the container.
pool::DbContainerImp::stackEntry
ActionList::value_type * stackEntry(size_t which)
Internal: get access to stack entry.
Definition: DbContainerImp.h:94
pool::Transaction::Action
Action
Definition: Transaction.h:34
pool::DbContainerImp::m_canDestroy
bool m_canDestroy
Flag to indicate if object removals are supported.
Definition: DbContainerImp.h:80
pool::DbContainerImp::m_writeSize
size_t m_writeSize
Number of objects to be written out during open transaction.
Definition: DbContainerImp.h:71
pool::DbContainerImp::allocate
virtual void * allocate(unsigned long siz, DbContainer &cntH, ShapeH shape) override
In place allocation of raw memory for the transient object.
pool::DbContainerImp::destroyObject
virtual DbStatus destroyObject(ActionList::value_type &)
Destroy persistent object in the container; does not touch transient!
Definition: DbContainerImp.h:97
pool::DbContainerImp::getOption
virtual DbStatus getOption(DbOption &opt) override
Access options.
pool::DbContainer
Definition: DbContainer.h:51
a
TList * a
Definition: liststreamerinfos.cxx:10
pool::DbContainerImp::m_stack
ActionList m_stack
Transaction fifo storage for writing.
Definition: DbContainerImp.h:67
pool::DbContainerImp::release
virtual void release() override
Release instance (Abstract interfaces do not expose destructor!)
Definition: DbContainerImp.h:111
pool::DbContainerImp::DbAction::object
const void * object
Definition: DbContainerImp.h:49
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
pool::DbContainerImp::allocate
virtual DbStatus allocate(DbContainer &cntH, const void *object, ShapeH shape, Token::OID_t &oid) override
In place allocation of object location.
pool::DbContainerImp::DbContainerImp
DbContainerImp()
pool::DbContainerImp::stackType
int stackType() const
Access accumulated stack entry types.
Definition: DbContainerImp.h:85
pool::DbContainerImp
Definition: DbContainerImp.h:44
IDbContainer.h
python.PyAthena.obj
obj
Definition: PyAthena.py:132
Token.h
This file contains the class definition for the Token class (migrated from POOL).
pool::DbContainerImp::DbAction::DbAction
DbAction()
Definition: DbContainerImp.h:54
pool::DbContainerImp::load
virtual DbStatus load(void **ptr, ShapeH shape, const Token::OID_t &lnkH, Token::OID_t &oid, bool any_next) override
Find object within the container and load it into memory.
pool::DbContainerImp::destroy
virtual DbStatus destroy(DbSelect &) override
Perform DELETE statement.
Definition: DbContainerImp.h:155
pool::DbContainerImp::destroy
virtual DbStatus destroy(const Token::OID_t &lnkH) override
Add the specified object to the delete stack.
pool::DbContainerImp::update
virtual DbStatus update(DbSelect &) override
Perform UPDATE statement.
Definition: DbContainerImp.h:153
pool::DbContainerImp::DbAction::shape
const Shape * shape
Definition: DbContainerImp.h:50