From 64dd90cfb914805f3334aa32022581e7a05971b7 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 3 Jan 2025 20:05:56 +0100 Subject: [PATCH 1/2] DPL: use requires rather than enable_if / static_assert --- Framework/Core/include/Framework/ServiceRegistry.h | 9 ++++----- Framework/Core/include/Framework/ServiceRegistryRef.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Framework/Core/include/Framework/ServiceRegistry.h b/Framework/Core/include/Framework/ServiceRegistry.h index e3fa23294ee78..2236562e6da75 100644 --- a/Framework/Core/include/Framework/ServiceRegistry.h +++ b/Framework/Core/include/Framework/ServiceRegistry.h @@ -267,33 +267,32 @@ struct ServiceRegistry { /// @deprecated old API to be substituted with the ServiceHandle one template + requires std::is_base_of_v void registerService(C* service, Salt salt = ServiceRegistry::globalDeviceSalt()) { // This only works for concrete implementations of the type T. // We need type elision as we do not want to know all the services in // advance - static_assert(std::is_base_of::value == true, - "Registered service is not derived from declared interface"); constexpr ServiceTypeHash typeHash{TypeIdHelpers::uniqueId()}; ServiceRegistry::registerService(typeHash, reinterpret_cast(service), K, salt, typeid(C).name()); } /// @deprecated old API to be substituted with the ServiceHandle one template + requires std::is_base_of_v void registerService(C const* service, Salt salt = ServiceRegistry::globalDeviceSalt()) { // This only works for concrete implementations of the type T. // We need type elision as we do not want to know all the services in // advance - static_assert(std::is_base_of::value == true, - "Registered service is not derived from declared interface"); constexpr ServiceTypeHash typeHash{TypeIdHelpers::uniqueId()}; this->registerService(typeHash, reinterpret_cast(const_cast(service)), K, salt, typeid(C).name()); } /// Check if service of type T is currently active. template - std::enable_if_t == false, bool> active(Salt salt) const + requires(std::is_const_v == false) + bool active(Salt salt) const { constexpr ServiceTypeHash typeHash{TypeIdHelpers::uniqueId()}; if (this->getPos(typeHash, GLOBAL_CONTEXT_SALT) != -1) { diff --git a/Framework/Core/include/Framework/ServiceRegistryRef.h b/Framework/Core/include/Framework/ServiceRegistryRef.h index fa791cc8c4643..910d4e726c080 100644 --- a/Framework/Core/include/Framework/ServiceRegistryRef.h +++ b/Framework/Core/include/Framework/ServiceRegistryRef.h @@ -72,7 +72,8 @@ class ServiceRegistryRef /// Check if service of type T is currently active. template - std::enable_if_t == false, bool> active() const + requires(std::is_const_v == false) + [[nodiscard]] bool active() const { return mRegistry.active(mSalt); } From 4d07555bd32fcea68981c6049c6f402e24fb5097 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Sun, 5 Jan 2025 10:00:37 +0100 Subject: [PATCH 2/2] DPL: cleanup ServiceRegistry headers --- Detectors/TPC/workflow/src/tpc-integrate-idc.cxx | 1 + Detectors/TPC/workflow/src/tpc-krypton-clusterer.cxx | 1 + Framework/Core/include/Framework/ServiceRegistry.h | 4 ---- Framework/Core/src/ArrowSupport.cxx | 2 ++ Framework/Core/src/DataProcessingStates.cxx | 1 + Framework/Core/src/WorkflowHelpers.cxx | 1 + Framework/Core/src/runDataProcessing.cxx | 1 + Framework/Core/test/test_ComputingQuotaEvaluator.cxx | 1 + Framework/Core/test/test_DataRelayer.cxx | 1 + Framework/Core/test/test_Services.cxx | 1 + 10 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Detectors/TPC/workflow/src/tpc-integrate-idc.cxx b/Detectors/TPC/workflow/src/tpc-integrate-idc.cxx index cd7e777a293e0..4aae6683f29b0 100644 --- a/Detectors/TPC/workflow/src/tpc-integrate-idc.cxx +++ b/Detectors/TPC/workflow/src/tpc-integrate-idc.cxx @@ -11,6 +11,7 @@ #include #include +#include #include "Algorithm/RangeTokenizer.h" #include "Framework/WorkflowSpec.h" #include "Framework/ConfigParamSpec.h" diff --git a/Detectors/TPC/workflow/src/tpc-krypton-clusterer.cxx b/Detectors/TPC/workflow/src/tpc-krypton-clusterer.cxx index e815a4fc85e3a..d7c1839f94c6b 100644 --- a/Detectors/TPC/workflow/src/tpc-krypton-clusterer.cxx +++ b/Detectors/TPC/workflow/src/tpc-krypton-clusterer.cxx @@ -12,6 +12,7 @@ #include #include #include +#include #include "Algorithm/RangeTokenizer.h" #include "Framework/WorkflowSpec.h" diff --git a/Framework/Core/include/Framework/ServiceRegistry.h b/Framework/Core/include/Framework/ServiceRegistry.h index 2236562e6da75..ebafd466929ff 100644 --- a/Framework/Core/include/Framework/ServiceRegistry.h +++ b/Framework/Core/include/Framework/ServiceRegistry.h @@ -14,17 +14,13 @@ #include "Framework/ThreadSafetyAnalysis.h" #include "Framework/ServiceHandle.h" #include "Framework/ServiceSpec.h" -#include "Framework/ServiceRegistryHelpers.h" #include "Framework/CompilerBuiltins.h" #include "Framework/TypeIdHelpers.h" -#include #include -#include #include #include #include -#include #include #include diff --git a/Framework/Core/src/ArrowSupport.cxx b/Framework/Core/src/ArrowSupport.cxx index 3f9014d8fbe3b..1dcc85c1d4f04 100644 --- a/Framework/Core/src/ArrowSupport.cxx +++ b/Framework/Core/src/ArrowSupport.cxx @@ -31,6 +31,8 @@ #include "WorkflowHelpers.h" #include "Framework/WorkflowSpecNode.h" #include "Framework/AnalysisSupportHelpers.h" +#include "Framework/ServiceRegistryRef.h" +#include "Framework/ServiceRegistryHelpers.h" #include "CommonMessageBackendsHelpers.h" #include diff --git a/Framework/Core/src/DataProcessingStates.cxx b/Framework/Core/src/DataProcessingStates.cxx index 094b83f01d7b4..64be1829d8c97 100644 --- a/Framework/Core/src/DataProcessingStates.cxx +++ b/Framework/Core/src/DataProcessingStates.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include namespace o2::framework diff --git a/Framework/Core/src/WorkflowHelpers.cxx b/Framework/Core/src/WorkflowHelpers.cxx index 3782c48e81c56..597f3d32856c1 100644 --- a/Framework/Core/src/WorkflowHelpers.cxx +++ b/Framework/Core/src/WorkflowHelpers.cxx @@ -27,6 +27,7 @@ #include "Framework/DataTakingContext.h" #include "Framework/DefaultsHelpers.h" #include "Framework/Signpost.h" +#include "Framework/ServiceRegistryHelpers.h" #include "Framework/Variant.h" #include "Headers/DataHeader.h" diff --git a/Framework/Core/src/runDataProcessing.cxx b/Framework/Core/src/runDataProcessing.cxx index 4bfbc3232822a..03b013d266316 100644 --- a/Framework/Core/src/runDataProcessing.cxx +++ b/Framework/Core/src/runDataProcessing.cxx @@ -34,6 +34,7 @@ #include "Framework/DeviceState.h" #include "Framework/DeviceConfig.h" #include "DeviceStateHelpers.h" +#include "Framework/ServiceRegistryHelpers.h" #include "Framework/DevicesManager.h" #include "Framework/DebugGUI.h" #include "Framework/LocalRootFileService.h" diff --git a/Framework/Core/test/test_ComputingQuotaEvaluator.cxx b/Framework/Core/test/test_ComputingQuotaEvaluator.cxx index 92fedcfe78614..cd0d79538e12a 100644 --- a/Framework/Core/test/test_ComputingQuotaEvaluator.cxx +++ b/Framework/Core/test/test_ComputingQuotaEvaluator.cxx @@ -16,6 +16,7 @@ #include "Framework/Logger.h" #include "Framework/TimingHelpers.h" #include "Framework/DataProcessingStats.h" +#include "Framework/ServiceRegistryHelpers.h" #include "uv.h" #pragma GCC diagnostic push diff --git a/Framework/Core/test/test_DataRelayer.cxx b/Framework/Core/test/test_DataRelayer.cxx index 64a1827820638..7d5a3ded88e16 100644 --- a/Framework/Core/test/test_DataRelayer.cxx +++ b/Framework/Core/test/test_DataRelayer.cxx @@ -22,6 +22,7 @@ #include "Framework/TimingHelpers.h" #include "../src/DataRelayerHelpers.h" #include "Framework/DataProcessingHeader.h" +#include "Framework/ServiceRegistryHelpers.h" #include "Framework/WorkflowSpec.h" #include #include diff --git a/Framework/Core/test/test_Services.cxx b/Framework/Core/test/test_Services.cxx index 23092127fb37b..056a3d0d9b6c4 100644 --- a/Framework/Core/test/test_Services.cxx +++ b/Framework/Core/test/test_Services.cxx @@ -14,6 +14,7 @@ #include "Framework/ServiceRegistry.h" #include "Framework/CallbackService.h" #include "Framework/CommonServices.h" +#include "Framework/ServiceRegistryHelpers.h" #include #include #include