The Gaudi Framework  v29r0 (ff2e7097)
DataObjectHandleBase.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_DATAOBJECTHANDLEBASE_H
2 #define GAUDIHIVE_DATAOBJECTHANDLEBASE_H
3 
4 #include <mutex>
5 
10 #include "GaudiKernel/SmartIF.h"
11 
12 //---------------------------------------------------------------------------
13 
23 //---------------------------------------------------------------------------
24 
26 {
27 
28 public:
31 
32  virtual ~DataObjectHandleBase();
33  DataObjectHandleBase( const DataObjectHandleBase& ) = delete;
36 
39  template <class OWNER, class K, typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type>
40  inline DataObjectHandleBase( OWNER* owner, Gaudi::DataHandle::Mode m, std::string name, const K& key = {},
41  std::string doc = "" )
42  : DataObjectHandleBase( key, m, owner )
43  {
44  auto p = owner->declareProperty( std::move( name ), *this, std::move( doc ) );
45  p->template setOwnerType<OWNER>();
46  }
47 
48  std::string toString() const;
49  std::string pythonRepr() const override;
50  void fromString( const std::string& s );
51 
52  friend std::ostream& operator<<( std::ostream& str, const DataObjectHandleBase& d );
53 
55  bool isOptional() const { return m_optional; }
56  void setOptional( bool optional = true ) { m_optional = optional; }
57 
58  bool initialized() const { return m_init; }
59  bool wasRead() const { return m_wasRead; }
60  bool wasWritten() const { return m_wasWritten; }
61 
62  bool isValid() const;
63 
64 protected:
65  void setRead( bool wasRead = true ) { m_wasRead = wasRead; }
66  void setWritten( bool wasWritten = true ) { m_wasWritten = wasWritten; }
67 
68  bool init() override;
69 
70  DataObject* fetch() const;
71 
72 protected:
75 
76  bool m_init = false;
77  bool m_optional = false;
78  bool m_wasRead = false;
79  bool m_wasWritten = false;
80 
86  mutable bool m_searchDone = false; // TODO: optimize it so that it is std::any_of( objKey, ":" )
87 
93 };
94 
95 //---------------------------------------------------------------------------
96 //---------------------------------------------------------------------------
97 
98 namespace Gaudi
99 {
100  namespace Parsers
101  {
103  }
104  namespace Utils
105  {
107  }
108 }
109 
110 #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:28
constexpr double m
Definition: SystemOfUnits.h:94
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:253
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:110
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
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:42
DataObjectHandleBase(const DataObjID &k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)