ATLAS Offline Software
DbIter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //====================================================================
6 // DbIter definition
7 //--------------------------------------------------------------------
8 //
9 // Package : StorageSvc (The POOL project)
10 //
11 // Description: Generic persistable object iterator
12 //
13 // @author M.Frank
14 //====================================================================
15 #ifndef POOL_DBITER_H
16 #define POOL_DBITER_H
17 
18 // Framework include files
19 #include "StorageSvc/DbObject.h"
20 #include "StorageSvc/DbContainer.h"
21 #include "StorageSvc/DbTypeInfo.h"
22 
23 // STL include files
24 #include <memory>
25 /*
26  * POOL namespace declaration
27  */
28 namespace pool {
29 
41  template <class T> class DbIter {
52 
53  private:
56  m_mode(c.m_mode) { }
58  bool operator==(const DbIter<T>& iter) const
59  { return m_obj.ptr() == iter.m_obj.ptr(); }
62  m_cnt = copy.m_cnt;
63  m_obj = copy.m_obj;
64  m_mode = copy.m_mode;
65  m_token = copy.m_token;
66  m_type = copy.m_type;
67  return *this;
68  }
69  public:
73  virtual ~DbIter() { }
75  const DbContainer& container() const{ return m_cnt; }
77  bool isValid() const { return m_obj.isValid(); }
79  DbHandle<T>& operator->() { return m_obj; }
81  DbHandle<T>& operator*() { return m_obj; }
83  DbHandle<T>& handle() { return m_obj; }
85  const DbHandle<T>& handle() const { return m_obj; }
87  const T* object() const { return m_obj.ptr(); }
88  T* object() { return m_obj.ptr(); }
90  const Token* token() const { return &m_token; }
92  DbStatus scan(const DbContainer& cntH, const DbTypeInfo* typ);
94  DbStatus next();
95  };
96 
98  template <> class DbIter<DbObject> {};
99 
100 } // End namespace pool
101 
103 template <class T> inline
105  const DbTypeInfo* typ)
106 {
107  if ( cntH.isValid() ) {
108  m_type = typ;
109  m_cnt = cntH;
110  }
111  m_obj = DbHandle<T>(cntH.type());
112 
113  return cntH.isValid()? Success : Error;
114 }
115 
117 template <class T> inline pool::DbStatus pool::DbIter<T>::next()
118 {
119  DbObjectHandle<DbObject> objH(m_obj.ptr());
120  objH._setType(m_obj.type());
121  m_token.oid().second++; // MN: assuming first OID=1?
122  if ( m_cnt.loadNext(objH, m_token.oid(), m_type).isSuccess() ) {
123  m_obj._setObject(static_cast<T*>(objH.ptr()));
124  return Success;
125  }
126  return Error;
127 }
128 
129 #endif // POOL_DBITER_H
pool::DbAccessMode
int DbAccessMode
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:47
pool::DbIter::m_token
Token m_token
Current cursor for the loop.
Definition: DbIter.h:47
pool::DbIter::operator*
DbHandle< T > & operator*()
Dereference operator.
Definition: DbIter.h:81
pool::DbObject
void DbObject
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:35
pool::DbStatus
Definition: DbStatus.h:67
pool::DbIter::token
const Token * token() const
Access to cursor token.
Definition: DbIter.h:90
pool::DbIter::isValid
bool isValid() const
Check validity.
Definition: DbIter.h:77
pool::DbIter::DbIter
DbIter(DbAccessMode mode=pool::READ)
Constructor with initializing arguments.
Definition: DbIter.h:71
pool
pool namespace
Definition: libname.h:15
pool::DbIter::DbIter
DbIter(const DbIter &c)
Copy constructor.
Definition: DbIter.h:55
DbIter< T >
pool::DbIter::handle
const DbHandle< T > & handle() const
Access to current object handle (CONST)
Definition: DbIter.h:85
pool::DbIter
Definition: DbIter.h:41
pool::DbObjectHandle
Definition: DbContainer.h:37
pool::DbIter::m_type
const DbTypeInfo * m_type
Object type used for this scan.
Definition: DbIter.h:49
pool::DbHandle< T >
pool::DbHandleBase::type
const DbType & type() const
Inquire storage type of the handle.
Definition: DbHandleBase.h:66
pool::DbIter::m_obj
DbHandle< T > m_obj
Handle to current object.
Definition: DbIter.h:45
pool::DbIter::operator->
DbHandle< T > & operator->()
Dereference operator.
Definition: DbIter.h:79
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
DbContainer.h
pool::DbObjectHandle::_setType
void _setType(const DbType &type)
Set handle type.
Definition: DbObject.h:103
pool::DbIter::~DbIter
virtual ~DbIter()
Destructor.
Definition: DbIter.h:73
Preparation.mode
mode
Definition: Preparation.py:94
pool::DbIter::object
const T * object() const
Dereference operator.
Definition: DbIter.h:87
DbObject.h
pool::DbIter::object
T * object()
Definition: DbIter.h:88
pool::READ
@ READ
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:68
pool::DbIter::m_mode
DbAccessMode m_mode
Data access type (Default to READ)
Definition: DbIter.h:51
pool::DbObjectHandle::oid
const Token::OID_t & oid() const
Access object oid.
Definition: DbObject.h:215
pool::DbIter::m_cnt
DbContainer m_cnt
Handle to container object.
Definition: DbIter.h:43
pool::DbIter::operator=
DbIter & operator=(const DbIter &copy)
Assignment operator.
Definition: DbIter.h:61
pool::DbContainer
Definition: DbContainer.h:51
pool::DbIter::handle
DbHandle< T > & handle()
Access to current object handle.
Definition: DbIter.h:83
pool::DbHandleBase::isValid
bool isValid() const
Validity check (Objy like)
Definition: DbHandleBase.h:64
pool::DbIter::container
const DbContainer & container() const
Access to container handler.
Definition: DbIter.h:75
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
pool::DbIter::next
DbStatus next()
Retrieve next element.
Definition: DbIter.h:117
calibdata.copy
bool copy
Definition: calibdata.py:27
pool::DbIter::operator==
bool operator==(const DbIter< T > &iter) const
Equality operator.
Definition: DbIter.h:58
python.compressB64.c
def c
Definition: compressB64.py:93
pool::DbIter::scan
DbStatus scan(const DbContainer &cntH, const DbTypeInfo *typ)
Scan the container.
Definition: DbIter.h:104
DbTypeInfo.h
pool::DbTypeInfo
Definition: DbTypeInfo.h:47
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35