3 * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration.
6 * @file StoreGate/WriteDecorHandleKey.h
7 * @author Nils Krumnack <Nils.Erik.Krumnack@cern.h>
8 * @author scott snyder <snyder@bnl.gov> (for original version)
9 * @brief Property holding a SG store/key/clid/attr name from which a
10 * WriteDecorHandle is made.
14 #include "AsgDataHandles/DecorKeyHelpers.h"
15 // #include "GaudiKernel/IDataHandleHolder.h"
25 // * @brief Optionally register read dependency of a @c WriteDecorHandleKey.
27 // void registerWriteDecorHandleKey (IDataHandleHolder* owner,
28 // const DataObjID& contHandleKey);
31 // } // namespace detail
36 * @param key The StoreGate key for the object.
37 * @param storeName Name to use for the store, if it's not encoded in sgkey.
39 * The provided key may actually start with the name of the store,
40 * separated by a "+": "MyStore+Obj". If no "+" is present
41 * the store named by @c storeName is used.
44 WriteDecorHandleKey<T>::WriteDecorHandleKey (const std::string& key /*= ""*/) :
45 // const std::string& storeName /*= "StoreGateSvc"*/) :
46 Base (key/*, storeName*/),
47 m_contHandleKey (contKeyFromKey (key)/*, storeName*/)
53 * @brief auto-declaring Property Constructor.
54 * @param owner Owning component.
55 * @param name name of the Property
56 * @param key default StoreGate key for the object.
57 * @param doc Documentation string.
59 * will associate the named Property with this key via declareProperty
61 * The provided key may actually start with the name of the store,
62 * separated by a "+": "MyStore+Obj". If no "+" is present
63 * the store named by @c storeName is used.
66 template <class OWNER, class K>
68 WriteDecorHandleKey<T>::WriteDecorHandleKey( OWNER* owner,
69 const std::string& name,
71 const std::string& doc /*=""*/)
73 m_contHandleKey (contKeyFromKey (key)/*, StoreID::storeName(StoreID::EVENT_STORE) */)
75 owner->declareProperty(name, *this, doc);
80 * @brief Change the key of the object to which we're referring.
81 * @param sgkey The StoreGate key for the object.
83 * The provided key may actually start with the name of the store,
84 * separated by a "+": "MyStore+Obj". If no "+" is present,
85 * the store is not changed.
88 WriteDecorHandleKey<T>&
89 WriteDecorHandleKey<T>::operator= (const std::string& sgkey)
91 m_contHandleKey = contKeyFromKey (sgkey);
92 Base::operator= (sgkey);
98 * @brief Change the key of the object to which we're referring.
99 * @param sgkey The StoreGate key for the object.
101 * The provided key may actually start with the name of the store,
102 * separated by a "+": "MyStore+Obj". If no "+" is present
103 * the store is not changed. A key name that starts with a "+"
104 * is interpreted as a hierarchical key name, not an empty store name.
106 * Returns failure the key string format is bad.
109 StatusCode WriteDecorHandleKey<T>::assign (const std::string& sgkey)
111 if (m_contHandleKey.assign (contKeyFromKey (sgkey)).isFailure())
112 return StatusCode::FAILURE;
113 return Base::assign (sgkey);
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 WriteDecorHandleKey<T>::initialize (bool used /*= true*/)
128 // detail::registerWriteDecorHandleKey (this->owner(), m_contHandleKey.fullKey());
129 if (m_contHandleKey.initialize (used).isFailure())
130 return StatusCode::FAILURE;
131 return Base::initialize (used);
136 * @brief Return the handle key for the container.
139 const ReadHandleKey<T>& WriteDecorHandleKey<T>::contHandleKey() const
141 return m_contHandleKey;
146 // * @brief Return the handle key for the container.
148 // template <class T>
149 // ReadHandleKey<T>& WriteDecorHandleKey<T>::contHandleKey_nc()
151 // return m_contHandleKey;