From 8a7fc6fdc927d3ec3e4e270a757d55ba123ff30a Mon Sep 17 00:00:00 2001 From: Nils Krumnack <krumnack@iastate.edu> Date: Thu, 13 Aug 2020 12:24:03 -0500 Subject: [PATCH] add more functionality to data handles --- .../AsgDataHandles/ReadHandleKeyArray.h | 6 +++ .../AsgDataHandles/WriteHandle.h | 32 ++++++------- .../AsgDataHandles/WriteHandle.icc | 48 ++++++++++--------- 3 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/ReadHandleKeyArray.h b/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/ReadHandleKeyArray.h index 8f7ae624f1c8..217824acc2b1 100644 --- a/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/ReadHandleKeyArray.h +++ b/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/ReadHandleKeyArray.h @@ -21,6 +21,12 @@ namespace SG { * @brief class to hold an array of ReadHandleKeys * * See StoreGate/ReadHandleKeyArray for details. + * + * This currently (13 Aug 20) contains a commented out template + * argument that was part of the original handle implementation, but + * has not yet been implemented in the standalone version. The plan + * is to either implement or remove them, depending on what is + * needed in AnalysisBase as we add more packages. */ template <class T> using ReadHandleKeyArray = HandleKeyArray<ReadHandle<T>, ReadHandleKey<T>/*, Gaudi::DataHandle::Reader*/ >; diff --git a/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/WriteHandle.h b/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/WriteHandle.h index 7a3f0d726d47..09cdf8b738dc 100644 --- a/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/WriteHandle.h +++ b/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/WriteHandle.h @@ -231,22 +231,22 @@ public: // StatusCode recordNonConst (SG::DataObjectSharedPtr<T> data); - // /** - // * @brief Record an object to the store. - // * @param data The object to record. - // * @param returnExisting Allow an existing object? - // * - // * Unlike record(), this does not change the handle object. - // * That means that one will not be able to get the object back - // * by dereferencing the handle. - // * Returns the object placed in the store, or nullptr if there - // * was an error. - // * If there was already an object in the store with the given key, - // * then return null, unless @c returnExisting is true, in which case - // * return success. In either case, @c data is destroyed. - // */ - // const_pointer_type put (std::unique_ptr<T> data, - // bool returnExisting = false) const; + /** + * @brief Record an object to the store. + * @param data The object to record. + * @param returnExisting Allow an existing object? + * + * Unlike record(), this does not change the handle object. + * That means that one will not be able to get the object back + * by dereferencing the handle. + * Returns the object placed in the store, or nullptr if there + * was an error. + * If there was already an object in the store with the given key, + * then return null, unless @c returnExisting is true, in which case + * return success. In either case, @c data is destroyed. + */ + const_pointer_type put (std::unique_ptr<T> data/*, + bool returnExisting = false*/) const; // /** diff --git a/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/WriteHandle.icc b/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/WriteHandle.icc index 798c2311c81a..16a98097c0a9 100644 --- a/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/WriteHandle.icc +++ b/Control/AthToolSupport/AsgDataHandles/AsgDataHandles/WriteHandle.icc @@ -336,29 +336,31 @@ WriteHandle<T>::WriteHandle::record (std::unique_ptr<T> data, // } -// /** -// * @brief Record an object to the store. -// * @param data The object to record. -// * @param returnExisting Allow an existing object? -// * -// * Unlike record(), this does not change the handle object. -// * That means that one will not be able to get the object back -// * by dereferencing the handle. -// * Returns the object placed in the store, or nullptr if there -// * was an error. -// * If there was already an object in the store with the given key, -// * then return null, unless @c returnExisting is true, in which case -// * return success. In either case, @c data is destroyed. -// */ -// template <class T> -// inline -// typename WriteHandle<T>::const_pointer_type -// WriteHandle<T>::put (std::unique_ptr<T> data, -// bool returnExisting /*= false*/) const -// { -// IProxyDict* store = nullptr; -// return doPut (nullptr, std::move(data), returnExisting, store); -// } +/** + * @brief Record an object to the store. + * @param data The object to record. + * @param returnExisting Allow an existing object? + * + * Unlike record(), this does not change the handle object. + * That means that one will not be able to get the object back + * by dereferencing the handle. + * Returns the object placed in the store, or nullptr if there + * was an error. + * If there was already an object in the store with the given key, + * then return null, unless @c returnExisting is true, in which case + * return success. In either case, @c data is destroyed. + */ +template <class T> +inline +typename WriteHandle<T>::const_pointer_type +WriteHandle<T>::put (std::unique_ptr<T> data/*, + bool returnExisting / *= false*/) const +{ + const_pointer_type result = data.get(); + if (xAOD::TActiveStore::store()->record (std::move (data), key()).isFailure()) + throw std::runtime_error ("failed to record object: " + key()); + return result; +} // /** -- GitLab