| The Gaudi Framework v32r1 (f65d50dc)

DataObjectHandleBase.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_DATAOBJECTHANDLEBASE_H
2 #define GAUDIHIVE_DATAOBJECTHANDLEBASE_H
3
4 #include <mutex>
5
6 #include "GaudiKernel/DataHandle.h"
7 #include "GaudiKernel/DataObjectHandleProperty.h"
8 #include "GaudiKernel/IDataProviderSvc.h"
9 #include "GaudiKernel/IMessageSvc.h"
10 #include "GaudiKernel/IProperty.h"
11 #include "GaudiKernel/SmartIF.h"
12
13 //---------------------------------------------------------------------------
14
24 //---------------------------------------------------------------------------
25
26 class DataObjectHandleBase : public Gaudi::DataHandle {
27
28 public:
29 DataObjectHandleBase( const DataObjID& k, Gaudi::DataHandle::Mode a, IDataHandleHolder* owner );
30 DataObjectHandleBase( const std::string& k, Gaudi::DataHandle::Mode a, IDataHandleHolder* owner );
31
32 virtual ~DataObjectHandleBase();
33 DataObjectHandleBase( const DataObjectHandleBase& ) = delete;
34 DataObjectHandleBase( DataObjectHandleBase&& );
35 DataObjectHandleBase& operator=( const DataObjectHandleBase& );
36
39 template <class OWNER, class K, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
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
53 using PropertyType = DataObjectHandleProperty;
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:
74 SmartIF<IDataProviderSvc> m_EDS;
75 SmartIF<IMessageSvc> m_MS;
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
93 mutable std::mutex m_searchMutex;
94 };
95
96 //---------------------------------------------------------------------------
97 //---------------------------------------------------------------------------
98
99 namespace Gaudi {
100 namespace Parsers {
101 StatusCode parse( DataObjectHandleBase&, const std::string& );
102 }
103 namespace Utils {
104 GAUDI_API std::ostream& toStream( const DataObjectHandleBase& v, std::ostream& o );
105 }
106 } // namespace Gaudi
107
108 #endif
DataObjectHandleBase::setWritten
void setWritten(bool wasWritten=true)
Definition: DataObjectHandleBase.h:67
DataObjectHandleBase::~DataObjectHandleBase
virtual ~DataObjectHandleBase()
Definition: DataObjectHandleBase.cpp:56
SmartIF< IDataProviderSvc >
DataObjectHandleProperty.h
Gaudi::Utils::toStream
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:284
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
DataObjectHandleBase::m_wasRead
bool m_wasRead
Definition: DataObjectHandleBase.h:79
DataObjID
Definition: DataObjID.h:37
DataObjectHandleBase::wasRead
bool wasRead() const
Definition: DataObjectHandleBase.h:60
Gaudi::DataHandle::owner
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:40
DataObjectHandleBase::pythonRepr
std::string pythonRepr() const override
Definition: DataObjectHandleBase.cpp:112
DataObjectHandleBase::m_EDS
SmartIF< IDataProviderSvc > m_EDS
Definition: DataObjectHandleBase.h:74
DataObjectHandleBase::m_init
bool m_init
Definition: DataObjectHandleBase.h:77
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition: DODBasicMapper.cpp:11
DataObjectHandleBase::setRead
void setRead(bool wasRead=true)
Definition: DataObjectHandleBase.h:66
DataObjectHandleBase::setOptional
void setOptional(bool optional=true)
Definition: DataObjectHandleBase.h:57
DataObjectHandleBase::m_searchDone
bool m_searchDone
Whether the search part of the fetch method (so dealing with alt names was already executed or not.
Definition: DataObjectHandleBase.h:87
std::mutex
DataObjectHandleBase::m_optional
bool m_optional
Definition: DataObjectHandleBase.h:78
DataObjectHandleProperty
DataObjectHandleProperty.h GaudiKernel/DataObjectHandleProperty.h.
Definition: DataObjectHandleProperty.h:23
std::string
STL class.
DataObjectHandleBase::operator=
DataObjectHandleBase & operator=(const DataObjectHandleBase &)
Definition: DataObjectHandleBase.cpp:29
IDataHandleHolder
Definition: IDataHandleHolder.h:14
IDataProviderSvc.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
SmartIF.h
DataObjectHandleBase::isOptional
bool isOptional() const
Check if the data object declared is optional for the algorithm.
Definition: DataObjectHandleBase.h:56
Gaudi::DataHandle
Definition: DataHandle.h:27
IMessageSvc.h
DataObjectHandleBase::fromString
void fromString(const std::string &s)
Definition: DataObjectHandleBase.cpp:129
std::move
T move(T... args)
DataObjectHandleBase::wasWritten
bool wasWritten() const
Definition: DataObjectHandleBase.h:61
IProperty.h
DataObjectHandleBase
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Definition: DataObjectHandleBase.h:26
DataObjectHandleBase::isValid
bool isValid() const
Definition: DataObjectHandleBase.cpp:162
DataObjectHandleBase::initialized
bool initialized() const
Definition: DataObjectHandleBase.h:59
DataObjectHandleBase::fetch
DataObject * fetch() const
Definition: DataObjectHandleBase.cpp:59
DataObjectHandleBase::m_searchMutex
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...
Definition: DataObjectHandleBase.h:93
gaudirun.s
string s
Definition: gaudirun.py:316
DataObjectHandleBase::init
bool init() override
Definition: DataObjectHandleBase.cpp:133
DataObjectHandleBase::toString
std::string toString() const
Definition: DataObjectHandleBase.cpp:109
DataObjectHandleBase::m_MS
SmartIF< IMessageSvc > m_MS
Definition: DataObjectHandleBase.h:75
Gaudi::DataHandle::Mode
Mode
Definition: DataHandle.h:29
DataHandle.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
std::ostream
STL class.
DataObjectHandleBase::operator<<
friend std::ostream & operator<<(std::ostream &str, const DataObjectHandleBase &d)
Definition: DataObjectHandleBase.cpp:166
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
DataObjectHandleBase::DataObjectHandleBase
DataObjectHandleBase(const DataObjID &k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
Definition: DataObjectHandleBase.cpp:45
DataObjectHandleBase::m_wasWritten
bool m_wasWritten
Definition: DataObjectHandleBase.h:80