2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 * @file StoreGate/ReadHandleKey.icc
6 * @author scott snyder <snyder@bnl.gov>
8 * @brief Property holding a SG store/key/clid from which a ReadHandle is made.
17 * @param key The StoreGate key for the object.
18 * @param storeName Name to use for the store, if it's not encoded in sgkey.
20 * The provided key may actually start with the name of the store,
21 * separated by a "+": "MyStore+Obj". If no "+" is present
22 * the store named by @c storeName is used.
25 ReadHandleKey<T>::ReadHandleKey (const std::string& key /*= ""*/,
26 const std::string& storeName /*= "StoreGateSvc"*/)
27 : VarHandleKey (ClassID_traits<T>::ID(), key,
28 Gaudi::DataHandle::Reader,
35 * @brief Change the key of the object to which we're referring.
36 * @param sgkey The StoreGate key for the object.
38 * The provided key may actually start with the name of the store,
39 * separated by a "+": "MyStore+Obj". If no "+" is present,
40 * the store is not changed.
43 ReadHandleKey<T>& ReadHandleKey<T>::operator= (const std::string& sgkey)
45 VarHandleKey::operator= (sgkey);
51 * @brief Auto-declaring Property constructor.
52 * @param owner Owning component.
53 * @param name Name of the Property.
54 * @param key Default StoreGate key for the object.
55 * @param doc Documentation string.
57 * Will associate the named Property with this RHK via declareProperty.
59 * The provided key may actually start with the name of the store,
60 * separated by a "+": "MyStore+Obj". If no "+" is present
61 * the store named by @c storeName is used.
64 template <class OWNER,
65 typename /*= typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type*/>
67 ReadHandleKey<T>::ReadHandleKey( OWNER* owner,
68 const std::string& name,
69 const std::string& key /* ={}*/,
70 const std::string& doc /*= ""*/)
71 : ReadHandleKey<T>( key )
73 auto p = owner->declareProperty(name, *this, doc);
74 p->template setOwnerType<OWNER>();
79 * @brief Constructor with explicit CLID.
80 * @param clid The CLID for the referenced object.
81 * @param key The StoreGate key for the object.
82 * @param storeName Name to use for the store, if it's not encoded in sgkey.
84 * This is meant to be used by @c ReadDecorHandleKey, to allow fixing the
85 * CLID to a base class to avoid scheduler issues.
89 ReadHandleKey<T>::ReadHandleKey (CLID clid,
90 const std::string& key,
91 const std::string& storeName)
92 : VarHandleKey (clid, key, Gaudi::DataHandle::Reader, storeName)
98 * @brief Auto-declaring constructor with explicit CLID.
99 * @param clid The CLID for the referenced object.
100 * @param owner Owning component.
101 * @param name name of the Property
102 * @param key The StoreGate key for the object.
103 * @param doc Documentation string.
105 * This is meant to be used by @c ReadDecorHandleKey, to allow fixing the
106 * CLID to a base class to avoid scheduler issues.
109 template <class OWNER,
110 typename /*= typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type*/>
112 ReadHandleKey<T>::ReadHandleKey( CLID clid,
114 const std::string& name,
115 const std::string& key,
116 const std::string& doc)
117 : ReadHandleKey<T>( clid, key, StoreID::storeName(StoreID::EVENT_STORE) )
119 auto p = owner->declareProperty(name, *this, doc);
120 p->template setOwnerType<OWNER>();
125 * @brief Constructor.
126 * @param key The StoreGate key for the object.
127 * @param storeName Name to use for the store, if it's not encoded in sgkey.
129 * The provided key may actually start with the name of the store,
130 * separated by a "+": "MyStore+Obj". If no "+" is present
131 * the store named by @c storeName is used.
134 InitializedReadHandleKey<T>::InitializedReadHandleKey (const std::string& key /*= ""*/,
135 const std::string& storeName /*= StoreID::storeName(StoreID::EVENT_STORE)*/)
136 : ReadHandleKey<T> (key, storeName)
138 if (this->initialize().isFailure()) {
139 throw SG::ExcBadInitializedReadHandleKey();