Skip to content
Snippets Groups Projects
Commit 20e700c5 authored by Nils Krumnack's avatar Nils Krumnack
Browse files

change handling of const pointers in SysCopyHandle

Essentially I now need to include the const modifier directly in the
template type.  The idea is that this allows future iterations of the
handle to do different things based on whether they will provide read
access or update access.
parent 5c4cb9b2
No related branches found
No related tags found
3 merge requests!59674InDetPerformanceMonitoring with LumiBlock selection,!59383cppcheck in trigger code: Prefer prefix ++/-- operators for non-primitive types.,!59007change handling of const pointers in SysCopyHandle, const-retrieve in OverlapRemovalAlg
......@@ -42,7 +42,7 @@ namespace CP
/// \brief the jet collection we run on
private:
SysCopyHandle<xAOD::JetContainer> m_jetHandle {
SysCopyHandle<const xAOD::JetContainer> m_jetHandle {
this, "jets", "", "the jet collection to run on"};
};
......
......@@ -91,12 +91,6 @@ namespace CP
const CP::SystematicSet& sys) const;
/// \brief const retrieve the object for the given name
public:
::StatusCode getCopy (const T*& object,
const CP::SystematicSet& sys) const;
//
// inherited interface
......
......@@ -100,6 +100,7 @@ namespace CP
if (std::get<1>(cache->second).empty())
{
// if no output name is configured, act like an update handle
// (or read handle if const qualified)
return m_evtStore->retrieve (object, std::get<0>(cache->second));
} else
{
......@@ -111,43 +112,12 @@ namespace CP
if (m_evtStore->retrieve (inputObject, std::get<0>(cache->second)).isFailure())
return StatusCode::FAILURE;
return detail::ShallowCopy<T>::getCopy
(msg(), *m_evtStore, object, inputObject,
std::get<1>(cache->second), std::get<2>(cache->second));
}
}
template<typename T> ::StatusCode SysCopyHandle<T> ::
getCopy (const T*& object, const CP::SystematicSet& sys) const
{
auto cache = m_nameCache.find (sys);
if (cache == m_nameCache.end())
{
if (m_nameCache.empty())
throw std::logic_error ("uninitialized SysCopyHandle (" + m_inputName + ")");
else
throw std::logic_error ("unsupported systematic in SysCopyHandle (" + m_inputName + "): (" + sys.name() + ")");
}
assert (m_evtStore);
if (std::get<1>(cache->second).empty())
{
// if no output name is configured, act like an update handle
return m_evtStore->retrieve (object, std::get<0>(cache->second));
} else
{
// if an output name is configured, retrieve the input object as
// a const object, (shallow) copy it, record the copy and return
// it.
const T *inputObject = nullptr;
if (m_evtStore->retrieve (inputObject, std::get<0>(cache->second)).isFailure())
return StatusCode::FAILURE;
T *tmpObject = nullptr;
if (detail::ShallowCopy<T>::getCopy
(msg(), *m_evtStore, tmpObject, inputObject,
std::get<1>(cache->second), std::get<2>(cache->second)).isFailure())
// using an intermediate, since in the const version we can't
// pass in our argument pointer
std::remove_const_t<T> *tmpObject = nullptr;
if (detail::ShallowCopy<std::remove_const_t<T>>::getCopy
(msg(), *m_evtStore, tmpObject, inputObject,
std::get<1>(cache->second), std::get<2>(cache->second)).isFailure())
return StatusCode::FAILURE;
object = tmpObject;
return StatusCode::SUCCESS;
......
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