Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Framework/Core/include/Framework/DataDescriptorMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class DataDescriptorMatcher
{
public:
enum struct Op { Just,
Not,
Or,
And,
Xor };
Expand Down
16 changes: 15 additions & 1 deletion Framework/Core/src/DataDescriptorMatcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<OriginValueMatcher>(&mLeft)) {
Expand Down Expand Up @@ -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<OriginValueMatcher>(&mRight)) {
auto dh = o2::header::get<header::DataHeader*>(d);
Expand Down Expand Up @@ -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");
};
Expand Down Expand Up @@ -383,7 +390,11 @@ bool DataDescriptorMatcher::operator==(DataDescriptorMatcher const& other) const
}

if (mOp == Op::Just) {
return true;
return leftValue;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when having two matchers with just left condition, the two should should be tested for equality and thus we need to return leftValue.

Actually, leftResult and rightresult would be better naming, shall we apply this?

}

if (mOp == Op::Not) {
return leftValue;
}

{
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 22 additions & 0 deletions Framework/Core/test/test_DataDescriptorMatcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down