diff --git a/Framework/Core/CMakeLists.txt b/Framework/Core/CMakeLists.txt index 7ddffda175a0a..8c2d9650776c0 100644 --- a/Framework/Core/CMakeLists.txt +++ b/Framework/Core/CMakeLists.txt @@ -229,7 +229,6 @@ add_executable(o2-test-framework-core test/test_OptionsHelpers.cxx test/test_OverrideLabels.cxx test/test_O2DataModelHelpers.cxx - test/test_PtrHelpers.cxx test/test_RootConfigParamHelpers.cxx test/test_Services.cxx test/test_StringHelpers.cxx diff --git a/Framework/Core/include/Framework/TypeTraits.h b/Framework/Core/include/Framework/TypeTraits.h index 6938b87238903..19ca548835cdd 100644 --- a/Framework/Core/include/Framework/TypeTraits.h +++ b/Framework/Core/include/Framework/TypeTraits.h @@ -164,32 +164,5 @@ struct has_root_setowner< void>> : public std::true_type { }; -/// Helper class to deal with the case we are creating the first instance of a -/// (possibly) shared resource. -/// -/// works for both: -/// -/// std::shared_ptr storage = make_matching(args...); -/// -/// or -/// -/// std::unique_ptr storage = make_matching(args...); -/// -/// Useful to deal with those who cannot make up their mind about ownership. -/// ;-) -template -static std::enable_if_t().unique()) != 0, HOLDER> - make_matching(ARGS&&... args) -{ - return std::make_shared(std::forward(args)...); -} - -template -static std::enable_if_t().get_deleter()) != 0, HOLDER> - make_matching(ARGS&&... args) -{ - return std::make_unique(std::forward(args)...); -} - } // namespace o2::framework #endif // FRAMEWORK_TYPETRAITS_H diff --git a/Framework/Core/src/runDataProcessing.cxx b/Framework/Core/src/runDataProcessing.cxx index 4cec8c63fe856..7d298998d0563 100644 --- a/Framework/Core/src/runDataProcessing.cxx +++ b/Framework/Core/src/runDataProcessing.cxx @@ -1098,10 +1098,7 @@ int doChild(int argc, char** argv, ServiceRegistry& serviceRegistry, serviceRef.registerService(ServiceRegistryHelpers::handleForService(deviceContext.get())); serviceRef.registerService(ServiceRegistryHelpers::handleForService(&driverConfig)); - // The decltype stuff is to be able to compile with both new and old - // FairMQ API (one which uses a shared_ptr, the other one a unique_ptr. - decltype(r.fDevice) device; - device = make_matching(ref, serviceRegistry, processingPolicies); + auto device = std::make_unique(ref, serviceRegistry, processingPolicies); serviceRef.get().setDevice(device.get()); r.fDevice = std::move(device); diff --git a/Framework/Core/test/test_PtrHelpers.cxx b/Framework/Core/test/test_PtrHelpers.cxx deleted file mode 100644 index 01486c9371749..0000000000000 --- a/Framework/Core/test/test_PtrHelpers.cxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#include -#include "Framework/TypeTraits.h" -#include - -/// exclude from doxygen, TODO: we might want to do this on a higher level -/// because of doxygen's autolinking of references, all 'A' are displayed as -/// reference to this struct. -/// @cond -struct Base { - int v; -}; -struct A : public Base { - A(int v_, int va_) : Base{v_}, va{va_} {} - int va; -}; -struct B : public Base { - B(int v_, int vb_) : Base{v_}, vb{vb_} {} - int vb; -}; - -TEST_CASE("MatchingPtrMaker") -{ - - std::shared_ptr s = std::move(o2::framework::make_matching(1, 3)); - std::unique_ptr u = std::move(o2::framework::make_matching(2, 4)); - - REQUIRE(s != nullptr); - REQUIRE(u != nullptr); - REQUIRE(s->v == 1); - REQUIRE(u->v == 2); - REQUIRE(static_cast(s.get())->va == 3); - REQUIRE(static_cast(u.get())->vb == 4); -} -// @endcond