2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
6 * @file AsgDataHandles/ReadDecorHandleKey.icc
7 * @author Nils Krumnack <Nils.Erik.Krumnack@cern.h>
8 * @author scott snyder <snyder@bnl.gov> (for original)
9 * @brief Property holding a SG store/key/clid/attr name from which a
10 * ReadDecorHandle is made.
13 #include <AsgDataHandles/DecorKeyHelpers.h>
21 * @param key The StoreGate key for the object.
22 * @param storeName Name to use for the store, if it's not encoded in sgkey.
24 * The provided key may actually start with the name of the store,
25 * separated by a "+": "MyStore+Obj". If no "+" is present
26 * the store named by @c storeName is used.
30 ReadDecorHandleKey<T>::ReadDecorHandleKey (const std::string& key /*= ""*/)
31 // const std::string& storeName /*= StoreID::storeName(StoreID::EVENT_STORE)*/)
32 // : Base (ClassID_traits<topbase_t>::ID(), key, storeName),
34 m_contHandleKey (contKeyFromKey (key)/*, storeName*/)
40 * @brief auto-declaring Property Constructor.
41 * @param owner Owning component.
42 * @param name name of the Property
43 * @param key default StoreGate key for the object.
44 * @param doc Documentation string.
46 * will associate the named Property with this RHK via declareProperty
48 * The provided key may actually start with the name of the store,
49 * separated by a "+": "MyStore+Obj". If no "+" is present
50 * the store named by @c storeName is used.
53 template <class OWNER, class K>
55 ReadDecorHandleKey<T>::ReadDecorHandleKey( OWNER* owner,
56 const std::string& name,
58 const std::string& doc /*=""*/)
60 m_contHandleKey (contKeyFromKey (key)/*, StoreID::storeName(StoreID::EVENT_STORE) */)
62 owner->declareProperty(name, *this, doc);
67 * @brief Change the key of the object to which we're referring.
68 * @param sgkey The StoreGate key for the object.
70 * The provided key may actually start with the name of the store,
71 * separated by a "+": "MyStore+Obj". If no "+" is present,
72 * the store is not changed.
75 ReadDecorHandleKey<T>&
76 ReadDecorHandleKey<T>::operator= (const std::string& sgkey)
78 m_contHandleKey = contKeyFromKey (sgkey);
79 Base::operator= (sgkey);
85 * @brief Change the key of the object to which we're referring.
86 * @param sgkey The StoreGate key for the object.
88 * The provided key may actually start with the name of the store,
89 * separated by a "+": "MyStore+Obj". If no "+" is present
90 * the store is not changed. A key name that starts with a "+"
91 * is interpreted as a hierarchical key name, not an empty store name.
93 * Returns failure the key string format is bad.
96 StatusCode ReadDecorHandleKey<T>::assign (const std::string& sgkey)
98 if (m_contHandleKey.assign (contKeyFromKey (sgkey)).isFailure())
99 return StatusCode::FAILURE;
100 return Base::assign (sgkey);
105 // * @brief Return the class ID for the referenced object.
107 // * Overridden here to return the CLID for @c T instead of @c topbase_t.
109 // template <class T>
111 // CLID ReadDecorHandleKey<T>::clid() const
113 // return ClassID_traits<T>::ID();
118 * @brief If this object is used as a property, then this should be called
119 * during the initialize phase. It will fail if the requested
120 * StoreGate service cannot be found or if the key is blank.
122 * @param used If false, then this handle is not to be used.
123 * Instead of normal initialization, the key will be cleared.
126 StatusCode ReadDecorHandleKey<T>::initialize (bool used /*= true*/)
128 if (m_contHandleKey.initialize (used).isFailure())
129 return StatusCode::FAILURE;
130 return Base::initialize (used);
135 * @brief Return the handle key for the container.
138 const ReadHandleKey<T>& ReadDecorHandleKey<T>::contHandleKey() const
140 return m_contHandleKey;