2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
5 /** @class AthCommonDataStore
6 * @file AthenaBaseComps/AthCommonDataStore.icc
7 * @author Charles Leggett
9 * @brief Templated class that provides access to Athena event stores
10 * and ability to set data dependencies via Properites.
11 * Implemented to reduce code duplication in AthAlgorithm,
12 * AthAlgTool, and AthReEntrantAlgorithm
15 #ifndef ATHENABASECOMPS_ATHCOMMONDATASTORE_ICC
16 #define ATHENABASECOMPS_ATHCOMMONDATASTORE_ICC
18 #include "AthenaBaseComps/VHKASupport.h"
19 #include "AthenaBaseComps/AthAlgStartVisitor.h"
21 template <class PBASE>
22 void AthCommonDataStore<PBASE>::extraDeps_update_handler( Gaudi::Details::PropertyBase& ExtraDeps )
24 DataObjIDColl newColl;
25 Gaudi::Property<DataObjIDColl> *prop = dynamic_cast<Gaudi::Property<DataObjIDColl>*> (&ExtraDeps);
27 for (auto id : prop->value()) {
28 SG::VarHandleKey vhk(id.clid(), id.key(), Gaudi::DataHandle::Reader);
29 id.updateKey( vhk.objKey() );
30 newColl.emplace( id );
32 if (newColl.size() != 0) prop->setValue( newColl );
34 ATH_MSG_ERROR("unable to dcast ExtraInput/Output Property");
39 * @brief Perform system initialization for an algorithm.
41 template <class PBASE>
42 StatusCode AthCommonDataStore<PBASE>::sysInitialize() {
43 ATH_CHECK( PBASE::sysInitialize() );
45 for ( SG::VarHandleKeyArray* a: m_vhka ) {
49 m_varHandleArraysDeclared = true;
51 return StatusCode::SUCCESS;
55 * @brief Handle START transition.
57 template <class PBASE>
58 StatusCode AthCommonDataStore<PBASE>::sysStart() {
59 ATH_CHECK( PBASE::sysStart() );
61 // Call start() on all input handles.
62 // This allows CondHandleKeys to cache pointers to their conditions containers.
63 // (CondInputLoader makes the containers that it creates during start(),
64 // so initialize() is too early for this.)
66 AthAlgStartVisitor visitor(this);
67 this->acceptDHVisitor (&visitor);
69 return StatusCode::SUCCESS;
73 * @brief Return this algorithm's input handles.
75 template <class PBASE>
76 std::vector<Gaudi::DataHandle*> AthCommonDataStore<PBASE>::inputHandles() const
78 std::vector<Gaudi::DataHandle*> v = PBASE::inputHandles();
80 if (!m_varHandleArraysDeclared) {
81 VHKASupport::insertInput( m_vhka, v );
88 * @brief Return this algorithm's output handles.
90 template <class PBASE>
91 std::vector<Gaudi::DataHandle*> AthCommonDataStore<PBASE>::outputHandles() const
93 std::vector<Gaudi::DataHandle*> v = PBASE::outputHandles();
95 if (!m_varHandleArraysDeclared) {
96 VHKASupport::insertOutput( m_vhka, v );