The Gaudi Framework  v28r3 (cc1cf868)
DataObjectHandleBase.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_DATAOBJECTHANDLEBASE_H
2 #define GAUDIHIVE_DATAOBJECTHANDLEBASE_H
3 
4 #include <mutex>
5 
7 #include "GaudiKernel/SmartIF.h"
10 #include "GaudiKernel/IProperty.h"
11 
12 //---------------------------------------------------------------------------
13 
23 //---------------------------------------------------------------------------
24 
26 
27 public:
28 
32  IDataHandleHolder* owner);
33 
34  virtual ~DataObjectHandleBase();
38 
41  template <class OWNER, class K,
44  std::string name, const K& key = {}, std::string doc = "" )
45  : DataObjectHandleBase( key, m, owner )
46  {
47  auto p = owner->declareProperty( std::move(name), *this, std::move(doc) );
48  p->template setOwnerType<OWNER>();
49  }
50 
51 
52  std::string toString() const;
53  std::string pythonRepr() const override;
54  void fromString(const std::string& s);
55 
57 
59  bool isOptional() const {return m_optional;}
60  void setOptional(bool optional = true) { m_optional = optional; }
61 
62  bool initialized() const { return m_init; }
63  bool wasRead() const { return m_wasRead; }
64  bool wasWritten() const { return m_wasWritten; }
65 
66  bool isValid() const;
67 
68 protected:
69  void setRead(bool wasRead=true) {m_wasRead = wasRead;}
71 
72  bool init() override;
73 
74  DataObject* fetch() const;
75 
76 protected:
77 
80 
81  bool m_init = false;
82  bool m_optional = false;
83  bool m_wasRead = false;
84  bool m_wasWritten = false;
85 
91  mutable bool m_searchDone = false; // TODO: optimize it so that it is std::any_of( objKey, ":" )
92 
98 
99 };
100 
101 //---------------------------------------------------------------------------
102 //---------------------------------------------------------------------------
103 
104 
105 namespace Gaudi {
106  namespace Parsers {
108  }
109  namespace Utils {
111  }
112 }
113 
114 #endif
DataObjectHandleBase(OWNER *owner, Gaudi::DataHandle::Mode m, std::string name, const K &key={}, std::string doc="")
Autodeclaring constructor with property name, mode, key and documentation.
void setWritten(bool wasWritten=true)
SmartIF< IDataProviderSvc > m_EDS
void setRead(bool wasRead=true)
std::string toString() const
void setOptional(bool optional=true)
bool m_searchDone
Whether the search part of the fetch method (so dealing with alt names was already executed or not...
STL class.
DataObjectHandleBase & operator=(const DataObjectHandleBase &)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
constexpr double m
Definition: SystemOfUnits.h:93
void fromString(const std::string &s)
T move(T...args)
StatusCode parse(DataObjectHandleBase &, const std::string &)
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
std::mutex m_searchMutex
A Mutex protecting the calls to the search part of the fetch method, so that we are sure that we only...
string s
Definition: gaudirun.py:245
std::string pythonRepr() const override
DataObject * fetch() const
GAUDI_API std::ostream & toStream(const DataObjectHandleBase &v, std::ostream &o)
SmartIF< IMessageSvc > m_MS
bool isOptional() const
Check if the data object declared is optional for the algorithm.
#define GAUDI_API
Definition: Kernel.h:107
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
STL class.
friend std::ostream & operator<<(std::ostream &str, const DataObjectHandleBase &d)
Helper functions to set/get the application return code.
Definition: __init__.py:1
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:49
DataObjectHandleBase(const DataObjID &k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)