ATLAS Offline Software
DbHandleBase.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 // 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 
23  // Forward declarations
24  template <class T> class DbHandleBase;
25 
34  template <class T> class DbHandleBase {
35  protected:
37  typedef T _DataType;
41  T* m_ptr;
44 
48  DbHandleBase() : m_ptr(0), m_type(0) { }
50  void setType(const DbType& typ) { m_type=typ; }
52  void setPtr(T* ptr) { m_ptr=ptr; }
53 
54  public:
56  T* operator->() { return m_ptr; }
57  const T* operator->() const { return m_ptr; }
59  bool operator!() const { return !isValid(); }
61  const T* ptr() const { return m_ptr; }
62  T* ptr() { return m_ptr; }
64  bool isValid() const { return 0 != m_ptr; }
66  const DbType& type() const { return m_type; }
67  };
68 } // End namespace pool
69 #endif // POOL_DBHANDLEBASE_H
pool::DbHandleBase::operator->
const T * operator->() const
Definition: DbHandleBase.h:57
pool::DbHandleBase::operator->
T * operator->()
Dereference operator.
Definition: DbHandleBase.h:56
pool
pool namespace
Definition: libname.h:15
pool::DbHandleBase::operator!
bool operator!() const
Validity check through operator NOT.
Definition: DbHandleBase.h:59
pool::DbHandleBase::ptr
T * ptr()
Definition: DbHandleBase.h:62
DbType.h
pool::DbType::check
void check() const
Check if type is within allowed range.
Definition: DbType.h:87
pool::DbHandleBase::type
const DbType & type() const
Inquire storage type of the handle.
Definition: DbHandleBase.h:66
pool::DbType
Definition: DbType.h:31
pool::DbHandleBase::~DbHandleBase
~DbHandleBase()
Standard destructor.
Definition: DbHandleBase.h:46
pool::DbHandleBase::ptr
const T * ptr() const
Access to underlying object.
Definition: DbHandleBase.h:61
pool::DbHandleBase::m_type
DbType m_type
Data member: Technology type. Sub-classes need access on re-assignment.
Definition: DbHandleBase.h:43
pool::DbHandleBase::setPtr
void setPtr(T *ptr)
Set data pointer.
Definition: DbHandleBase.h:52
pool::DbHandleBase::setType
void setType(const DbType &typ)
Set handle type.
Definition: DbHandleBase.h:50
pool::DbHandleBase::_DataType
T _DataType
Data type definition.
Definition: DbHandleBase.h:37
pool::DbHandleBase::Base
DbHandleBase< _DataType > Base
Data type definition.
Definition: DbHandleBase.h:39
pool::DbHandleBase::DbHandleBase
DbHandleBase()
Standard constructor.
Definition: DbHandleBase.h:48
pool::DbHandleBase::m_ptr
T * m_ptr
Data member: Object pointer. Sub-classes need access on re-assignment.
Definition: DbHandleBase.h:41
pool::DbHandleBase::isValid
bool isValid() const
Validity check (Objy like)
Definition: DbHandleBase.h:64
pool::DbHandleBase
Definition: DbHandleBase.h:24