Belle II Software light-2406-ragdoll
BinaryRelationalNode< AVariableManager > Class Template Reference

BooleanNode which has two AbstractExpressionNodes nodes and a ComparisonOperator. More...

#include <CutNodes.h>

Inheritance diagram for BinaryRelationalNode< AVariableManager >:
Collaboration diagram for BinaryRelationalNode< AVariableManager >:

Public Types

typedef AVariableManager::Var Var
 Template argument dependent Variable type definition.
 

Public Member Functions

bool check (const Object *p) const override
 Evaluate the Expression children nodes which yield std::variant values.
 
void print () const override
 Print node.
 
std::string decompile () const override
 Decompile Node back to a string.
 
 ~BinaryRelationalNode ()
 Destructor.
 

Private Types

typedef AVariableManager::Object Object
 Template argument dependent Particle type definition.
 

Private Member Functions

 BinaryRelationalNode (Nodetuple left_node, Nodetuple right_node, ComparisonOperator coperator)
 Constructor.
 

Private Attributes

std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_left_enode
 subexpression of a cut
 
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_right_enode
 subexpression of a cut
 
const ComparisonOperator m_coperator
 comparison operator to be applied to the expression evaluations
 

Friends

class NodeFactory
 

Detailed Description

template<class AVariableManager>
class Belle2::BinaryRelationalNode< AVariableManager >

BooleanNode which has two AbstractExpressionNodes nodes and a ComparisonOperator.

Check() evaluates the children nodes and compares the results with the specified operator.

Definition at line 427 of file CutNodes.h.

Member Typedef Documentation

◆ Object

typedef AVariableManager::Object Object
private

Template argument dependent Particle type definition.

Definition at line 431 of file CutNodes.h.

◆ Var

typedef AVariableManager::Var Var
inherited

Template argument dependent Variable type definition.

Definition at line 39 of file AbstractNodes.h.

Constructor & Destructor Documentation

◆ ~BinaryRelationalNode()

~BinaryRelationalNode ( )
inline

Destructor.

Definition at line 496 of file CutNodes.h.

496{}

◆ BinaryRelationalNode()

BinaryRelationalNode ( Nodetuple  left_node,
Nodetuple  right_node,
ComparisonOperator  coperator 
)
inlineexplicitprivate

Constructor.

Parameters
left_node(const boost::python::tuple&): tuple containing an expression node
right_node(const boost::python::tuple&): tuple containing an expression node
coperator(ComparisonOperator): comparison operator enum value

Definition at line 506 of file CutNodes.h.

507 : m_left_enode{NodeFactory::compile_expression_node<AVariableManager>(left_node)}, m_right_enode{NodeFactory::compile_expression_node<AVariableManager>(right_node)},
508 m_coperator{coperator}
509 {
510 }
const ComparisonOperator m_coperator
comparison operator to be applied to the expression evaluations
Definition: CutNodes.h:513
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_left_enode
subexpression of a cut
Definition: CutNodes.h:511
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_right_enode
subexpression of a cut
Definition: CutNodes.h:512

Member Function Documentation

◆ check()

bool check ( const Object p) const
inlineoverridevirtual

Evaluate the Expression children nodes which yield std::variant values.

variant data types cannot be compared in relational expressions, every data type combination has to be considered.

Parameters
ppointer to the object, that should be checked. returns the boolean result of the relational expression.

Implements AbstractBooleanNode< AVariableManager >.

Definition at line 439 of file CutNodes.h.

440 {
441 // Get std::variant values of children node
442 typename AVariableManager::VarVariant left_eval = m_left_enode->evaluate(p);
443 typename AVariableManager::VarVariant right_eval = m_right_enode->evaluate(p);
444 switch (m_coperator) {
445 case ComparisonOperator::EQUALEQUAL:
446 return std::visit(EqualVisitor{}, left_eval, right_eval);
447 break;
448 case ComparisonOperator::GREATEREQUAL:
449 return std::visit(Visitor<std::greater_equal> {}, left_eval, right_eval);
450 break;
451 case ComparisonOperator::LESSEQUAL:
452 return std::visit(Visitor<std::less_equal> {}, left_eval, right_eval);
453 break;
454 case ComparisonOperator::GREATER:
455 return std::visit(Visitor<std::greater> {}, left_eval, right_eval);
456 break;
457 case ComparisonOperator::LESS:
458 return std::visit(Visitor<std::less> {}, left_eval, right_eval);
459 break;
460
461 case ComparisonOperator::NOTEQUAL:
462 return !std::visit(EqualVisitor{}, left_eval, right_eval);
463 break;
464 default:
465 throw std::runtime_error("BinaryRelationalNode has an invalid ComparisonOperator.");
466 }
467 return false;
468 }

◆ decompile()

std::string decompile ( ) const
inlineoverridevirtual

Decompile Node back to a string.

decompile(compile) should give the same result.

Implements AbstractBooleanNode< AVariableManager >.

Definition at line 483 of file CutNodes.h.

484 {
485 std::stringstream stringstream;
486
487 stringstream << m_left_enode->decompile();
489 stringstream << m_right_enode->decompile();
490
491 return stringstream.str();
492 }
void injectComparisonOperatorToStream(std::ostream &stream, const ComparisonOperator &coperator)
Helper functions for AbstractBooleanNode and AbstractExpressionNode print() and decompile() members S...

◆ print()

void print ( ) const
inlineoverridevirtual

Print node.

Implements AbstractBooleanNode< AVariableManager >.

Definition at line 473 of file CutNodes.h.

474 {
475 m_left_enode->print();
477 m_right_enode->print();
478 }

Friends And Related Function Documentation

◆ NodeFactory

friend class NodeFactory
friend

Definition at line 499 of file CutNodes.h.

Member Data Documentation

◆ m_coperator

const ComparisonOperator m_coperator
private

comparison operator to be applied to the expression evaluations

Definition at line 513 of file CutNodes.h.

◆ m_left_enode

std::unique_ptr<const AbstractExpressionNode<AVariableManager> > m_left_enode
private

subexpression of a cut

Definition at line 511 of file CutNodes.h.

◆ m_right_enode

std::unique_ptr<const AbstractExpressionNode<AVariableManager> > m_right_enode
private

subexpression of a cut

Definition at line 512 of file CutNodes.h.


The documentation for this class was generated from the following file: