| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

DataHandleHolderBase.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATAHANDLEHOLDERBASE
2 #define GAUDIKERNEL_DATAHANDLEHOLDERBASE 1
3
4 #include "GaudiKernel/IDataHandleHolder.h"
5 #include "GaudiKernel/DataHandle.h"
6 #include "GaudiKernel/GaudiException.h"
7 #include "GaudiKernel/Property.h"
8
9 #include <unordered_set>
10 #include <algorithm>
11
12 namespace {
13 template <typename Container>
14 std::vector<Gaudi::DataHandle*> handles(Container& c, Gaudi::DataHandle::Mode mode) {
15 std::vector<Gaudi::DataHandle*> h;
16 std::copy_if( std::begin(c), std::end(c),
17 std::back_inserter(h),
18 [&](const Gaudi::DataHandle* hndl) -> bool
19 { return hndl->mode() & mode ; } );
20 return h;
21 }
22 }
23
24 template<class BASE>
25 class GAUDI_API DataHandleHolderBase : public extends<BASE, IDataHandleHolder> {
26 public:
27
28 using extends<BASE, IDataHandleHolder>::extends;
29
30 std::vector<Gaudi::DataHandle*> inputHandles() const override {
31 return handles( m_handles, Gaudi::DataHandle::Reader );
32 }
33 std::vector<Gaudi::DataHandle*> outputHandles() const override {
34 return handles( m_handles, Gaudi::DataHandle::Writer );
35 }
36
37 virtual const DataObjIDColl& extraInputDeps() const override {
38 return m_extInputDataObjs;
39 }
40 virtual const DataObjIDColl& extraOutputDeps() const override {
41 return m_extOutputDataObjs;
42 }
43
44 void declare(Gaudi::DataHandle& handle) override {
45 if (!handle.owner()) handle.setOwner(this);
46
47 if (handle.owner() != this) {
48 throw GaudiException("Attempt to declare foreign handle with algorithm!", this->name(), StatusCode::FAILURE);
49 }
50
51 m_handles.insert(&handle);
52 }
53
54 void renounce(Gaudi::DataHandle& handle) override {
55 if (handle.owner() != this) {
56 throw GaudiException("Attempt to renounce foreign handle with algorithm!", this->name(), StatusCode::FAILURE);
57 }
58 m_handles.erase(&handle);
59
60 }
61
62 const DataObjIDColl& inputDataObjs() const override { return m_inputDataObjs; }
63 const DataObjIDColl& outputDataObjs() const override { return m_outputDataObjs; }
64
65 void addDependency(const DataObjID& id, const Gaudi::DataHandle::Mode& mode) override {
66 if (mode & Gaudi::DataHandle::Reader) m_inputDataObjs.emplace(id);
67 if (mode & Gaudi::DataHandle::Writer) m_outputDataObjs.emplace(id);
68 }
69
70 private:
71
72
73 protected:
74
77 void initDataHandleHolder() {
78 for (auto h : m_handles) h->init();
79 }
80
81 DataObjIDColl m_inputDataObjs, m_outputDataObjs;
82
83 private:
84
85 std::unordered_set<Gaudi::DataHandle*> m_handles;
86
87 Gaudi::Property<DataObjIDColl> m_extInputDataObjs{this, "ExtraInputs", DataObjIDColl{}, "[[deprecated]]"};
88 Gaudi::Property<DataObjIDColl> m_extOutputDataObjs{this, "ExtraOutputs", DataObjIDColl{}, "[[deprecated]]"};
89
90 };
91
92 #endif // !GAUDIKERNEL_DATAHANDLEHOLDERBASE
IDataHandleHolder.h
std::copy_if
T copy_if(T...args)
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
gaudirun.c
c
Definition: gaudirun.py:391
Gaudi::DataHandle::setOwner
virtual void setOwner(IDataHandleHolder *o)
Definition: DataHandle.h:48
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
StatusCode::FAILURE
Definition: StatusCode.h:29
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
DataObjID
Definition: DataObjID.h:38
DataHandleHolderBase::outputDataObjs
const DataObjIDColl & outputDataObjs() const override
Definition: DataHandleHolderBase.h:63
Gaudi::DataHandle::mode
virtual Mode mode() const
Definition: DataHandle.h:51
DataHandleHolderBase::initDataHandleHolder
void initDataHandleHolder()
initializes all handles - called by the sysInitialize method of any descendant of this ...
Definition: DataHandleHolderBase.h:77
DataHandleHolderBase::extraOutputDeps
virtual const DataObjIDColl & extraOutputDeps() const override
Definition: DataHandleHolderBase.h:40
DataHandleHolderBase::renounce
void renounce(Gaudi::DataHandle &handle) override
Definition: DataHandleHolderBase.h:54
std::end
T end(T...args)
Gaudi::DataHandle::Reader
Definition: DataHandle.h:31
DataHandleHolderBase::declare
void declare(Gaudi::DataHandle &handle) override
Definition: DataHandleHolderBase.h:44
DataHandleHolderBase::outputHandles
std::vector< Gaudi::DataHandle * > outputHandles() const override
Definition: DataHandleHolderBase.h:33
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
DataHandleHolderBase::inputDataObjs
const DataObjIDColl & inputDataObjs() const override
Definition: DataHandleHolderBase.h:62
GaudiException.h
DataHandleHolderBase
Definition: DataHandleHolderBase.h:25
DataHandleHolderBase::inputHandles
std::vector< Gaudi::DataHandle * > inputHandles() const override
Definition: DataHandleHolderBase.h:30
Gaudi::DataHandle
Definition: DataHandle.h:27
std::unordered_set< DataObjID, DataObjID_Hasher >
DataHandleHolderBase::addDependency
void addDependency(const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
Definition: DataHandleHolderBase.h:65
std::vector
STL class.
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Property.h
Gaudi::DataHandle::Writer
Definition: DataHandle.h:32
Gaudi::DataHandle::Mode
Mode
Definition: DataHandle.h:30
DataHandle.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
DataHandleHolderBase::extraInputDeps
virtual const DataObjIDColl & extraInputDeps() const override
Definition: DataHandleHolderBase.h:37
DataHandleHolderBase::m_outputDataObjs
DataObjIDColl m_outputDataObjs
Definition: DataHandleHolderBase.h:81
Gaudi::DataHandle::owner
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:49
DataHandleHolderBase::m_handles
std::unordered_set< Gaudi::DataHandle * > m_handles
Definition: DataHandleHolderBase.h:85