ATLAS Offline Software
Loading...
Searching...
No Matches
AthCommonDataStore.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5/** @class AthCommonDataStore
6 * @file AthenaBaseComps/AthCommonDataStore.icc
7 * @author Charles Leggett
8 * @date June 2018
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
13 */
14
15#ifndef ATHENABASECOMPS_ATHCOMMONDATASTORE_ICC
16#define ATHENABASECOMPS_ATHCOMMONDATASTORE_ICC
17
18#include "AthenaBaseComps/VHKASupport.h"
19#include "AthenaBaseComps/AthAlgStartVisitor.h"
20
21template <class PBASE>
22void AthCommonDataStore<PBASE>::extraDeps_update_handler( Gaudi::Details::PropertyBase& ExtraDeps )
23 {
24 DataObjIDColl newColl;
25 Gaudi::Property<DataObjIDColl> *prop = dynamic_cast<Gaudi::Property<DataObjIDColl>*> (&ExtraDeps);
26 if ( prop ) {
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 );
31 }
32 if (newColl.size() != 0) prop->setValue( newColl );
33 } else {
34 ATH_MSG_ERROR("unable to dcast ExtraInput/Output Property");
35 }
36 }
37
38/**
39 * @brief Perform system initialization for an algorithm.
40 */
41template <class PBASE>
42StatusCode AthCommonDataStore<PBASE>::sysInitialize() {
43 ATH_CHECK( PBASE::sysInitialize() );
44
45 for ( SG::VarHandleKeyArray* a: m_vhka ) {
46 a->declare( this );
47 }
48
49 m_varHandleArraysDeclared = true;
50
51 return StatusCode::SUCCESS;
52}
53
54/**
55 * @brief Handle START transition.
56 */
57template <class PBASE>
58StatusCode AthCommonDataStore<PBASE>::sysStart() {
59 ATH_CHECK( PBASE::sysStart() );
60
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.)
65
66 AthAlgStartVisitor visitor(this);
67 this->acceptDHVisitor (&visitor);
68
69 return StatusCode::SUCCESS;
70}
71
72/**
73 * @brief Return this algorithm's input handles.
74 */
75template <class PBASE>
76std::vector<Gaudi::DataHandle*> AthCommonDataStore<PBASE>::inputHandles() const
77{
78 std::vector<Gaudi::DataHandle*> v = PBASE::inputHandles();
79
80 if (!m_varHandleArraysDeclared) {
81 VHKASupport::insertInput( m_vhka, v );
82 }
83
84 return v;
85}
86
87/**
88 * @brief Return this algorithm's output handles.
89 */
90template <class PBASE>
91std::vector<Gaudi::DataHandle*> AthCommonDataStore<PBASE>::outputHandles() const
92{
93 std::vector<Gaudi::DataHandle*> v = PBASE::outputHandles();
94
95 if (!m_varHandleArraysDeclared) {
96 VHKASupport::insertOutput( m_vhka, v );
97 }
98
99 return v;
100}
101
102
103#endif