| The Gaudi Framework v30r0 (c919700c)

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