The Gaudi Framework  master (37c0b60a)
DataHandle.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 
15 #include <GaudiKernel/DataObjID.h>
16 
17 //---------------------------------------------------------------------------
18 
32 //---------------------------------------------------------------------------
33 
34 class IDataHandleHolder;
35 
36 namespace Gaudi {
37 
38  class DataHandle {
39  public:
40  enum Mode { Reader = 1 << 2, Writer = 1 << 4 };
41 
43  : m_key( std::move( k ) ), m_owner( owner ), m_mode( a ) {}
44 
45  DataHandle( DataObjID k, bool isCond, Mode a = Reader, IDataHandleHolder* owner = nullptr )
46  : m_key( std::move( k ) ), m_owner( owner ), m_mode( a ), m_isCond( isCond ) {}
47 
49 
50  virtual ~DataHandle() = default;
51 
52  virtual void setOwner( IDataHandleHolder* o ) { m_owner = o; }
53  virtual IDataHandleHolder* owner() const { return m_owner; }
54 
55  virtual Mode mode() const { return m_mode; }
56 
57  virtual void setKey( DataObjID key ) { m_key = std::move( key ); }
58  virtual void updateKey( std::string key ) { m_key.updateKey( std::move( key ) ); }
59 
60  virtual const std::string& objKey() const { return m_key.key(); }
61  virtual const DataObjID& fullKey() const { return m_key; }
62 
63  virtual void reset( bool ) {}
64 
65  virtual std::string pythonRepr() const;
66  virtual bool init() { return true; }
67 
68  // is this a ConditionHandle?
69  virtual bool isCondition() const { return m_isCond; }
70 
71  friend std::ostream& operator<<( std::ostream& str, const DataHandle& d );
72 
73  protected:
80  DataObjID m_key = { "NONE" };
82 
83  static const std::string default_type;
84 
85  private:
87  bool m_isCond = false;
88  };
89 
90  namespace Parsers {
91  StatusCode parse( DataHandle&, std::string_view );
92  }
93  namespace Utils {
94  GAUDI_API std::ostream& toStream( const DataHandle& v, std::ostream& o );
95  }
96 } // namespace Gaudi
97 
98 #endif
IDataHandleHolder
Definition: IDataHandleHolder.h:24
std::string
STL class.
std::move
T move(T... args)
Gaudi::DataHandle::default_type
static const std::string default_type
Definition: DataHandle.h:83
DataObjID::updateKey
void updateKey(std::string key)
Definition: DataObjID.h:109
Gaudi::DataHandle::m_mode
Mode m_mode
Definition: DataHandle.h:86
DataHandleProperty.h
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition: DODBasicMapper.cpp:21
Gaudi::DataHandle::setOwner
virtual void setOwner(IDataHandleHolder *o)
Definition: DataHandle.h:52
DataHandleProperty
DataHandleProperty.h GaudiKernel/DataHandleProperty.h.
Definition: DataHandleProperty.h:34
Gaudi::DataHandle::reset
virtual void reset(bool)
Definition: DataHandle.h:63
Gaudi::DataHandle
Definition: DataHandle.h:38
Gaudi::DataHandle::setKey
virtual void setKey(DataObjID key)
Definition: DataHandle.h:57
DataObjID.h
Gaudi::DataHandle::Writer
@ Writer
Definition: DataHandle.h:40
StatusCode
Definition: StatusCode.h:65
Gaudi::DataHandle::owner
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:53
Gaudi::DataHandle::DataHandle
DataHandle(DataObjID k, bool isCond, Mode a=Reader, IDataHandleHolder *owner=nullptr)
Definition: DataHandle.h:45
std::ostream
STL class.
Gaudi::DataHandle::objKey
virtual const std::string & objKey() const
Definition: DataHandle.h:60
Gaudi::DataHandle::updateKey
virtual void updateKey(std::string key)
Definition: DataHandle.h:58
Gaudi::DataHandle::m_owner
IDataHandleHolder * m_owner
Definition: DataHandle.h:81
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
DataObjID
Definition: DataObjID.h:47
Gaudi::DataHandle::Mode
Mode
Definition: DataHandle.h:40
Gaudi::DataHandle::~DataHandle
virtual ~DataHandle()=default
Gaudi::DataHandle::m_key
DataObjID m_key
The key of the object behind this DataHandle Although it may look strange to have it mutable,...
Definition: DataHandle.h:80
Gaudi::DataHandle::mode
virtual Mode mode() const
Definition: DataHandle.h:55
std
STL namespace.
Gaudi::Utils::toStream
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition: ToStream.h:299
Gaudi::DataHandle::pythonRepr
virtual std::string pythonRepr() const
Definition: DataHandle.cpp:19
Gaudi::DataHandle::isCondition
virtual bool isCondition() const
Definition: DataHandle.h:69
Properties.v
v
Definition: Properties.py:122
Gaudi::DataHandle::Reader
@ Reader
Definition: DataHandle.h:40
DataObjID::key
const std::string & key() const
only return the last part of the key
Definition: DataObjID.h:60
Gaudi::DataHandle::DataHandle
DataHandle(DataObjID k, Mode a=Reader, IDataHandleHolder *owner=nullptr)
Definition: DataHandle.h:42
Gaudi::DataHandle::fullKey
virtual const DataObjID & fullKey() const
Definition: DataHandle.h:61
ProduceConsume.key
key
Definition: ProduceConsume.py:84
Gaudi::DataHandle::m_isCond
bool m_isCond
Definition: DataHandle.h:87
Gaudi::DataHandle::operator<<
friend std::ostream & operator<<(std::ostream &str, const DataHandle &d)
Definition: DataHandle.cpp:37
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::DataHandle::init
virtual bool init()
Definition: DataHandle.h:66