2 * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration.
5 * @file StoreGate/ShallowCopyDecorDeps.icc
6 * @author scott snyder <snyder@bnl.gov>
8 * @brief Helper to propagate decoration dependencies to a shallow copy.
16 * @brief Auto-declaring Property constructor.
17 * @param owner Owning component.
18 * @param name Name of the Property.
19 * @param l Default list of decorations to propagate.
20 * @param doc Documentation string.
23 template <class OWNER>
24 ShallowCopyDecorDeps<T>::ShallowCopyDecorDeps (OWNER* owner,
25 const std::string& name,
26 std::initializer_list<std::string> l,
27 const std::string& doc /*= ""*/)
28 : m_readKeys (owner, name + "ReadKeys", {}, "[Internal property]"),
29 m_writeKeys (owner, name, l, doc)
35 * @brief Initialize this property. Call this from initialize().
36 * @param origKey Key for the source of the shallow copy.
37 * @param copyKey Key for the result of the shallow copy.
38 * @param used If false, then this handle is not to be used.
39 * Instead of normal initialization, the keys will be cleared.
43 ShallowCopyDecorDeps<T>::initialize (const SG::ReadHandleKey<T>& origKey,
44 const SG::WriteHandleKey<T>& copyKey,
49 for (SG::WriteHandleKey<T>& k : m_writeKeys) {
50 m_readKeys.emplace_back (origKey.key() + '.' + k.key());
51 k = copyKey.key() + '.' + k.key();
53 CHECK( m_readKeys.initialize() );
54 CHECK( m_writeKeys.initialize() );
59 return StatusCode::SUCCESS;
64 * @brief Create alias for the decorations, linked to the shallow copy.
65 * @param origKey Key for the source of the shallow copy.
66 * @param ctx The current EventContext.
68 * Call this after the shallow copy has been recorded in SG.
72 ShallowCopyDecorDeps<T>::linkDecors (const SG::ReadHandleKey<T>& origKey,
73 const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
75 SG::ReadHandle<T> orig (origKey, ctx);
76 for (const SG::WriteHandleKey<T>& k : m_writeKeys) {
77 CHECK( orig.alias (k) );
79 return StatusCode::SUCCESS;