Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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/IProperty.h"
11 #include "GaudiKernel/SmartIF.h"
12 
13 //---------------------------------------------------------------------------
14 
24 //---------------------------------------------------------------------------
25 
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  auto p = owner->declareProperty( std::move( name ), *this, std::move( doc ) );
44  p->template setOwnerType<OWNER>();
45  }
46 
47  std::string toString() const;
48  std::string pythonRepr() const override;
49  void fromString( const std::string& s );
50 
51  friend std::ostream& operator<<( std::ostream& str, const DataObjectHandleBase& d );
52 
54 
56  bool isOptional() const { return m_optional; }
57  void setOptional( bool optional = true ) { m_optional = optional; }
58 
59  bool initialized() const { return m_init; }
60  bool wasRead() const { return m_wasRead; }
61  bool wasWritten() const { return m_wasWritten; }
62 
63  bool isValid() const;
64 
65 protected:
66  void setRead( bool wasRead = true ) { m_wasRead = wasRead; }
67  void setWritten( bool wasWritten = true ) { m_wasWritten = wasWritten; }
68 
69  bool init() override;
70 
71  DataObject* fetch() const;
72 
73 protected:
76 
77  bool m_init = false;
78  bool m_optional = false;
79  bool m_wasRead = false;
80  bool m_wasWritten = false;
81 
87  mutable bool m_searchDone = false; // TODO: optimize it so that it is std::any_of( objKey, ":" )
88 
94 };
95 
96 //---------------------------------------------------------------------------
97 //---------------------------------------------------------------------------
98 
99 namespace Gaudi {
100  namespace Parsers {
102  }
103  namespace Utils {
105  }
106 } // namespace Gaudi
107 
108 #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...
DataObjectHandleProperty.h GaudiKernel/DataObjectHandleProperty.h.
STL class.
DataObjectHandleBase & operator=(const DataObjectHandleBase &)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
constexpr double m
Definition: SystemOfUnits.h:92
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:82
void fromString(const std::string &s)
T move(T...args)
StatusCode parse(DataObjID &dest, const std::string &src)
Definition: DataObjID.cpp:46
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:312
std::string pythonRepr() const override
DataObject * fetch() const
SmartIF< IMessageSvc > m_MS
bool isOptional() const
Check if the data object declared is optional for the algorithm.
#define GAUDI_API
Definition: Kernel.h:71
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:40
DataObjectHandleBase(const DataObjID &k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)