Skip to content

Commit

Permalink
Transparently switch to optional return type for MetaDataHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed May 23, 2024
1 parent 6a19c8c commit 976edef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions k4FWCore/include/k4FWCore/MetaDataHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ template <typename T> class MetaDataHandle {
MetaDataHandle(const Gaudi::DataHandle& handle, const std::string& descriptor, Gaudi::DataHandle::Mode a);
~MetaDataHandle();

const T get() const;
void put(T);
const auto get() const;
void put(T);

private:
std::string fullDescriptor() const;
Expand Down Expand Up @@ -65,7 +65,7 @@ MetaDataHandle<T>::MetaDataHandle(const Gaudi::DataHandle& handle, const std::st
}

//---------------------------------------------------------------------------
template <typename T> const T MetaDataHandle<T>::get() const {
template <typename T> const auto MetaDataHandle<T>::get() const {
const auto& frame = m_podio_data_service->getMetaDataFrame();
return frame.getParameter<T>(fullDescriptor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "k4FWCoreTest_cellID_reader.h"
#include "k4FWCoreTest_cellID_writer.h"

#include "podio/podioVersion.h"

DECLARE_COMPONENT(k4FWCoreTest_cellID_reader)

k4FWCoreTest_cellID_reader::k4FWCoreTest_cellID_reader(const std::string& aName, ISvcLocator* aSvcLoc)
Expand All @@ -41,8 +43,11 @@ StatusCode k4FWCoreTest_cellID_reader::initialize() {
StatusCode k4FWCoreTest_cellID_reader::execute(const EventContext&) const {
const auto simtrackerhits_coll = m_simTrackerHitReaderHandle.get();

auto collID = simtrackerhits_coll->getID();
#if PODIO_BUILD_VERSION > PODIO_VERSION(0, 99, 0)
const auto cellIDstr = m_cellIDHandle.get().value_or("");
#else
const auto cellIDstr = m_cellIDHandle.get();
#endif
if (cellIDstr != cellIDtest) {
error() << "ERROR cellID is: " << cellIDstr << endmsg;
return StatusCode::FAILURE;
Expand Down

0 comments on commit 976edef

Please sign in to comment.