| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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/IDataProviderSvc.h"
8 #include "GaudiKernel/IMessageSvc.h"
9 #include "GaudiKernel/IProperty.h"
10 #include "GaudiKernel/SmartIF.h"
11
12 //---------------------------------------------------------------------------
13
23 //---------------------------------------------------------------------------
24
25 class DataObjectHandleBase : public Gaudi::DataHandle
26 {
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 = 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:
73 SmartIF<IDataProviderSvc> m_EDS;
74 SmartIF<IMessageSvc> m_MS;
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
92 mutable std::mutex m_searchMutex;
93 };
94
95 //---------------------------------------------------------------------------
96 //---------------------------------------------------------------------------
97
98 namespace Gaudi
99 {
100 namespace Parsers
101 {
102 StatusCode parse( DataObjectHandleBase&, const std::string& );
103 }
104 namespace Utils
105 {
106 GAUDI_API std::ostream& toStream( const DataObjectHandleBase& v, std::ostream& o );
107 }
108 }
109
110 #endif
DataObjectHandleBase::DataObjectHandleBase
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.
Definition: DataObjectHandleBase.h:40
DataObjectHandleBase::setWritten
void setWritten(bool wasWritten=true)
Definition: DataObjectHandleBase.h:66
DataObjectHandleBase::~DataObjectHandleBase
virtual ~DataObjectHandleBase()
Definition: DataObjectHandleBase.cpp:61
SmartIF< IDataProviderSvc >
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
DataObjectHandleBase::m_wasRead
bool m_wasRead
Definition: DataObjectHandleBase.h:78
DataObjID
Definition: DataObjID.h:37
DataObjectHandleBase::wasRead
bool wasRead() const
Definition: DataObjectHandleBase.h:59
DataObjectHandleBase::m_EDS
SmartIF< IDataProviderSvc > m_EDS
Definition: DataObjectHandleBase.h:73
DataObjectHandleBase::m_init
bool m_init
Definition: DataObjectHandleBase.h:76
DataObjectHandleBase::wasWritten
bool wasWritten() const
Definition: DataObjectHandleBase.h:60
DataObjectHandleBase::setRead
void setRead(bool wasRead=true)
Definition: DataObjectHandleBase.h:65
DataObjectHandleBase::toString
std::string toString() const
Definition: DataObjectHandleBase.cpp:115
DataObjectHandleBase::setOptional
void setOptional(bool optional=true)
Definition: DataObjectHandleBase.h:56
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:86
std::mutex
DataObjectHandleBase::m_optional
bool m_optional
Definition: DataObjectHandleBase.h:77
std::string
STL class.
DataObjectHandleBase::operator=
DataObjectHandleBase & operator=(const DataObjectHandleBase &)
Definition: DataObjectHandleBase.cpp:30
IDataHandleHolder
Definition: IDataHandleHolder.h:14
IDataProviderSvc.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:94
gaudirun.type
type
Definition: gaudirun.py:133
SmartIF.h
Gaudi::DataHandle
Definition: DataHandle.h:28
IMessageSvc.h
DataObjectHandleBase::fromString
void fromString(const std::string &s)
Definition: DataObjectHandleBase.cpp:121
std::move
T move(T...args)
Gaudi::Parsers::parse
StatusCode parse(DataObjectHandleBase &, const std::string &)
Definition: DataObjectHandleProperty.cpp:14
DataObjectHandleBase::initialized
bool initialized() const
Definition: DataObjectHandleBase.h:58
DataObjectHandleBase::isValid
bool isValid() const
Definition: DataObjectHandleBase.cpp:155
IProperty.h
DataObjectHandleBase
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Definition: DataObjectHandleBase.h:25
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:92
gaudirun.s
string s
Definition: gaudirun.py:253
DataObjectHandleBase::pythonRepr
std::string pythonRepr() const override
Definition: DataObjectHandleBase.cpp:118
DataObjectHandleBase::fetch
DataObject * fetch() const
Definition: DataObjectHandleBase.cpp:64
DataObjectHandleBase::init
bool init() override
Definition: DataObjectHandleBase.cpp:125
Gaudi::Utils::toStream
GAUDI_API std::ostream & toStream(const DataObjectHandleBase &v, std::ostream &o)
Definition: DataObjectHandleProperty.cpp:26
DataObjectHandleBase::m_MS
SmartIF< IMessageSvc > m_MS
Definition: DataObjectHandleBase.h:74
Gaudi::DataHandle::Mode
Mode
Definition: DataHandle.h:31
DataObjectHandleBase::isOptional
bool isOptional() const
Check if the data object declared is optional for the algorithm.
Definition: DataObjectHandleBase.h:55
DataHandle.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
std::ostream
STL class.
DataObjectHandleBase::operator<<
friend std::ostream & operator<<(std::ostream &str, const DataObjectHandleBase &d)
Definition: DataObjectHandleBase.cpp:159
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::DataHandle::owner
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:42
DataObjectHandleBase::DataObjectHandleBase
DataObjectHandleBase(const DataObjID &k, Gaudi::DataHandle::Mode a, IDataHandleHolder *owner)
Definition: DataObjectHandleBase.cpp:47
DataObjectHandleBase::m_wasWritten
bool m_wasWritten
Definition: DataObjectHandleBase.h:79