diff --git a/Framework/Core/include/Framework/DataDescriptorMatcher.h b/Framework/Core/include/Framework/DataDescriptorMatcher.h index 9353aabff699c..53313756b9701 100644 --- a/Framework/Core/include/Framework/DataDescriptorMatcher.h +++ b/Framework/Core/include/Framework/DataDescriptorMatcher.h @@ -259,6 +259,7 @@ class DataDescriptorMatcher { public: enum struct Op { Just, + Not, Or, And, Xor }; diff --git a/Framework/Core/src/DataDescriptorMatcher.cxx b/Framework/Core/src/DataDescriptorMatcher.cxx index b7ee5e0f24029..25803946abff3 100644 --- a/Framework/Core/src/DataDescriptorMatcher.cxx +++ b/Framework/Core/src/DataDescriptorMatcher.cxx @@ -243,6 +243,8 @@ bool DataDescriptorMatcher::match(char const* d, VariableContext& context) const // return std::visit(eval, mLeft) ^ std::visit(eval, mRight); // case Op::Just: // return std::visit(eval, mLeft); + // case Op::Not: + // return !std::visit(eval, mLeft); // } // When we drop support for macOS 10.13 if (auto pval0 = std::get_if(&mLeft)) { @@ -287,6 +289,9 @@ bool DataDescriptorMatcher::match(char const* d, VariableContext& context) const if (mOp == Op::Just) { return leftValue; } + if (mOp == Op::Not) { + return !leftValue; + } if (auto pval0 = std::get_if(&mRight)) { auto dh = o2::header::get(d); @@ -317,6 +322,8 @@ bool DataDescriptorMatcher::match(char const* d, VariableContext& context) const return leftValue ^ rightValue; case Op::Just: return leftValue; + case Op::Not: + return !leftValue; } throw runtime_error("Bad parsing tree"); }; @@ -383,7 +390,11 @@ bool DataDescriptorMatcher::operator==(DataDescriptorMatcher const& other) const } if (mOp == Op::Just) { - return true; + return leftValue; + } + + if (mOp == Op::Not) { + return leftValue; } { @@ -479,6 +490,9 @@ std::ostream& operator<<(std::ostream& os, DataDescriptorMatcher::Op const& op) case DataDescriptorMatcher::Op::Just: os << "just"; break; + case DataDescriptorMatcher::Op::Not: + os << "not"; + break; case DataDescriptorMatcher::Op::Xor: os << "xor"; break; diff --git a/Framework/Core/test/test_DataDescriptorMatcher.cxx b/Framework/Core/test/test_DataDescriptorMatcher.cxx index b92cb4d9f5550..dcb9888b35674 100644 --- a/Framework/Core/test/test_DataDescriptorMatcher.cxx +++ b/Framework/Core/test/test_DataDescriptorMatcher.cxx @@ -153,6 +153,28 @@ BOOST_AUTO_TEST_CASE(TestMatcherInvariants) ConstantValueMatcher{true}))}; BOOST_CHECK_EQUAL(matcherA, matcherB); } + + { + DataDescriptorMatcher matcherA{ + DataDescriptorMatcher::Op::Not, + OriginValueMatcher{"TPC"}}; + DataDescriptorMatcher matcherB{ + DataDescriptorMatcher::Op::Not, + DescriptionValueMatcher{"TRACKLET"}}; + DataDescriptorMatcher matcherC{ + DataDescriptorMatcher::Op::Not, + SubSpecificationTypeValueMatcher{1}}; + + BOOST_CHECK(matcherA.match(header0, context) == false); + BOOST_CHECK(matcherA.match(header1, context) == true); + BOOST_CHECK(matcherA.match(header4, context) == true); + BOOST_CHECK(matcherB.match(header0, context) == true); + BOOST_CHECK(matcherB.match(header1, context) == false); + BOOST_CHECK(matcherB.match(header4, context) == false); + BOOST_CHECK(matcherC.match(header0, context) == false); + BOOST_CHECK(matcherC.match(header1, context) == true); + BOOST_CHECK(matcherC.match(header4, context) == true); + } } BOOST_AUTO_TEST_CASE(TestSimpleMatching)