diff --git a/k4FWCore/include/k4FWCore/FunctionalUtils.h b/k4FWCore/include/k4FWCore/FunctionalUtils.h index 49f35f4d..0347f83b 100644 --- a/k4FWCore/include/k4FWCore/FunctionalUtils.h +++ b/k4FWCore/include/k4FWCore/FunctionalUtils.h @@ -19,17 +19,18 @@ #ifndef FWCORE_FUNCTIONALUTILS_H #define FWCORE_FUNCTIONALUTILS_H -#include -#include #include "Gaudi/Functional/details.h" +#include "GaudiKernel/AnyDataWrapper.h" #include "GaudiKernel/DataObjID.h" -#include "k4FWCore/DataWrapper.h" -#include "podio/CollectionBase.h" - #include "GaudiKernel/DataObjectHandle.h" #include "GaudiKernel/EventContext.h" +#include "GaudiKernel/IDataProviderSvc.h" #include "GaudiKernel/ThreadLocalContext.h" +#include "podio/CollectionBase.h" + +#include "k4FWCore/DataWrapper.h" + // #include "GaudiKernel/CommonMessaging.h" #include @@ -48,24 +49,27 @@ namespace k4FWCore { }; using EventStoreType_t = typename EventStoreType::type; + // This is used when there is an arbitrary number of collections as input/output template requires(!std::is_same_v) const auto& maybeTransformToEDM4hep(const P& arg) { return arg; } - template - requires(std::is_base_of_v && !std::same_as) - const auto& maybeTransformToEDM4hep(P* arg) { - return *arg; - } - + // This is used by the FilterPredicate template requires std::same_as const auto& maybeTransformToEDM4hep(P&& arg) { return static_cast(*arg); } + // This is used in all the remaining cases + template + requires(std::is_base_of_v && !std::same_as) + const auto& maybeTransformToEDM4hep(P* arg) { + return *arg; + } + template > using addPtrIfColl = std::conditional_t, T>; @@ -91,9 +95,9 @@ namespace k4FWCore { // returned from the algorithm if constexpr (std::same_as) { return std::unique_ptr(std::forward(arg)); + } else { // Most common case, when an algorithm returns a collection and // we want to store a unique_ptr - } else { return std::make_unique(std::forward(arg)); } } @@ -205,6 +209,8 @@ namespace k4FWCore { } // Functional handles + // This is currently used so that the FilterPredicate can be used together with the + // consumer/producer/transformer template class FunctionalDataObjectReadHandle : public ::details::ReadHandle { template FunctionalDataObjectReadHandle(std::tuple&& args, std::index_sequence)