The Gaudi Framework  v33r1 (b1225454)
DataHandle.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_DATAHANDLE
12 #define GAUDIKERNEL_DATAHANDLE 1
13 
14 #include "GaudiKernel/DataObjID.h"
15 
16 //---------------------------------------------------------------------------
17 
31 //---------------------------------------------------------------------------
32 
33 class IDataHandleHolder;
34 
35 namespace Gaudi {
36 
37  class DataHandle {
38  public:
39  enum Mode { Reader = 1 << 2, Writer = 1 << 4, Updater = Reader | Writer };
40 
41  DataHandle( const DataObjID& k, Mode a = Reader, IDataHandleHolder* owner = nullptr )
42  : m_key( k ), m_owner( owner ), m_mode( a ){};
43 
44  DataHandle( const DataObjID& k, const bool& isCond, Mode a = Reader, IDataHandleHolder* owner = nullptr )
45  : m_key( k ), m_owner( owner ), m_mode( a ), m_isCond( isCond ){};
46 
47  virtual ~DataHandle() = default;
48 
49  virtual void setOwner( IDataHandleHolder* o ) { m_owner = o; }
50  virtual IDataHandleHolder* owner() const { return m_owner; }
51 
52  virtual Mode mode() const { return m_mode; }
53 
54  virtual void setKey( DataObjID key ) const { m_key = std::move( key ); }
55  virtual void updateKey( std::string key ) const { m_key.updateKey( std::move( key ) ); }
56 
57  virtual const std::string& objKey() const { return m_key.key(); }
58  virtual const DataObjID& fullKey() const { return m_key; }
59 
60  virtual void reset( bool ){};
61 
62  virtual std::string pythonRepr() const;
63  virtual bool init() { return true; }
64 
65  // is this a ConditionHandle?
66  virtual bool isCondition() const { return m_isCond; }
67 
68  protected:
75  mutable DataObjID m_key = {"NONE"};
77 
78  private:
80  bool m_isCond = false;
81  };
82 } // namespace Gaudi
83 
84 #endif
virtual Mode mode() const
Definition: DataHandle.h:52
virtual void reset(bool)
Definition: DataHandle.h:60
DataHandle(const DataObjID &k, const bool &isCond, Mode a=Reader, IDataHandleHolder *owner=nullptr)
Definition: DataHandle.h:44
virtual bool isCondition() const
Definition: DataHandle.h:66
virtual void setOwner(IDataHandleHolder *o)
Definition: DataHandle.h:49
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:50
virtual void updateKey(std::string key) const
Definition: DataHandle.h:55
virtual ~DataHandle()=default
virtual const std::string & objKey() const
Definition: DataHandle.h:57
virtual std::string pythonRepr() const
Definition: DataHandle.cpp:19
STL class.
DataObjID m_key
The key of the object behind this DataHandle Although it may look strange to have it mutable,...
Definition: DataHandle.h:75
virtual const DataObjID & fullKey() const
Definition: DataHandle.h:58
IDataHandleHolder * m_owner
Definition: DataHandle.h:76
T move(T... args)
const std::string & key() const
Definition: DataObjID.h:58
DataHandle(const DataObjID &k, Mode a=Reader, IDataHandleHolder *owner=nullptr)
Definition: DataHandle.h:41
virtual void setKey(DataObjID key) const
Definition: DataHandle.h:54
virtual bool init()
Definition: DataHandle.h:63
void updateKey(std::string key)
Definition: DataObjID.h:103
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1