The Gaudi Framework  v30r3 (a5ef0a68)
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 
29 public:
32 
33  virtual ~DataObjectHandleBase();
34  DataObjectHandleBase( const DataObjectHandleBase& ) = delete;
37 
40  template <class OWNER, class K, typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type>
41  inline DataObjectHandleBase( OWNER* owner, Gaudi::DataHandle::Mode m, std::string name, const K& key = {},
42  std::string doc = "" )
43  : DataObjectHandleBase( key, m, owner )
44  {
45  auto p = owner->declareProperty( std::move( name ), *this, std::move( doc ) );
46  p->template setOwnerType<OWNER>();
47  }
48 
49  std::string toString() const;
50  std::string pythonRepr() const override;
51  void fromString( const std::string& s );
52 
53  friend std::ostream& operator<<( std::ostream& str, const DataObjectHandleBase& d );
54 
56 
58  bool isOptional() const { return m_optional; }
59  void setOptional( bool optional = true ) { m_optional = optional; }
60 
61  bool initialized() const { return m_init; }
62  bool wasRead() const { return m_wasRead; }
63  bool wasWritten() const { return m_wasWritten; }
64 
65  bool isValid() const;
66 
67 protected:
68  void setRead( bool wasRead = true ) { m_wasRead = wasRead; }
69  void setWritten( bool wasWritten = true ) { m_wasWritten = wasWritten; }
70 
71  bool init() override;
72 
73  DataObject* fetch() const;
74 
75 protected:
78 
79  bool m_init = false;
80  bool m_optional = false;
81  bool m_wasRead = false;
82  bool m_wasWritten = false;
83 
89  mutable bool m_searchDone = false; // TODO: optimize it so that it is std::any_of( objKey, ":" )
90 
96 };
97 
98 //---------------------------------------------------------------------------
99 //---------------------------------------------------------------------------
100 
101 namespace Gaudi
102 {
103  namespace Parsers
104  {
106  }
107  namespace Utils
108  {
110  }
111 }
112 
113 #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:51
constexpr double m
Definition: SystemOfUnits.h:94
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:92
void fromString(const std::string &s)
T move(T...args)
StatusCode parse(DataObjID &dest, const std::string &src)
Definition: DataObjID.cpp:52
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
SmartIF< IMessageSvc > m_MS
bool isOptional() const
Check if the data object declared is optional for the algorithm.
#define GAUDI_API
Definition: Kernel.h:104
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:42
DataObjectHandleBase(const DataObjID &k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)