Skip to content

Commit 644e57c

Browse files
authored
DPL: add helper to match only description (#4357)
1 parent 11e00c0 commit 644e57c

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Framework/Core/include/Framework/DataSpecUtils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ struct DataSpecUtils {
7272
/// @return true if the OutputSpec will match at least the provided @a origin.
7373
static bool partialMatch(OutputSpec const& spec, o2::header::DataOrigin const& origin);
7474

75+
/// @return true if the OutputSpec will match at least the provided @a description.
76+
static bool partialMatch(InputSpec const& spec, o2::header::DataDescription const& description);
77+
78+
/// @return true if the OutputSpec will match at least the provided @a description.
79+
static bool partialMatch(OutputSpec const& spec, o2::header::DataDescription const& description);
80+
7581
template <typename T>
7682
static bool match(const T& spec, const o2::header::DataHeader& header)
7783
{

Framework/Core/src/DataSpecUtils.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ bool DataSpecUtils::partialMatch(InputSpec const& input, header::DataOrigin cons
265265
return DataSpecUtils::asConcreteOrigin(input) == origin;
266266
}
267267

268+
bool DataSpecUtils::partialMatch(InputSpec const& input, header::DataDescription const& description)
269+
{
270+
auto dataType = DataSpecUtils::asConcreteDataTypeMatcher(input);
271+
return dataType.description == description;
272+
}
273+
274+
bool DataSpecUtils::partialMatch(OutputSpec const& output, header::DataDescription const& description)
275+
{
276+
auto dataType = DataSpecUtils::asConcreteDataTypeMatcher(output);
277+
return dataType.description == description;
278+
}
279+
268280
ConcreteDataMatcher DataSpecUtils::asConcreteDataMatcher(InputSpec const& spec)
269281
{
270282
return std::get<ConcreteDataMatcher>(spec.matcher);

Framework/Core/test/unittest_DataSpecUtils.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ BOOST_AUTO_TEST_CASE(PartialMatching)
201201

202202
BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedOutput, header::DataOrigin("FOO")) == false);
203203
BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedInput, header::DataOrigin("FOO")) == false);
204+
205+
BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedOutput, header::DataDescription("TEST")) == false);
206+
BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedInput, header::DataDescription("TSET")) == false);
207+
208+
BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedOutput, header::DataDescription("FOOO")) == true);
209+
BOOST_CHECK(DataSpecUtils::partialMatch(fullySpecifiedInput, header::DataDescription("FOOO")) == true);
204210
}
205211

206212
BOOST_AUTO_TEST_CASE(GetOptionalSubSpecWithMatcher)

0 commit comments

Comments
 (0)