From 82d34a258d443d4c1d1ed9cc729913aa0f1d5eaf Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Wed, 16 Sep 2020 10:29:31 +0200 Subject: [PATCH] DPL: add helper to match only description --- Framework/Core/include/Framework/DataSpecUtils.h | 6 ++++++ Framework/Core/src/DataSpecUtils.cxx | 12 ++++++++++++ Framework/Core/test/unittest_DataSpecUtils.cxx | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/Framework/Core/include/Framework/DataSpecUtils.h b/Framework/Core/include/Framework/DataSpecUtils.h index 9ade6382b7e2c..aeeef13ed9b43 100644 --- a/Framework/Core/include/Framework/DataSpecUtils.h +++ b/Framework/Core/include/Framework/DataSpecUtils.h @@ -72,6 +72,12 @@ struct DataSpecUtils { /// @return true if the OutputSpec will match at least the provided @a origin. static bool partialMatch(OutputSpec const& spec, o2::header::DataOrigin const& origin); + /// @return true if the OutputSpec will match at least the provided @a description. + static bool partialMatch(InputSpec const& spec, o2::header::DataDescription const& description); + + /// @return true if the OutputSpec will match at least the provided @a description. + static bool partialMatch(OutputSpec const& spec, o2::header::DataDescription const& description); + template static bool match(const T& spec, const o2::header::DataHeader& header) { diff --git a/Framework/Core/src/DataSpecUtils.cxx b/Framework/Core/src/DataSpecUtils.cxx index 73080bc144e93..8eb02f2629d2a 100644 --- a/Framework/Core/src/DataSpecUtils.cxx +++ b/Framework/Core/src/DataSpecUtils.cxx @@ -265,6 +265,18 @@ bool DataSpecUtils::partialMatch(InputSpec const& input, header::DataOrigin cons return DataSpecUtils::asConcreteOrigin(input) == origin; } +bool DataSpecUtils::partialMatch(InputSpec const& input, header::DataDescription const& description) +{ + auto dataType = DataSpecUtils::asConcreteDataTypeMatcher(input); + return dataType.description == description; +} + +bool DataSpecUtils::partialMatch(OutputSpec const& output, header::DataDescription const& description) +{ + auto dataType = DataSpecUtils::asConcreteDataTypeMatcher(output); + return dataType.description == description; +} + ConcreteDataMatcher DataSpecUtils::asConcreteDataMatcher(InputSpec const& spec) { return std::get(spec.matcher); diff --git a/Framework/Core/test/unittest_DataSpecUtils.cxx b/Framework/Core/test/unittest_DataSpecUtils.cxx index 9a394ba481b35..d1d91ad74ae05 100644 --- a/Framework/Core/test/unittest_DataSpecUtils.cxx +++ b/Framework/Core/test/unittest_DataSpecUtils.cxx @@ -201,6 +201,12 @@ BOOST_AUTO_TEST_CASE(PartialMatching) BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedOutput, header::DataOrigin("FOO")) == false); BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedInput, header::DataOrigin("FOO")) == false); + + BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedOutput, header::DataDescription("TEST")) == false); + BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedInput, header::DataDescription("TSET")) == false); + + BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedOutput, header::DataDescription("FOOO")) == true); + BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedInput, header::DataDescription("FOOO")) == true); } BOOST_AUTO_TEST_CASE(GetOptionalSubSpecWithMatcher)