The Gaudi Framework  v33r1 (b1225454)
DataObjectHandleBase.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 GAUDIHIVE_DATAOBJECTHANDLEBASE_H
12 #define GAUDIHIVE_DATAOBJECTHANDLEBASE_H
13 
14 #include <mutex>
15 
16 #include "GaudiKernel/DataHandle.h"
20 #include "GaudiKernel/IProperty.h"
21 #include "GaudiKernel/SmartIF.h"
22 
23 //---------------------------------------------------------------------------
24 
34 //---------------------------------------------------------------------------
35 
37 
38 public:
41 
42  virtual ~DataObjectHandleBase();
43  DataObjectHandleBase( const DataObjectHandleBase& ) = delete;
46 
49  template <class OWNER, class K, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
50  inline DataObjectHandleBase( OWNER* owner, Gaudi::DataHandle::Mode m, std::string name, const K& key = {},
51  std::string doc = "" )
52  : DataObjectHandleBase( key, m, owner ) {
53  auto p = owner->declareProperty( std::move( name ), *this, std::move( doc ) );
54  p->template setOwnerType<OWNER>();
55  }
56 
57  std::string toString() const;
58  std::string pythonRepr() const override;
59  void fromString( const std::string& s );
60 
61  friend std::ostream& operator<<( std::ostream& str, const DataObjectHandleBase& d );
62 
64 
66  bool isOptional() const { return m_optional; }
67  void setOptional( bool optional = true ) { m_optional = optional; }
68 
69  bool initialized() const { return m_init; }
70  bool wasRead() const { return m_wasRead; }
71  bool wasWritten() const { return m_wasWritten; }
72 
73  bool isValid() const;
74 
75 protected:
76  void setRead( bool wasRead = true ) { m_wasRead = wasRead; }
77  void setWritten( bool wasWritten = true ) { m_wasWritten = wasWritten; }
78 
79  bool init() override;
80 
81  DataObject* fetch() const;
82 
83 protected:
86 
87  bool m_init = false;
88  bool m_optional = false;
89  bool m_wasRead = false;
90  bool m_wasWritten = false;
91 
97  mutable bool m_searchDone = false; // TODO: optimize it so that it is std::any_of( objKey, ":" )
98 
104 
105  static const std::string default_type;
106 };
107 
108 //---------------------------------------------------------------------------
109 //---------------------------------------------------------------------------
110 
111 namespace Gaudi {
112  namespace Parsers {
114  }
115  namespace Utils {
117  }
118 } // namespace Gaudi
119 
120 #endif
void setWritten(bool wasWritten=true)
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:291
static const std::string default_type
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:50
std::string pythonRepr() const override
SmartIF< IDataProviderSvc > m_EDS
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
void setRead(bool wasRead=true)
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:61
constexpr double m
bool isOptional() const
Check if the data object declared is optional for the algorithm.
void fromString(const std::string &s)
T move(T... args)
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
DataObject * fetch() const
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:328
std::string toString() const
SmartIF< IMessageSvc > m_MS
#define GAUDI_API
Definition: Kernel.h:81
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
STL class.
friend std::ostream & operator<<(std::ostream &str, const DataObjectHandleBase &d)
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
DataObjectHandleBase(const DataObjID &k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)