ATLAS Offline Software
DbHandleBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //====================================================================
6 // Pool Handle Base class definitions
7 //--------------------------------------------------------------------
8 //
9 // Package : StorageSvc (The POOL project)
10 // @author M.Frank
11 //====================================================================
12 #ifndef POOL_DBHANDLEBASE_H
13 #define POOL_DBHANDLEBASE_H 1
14 
15 // Framework include files
16 #include "StorageSvc/DbType.h"
17 
18 /*
19  * POOL namespace declaration
20  */
21 namespace pool {
22 
31  template <class T> class DbHandleBase {
32  protected:
34  typedef T _DataType;
38  T* m_ptr;
41 
45  DbHandleBase() : m_ptr(0), m_type(0) { }
46 
47  // Copy/move handled by derived classes.
48  DbHandleBase (const DbHandleBase&) = delete;
49  DbHandleBase (DbHandleBase&&) = delete;
52 
54  void setType(const DbType& typ) { m_type=typ; }
56  void setPtr(T* ptr) { m_ptr=ptr; }
57 
58  public:
60  T* operator->() { return m_ptr; }
61  const T* operator->() const { return m_ptr; }
63  bool operator!() const { return !isValid(); }
65  const T* ptr() const { return m_ptr; }
66  T* ptr() { return m_ptr; }
68  bool isValid() const { return 0 != m_ptr; }
70  const DbType& type() const { return m_type; }
71  };
72 } // End namespace pool
73 #endif // POOL_DBHANDLEBASE_H
pool::DbHandleBase::isValid
bool isValid() const
Validity check (Objy like)
Definition: DbHandleBase.h:68
pool::DbHandleBase::DbHandleBase
DbHandleBase()
Standard constructor.
Definition: DbHandleBase.h:45
pool::DbHandleBase::setPtr
void setPtr(T *ptr)
Set data pointer.
Definition: DbHandleBase.h:56
pool
pool namespace
Definition: libname.h:15
DbType.h
pool::DbType::check
void check() const
Check if type is within allowed range.
Definition: DbType.h:87
pool::DbHandleBase::operator->
const T * operator->() const
Definition: DbHandleBase.h:61
pool::DbHandleBase::m_ptr
T * m_ptr
Data member: Object pointer. Sub-classes need access on re-assignment.
Definition: DbHandleBase.h:38
pool::DbHandleBase::operator=
DbHandleBase & operator=(const DbHandleBase &)=delete
pool::DbHandleBase::operator!
bool operator!() const
Validity check through operator NOT.
Definition: DbHandleBase.h:63
pool::DbHandleBase::ptr
const T * ptr() const
Access to underlying object.
Definition: DbHandleBase.h:65
pool::DbType
Definition: DbType.h:31
pool::DbHandleBase::operator->
T * operator->()
Dereference operator.
Definition: DbHandleBase.h:60
pool::DbHandleBase::Base
DbHandleBase< _DataType > Base
Data type definition.
Definition: DbHandleBase.h:36
pool::DbHandleBase::ptr
T * ptr()
Definition: DbHandleBase.h:66
pool::DbHandleBase::setType
void setType(const DbType &typ)
Set handle type.
Definition: DbHandleBase.h:54
pool::DbHandleBase::type
const DbType & type() const
Inquire storage type of the handle.
Definition: DbHandleBase.h:70
pool::DbHandleBase::DbHandleBase
DbHandleBase(DbHandleBase &&)=delete
pool::DbHandleBase
Definition: DbHandleBase.h:31
pool::DbHandleBase::_DataType
T _DataType
Data type definition.
Definition: DbHandleBase.h:34
pool::DbHandleBase::~DbHandleBase
~DbHandleBase()
Standard destructor.
Definition: DbHandleBase.h:43
pool::DbHandleBase::DbHandleBase
DbHandleBase(const DbHandleBase &)=delete
pool::DbHandleBase::m_type
DbType m_type
Data member: Technology type. Sub-classes need access on re-assignment.
Definition: DbHandleBase.h:40