Skip to content
Snippets Groups Projects
Commit 71ca656c authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'cdvPut.StoreGate-20171029' into 'master'

StoreGate: Add WriteHandle<T>::put taking ConstDataVector<T>.

See merge request !5925
parents 6fd02be1 8b66fa96
No related merge requests found
......@@ -24,6 +24,9 @@
#include <memory> /*unique_ptr*/
template <class DV> class ConstDataVector;
namespace SG {
......@@ -294,6 +297,24 @@ public:
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 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<const ConstDataVector<T> > data,
bool returnExisting = false) const;
/**
* @brief Record an object to the store.
* @param ctx The event context to use.
......
......@@ -382,6 +382,32 @@ WriteHandle<T>::put (std::unique_ptr<const 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 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<const ConstDataVector<T> > data,
bool returnExisting /*= false*/) const
{
IProxyDict* store = nullptr;
std::unique_ptr<const T> coll (data.release()->asDataVector());
return doPut (nullptr, std::move(coll), returnExisting, store);
}
/**
* @brief Record an object to the store.
* @param ctx The event context to use.
......
......@@ -23,6 +23,7 @@
#include "TestTools/expect_exception.h"
#include "AthContainersInterfaces/IConstAuxStore.h"
#include "AthContainers/DataVector.h"
#include "AthContainers/ConstDataVector.h"
#include "AthenaKernel/errorcheck.h"
#include "AthenaKernel/ExtendedEventContext.h"
#include "CxxUtils/unused.h"
......@@ -548,6 +549,12 @@ void test9()
const DataVector<MyObj>* vo =
h7.put (std::make_unique<const DataVector<MyObj> >());
assert (vo->empty());
SG::WriteHandle<DataVector<MyObj> > h8 ("foo8");
assert (h8.setProxyDict (&testStore).isSuccess());
const DataVector<MyObj>* vco =
h8.put (std::make_unique<ConstDataVector<DataVector<MyObj> > >());
assert (vco->empty());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment