Belle II Software development
TernaryRelationalNode< AVariableManager > Class Template Reference

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

#include <CutNodes.h>

Inheritance diagram for TernaryRelationalNode< AVariableManager >:
AbstractBooleanNode< AVariableManager >

Public Types

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

Public Member Functions

bool check (const Object *p) const override
 
void print () const override
 Print node.
 
std::string decompile () const override
 Decompile Node back to a string.
 
 ~TernaryRelationalNode ()
 Destructor.
 

Private Types

typedef AbstractBooleanNode< AVariableManager >::Object Object
 Template argument dependent Particle type definition.
 

Private Member Functions

 TernaryRelationalNode (Nodetuple left_node, Nodetuple center_node, Nodetuple right_node, ComparisonOperator lc_coperator, ComparisonOperator cr_coperator)
 Constructor.
 

Private Attributes

std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_left_enode
 left expression of the ternary relational expression
 
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_center_enode
 center expression of the ternary relational expression
 
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_right_enode
 right expression of the ternary relational expression
 
const ComparisonOperator m_lc_coperator
 comparison operator to be applied to the evaluations of the left and center expression
 
const ComparisonOperator m_cr_coperator
 comparison operator to be applied to the evaluations of the center and right expressions
 

Friends

class NodeFactory
 

Detailed Description

template<class AVariableManager>
class Belle2::TernaryRelationalNode< AVariableManager >

BooleanNode which has three AbstractExpressionNodes nodes and two ComparisonOperator.

This allows Ranges in the Cutstring e.g 2.0 < var < 4.3 Check() evaluates the children nodes and compares both sides with the specified operator.

Definition at line 523 of file CutNodes.h.

Member Typedef Documentation

◆ Object

typedef AbstractBooleanNode<AVariableManager>::Object Object
private

Template argument dependent Particle type definition.

Definition at line 527 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

◆ ~TernaryRelationalNode()

~TernaryRelationalNode ( )
inline

Destructor.

Definition at line 616 of file CutNodes.h.

616{}

◆ TernaryRelationalNode()

TernaryRelationalNode ( Nodetuple  left_node,
Nodetuple  center_node,
Nodetuple  right_node,
ComparisonOperator  lc_coperator,
ComparisonOperator  cr_coperator 
)
inlineexplicitprivate

Constructor.

Parameters
left_node(const boost::python::tuple&): tuple containing an expression node
center_node(const boost::python::tuple&): tuple containing an expression node
right_node(const boost::python::tuple&): tuple containing an expression node
lc_coperator(ComparisonOperator): comparison operator enum value specifying the comparison between left and center expression
cr_coperator(ComparisonOperator): comparison operator enum value specifiying the comparison between center and right expression

Definition at line 628 of file CutNodes.h.

630 : m_left_enode{NodeFactory::compile_expression_node<AVariableManager>(left_node)}, m_center_enode{NodeFactory::compile_expression_node<AVariableManager>(center_node)},
631 m_right_enode{NodeFactory::compile_expression_node<AVariableManager>(right_node)}, m_lc_coperator{lc_coperator},
632 m_cr_coperator{cr_coperator}
633 {
634 }
const ComparisonOperator m_cr_coperator
comparison operator to be applied to the evaluations of the center and right expressions
Definition: CutNodes.h:644
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_center_enode
center expression of the ternary relational expression
Definition: CutNodes.h:638
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_left_enode
left expression of the ternary relational expression
Definition: CutNodes.h:636
std::unique_ptr< const AbstractExpressionNode< AVariableManager > > m_right_enode
right expression of the ternary relational expression
Definition: CutNodes.h:640
const ComparisonOperator m_lc_coperator
comparison operator to be applied to the evaluations of the left and center expression
Definition: CutNodes.h:642

Member Function Documentation

◆ check()

bool check ( const Object p) const
inlineoverridevirtual
Parameters
ppointer to the object, that should be checked. Checking is done sequentially. At first the left-center condition is checked. If it evaluates to false we can directly return false. If it true we have to check to center-right condition.

Implements AbstractBooleanNode< AVariableManager >.

Definition at line 535 of file CutNodes.h.

536 {
537 typename AVariableManager::VarVariant left_eval = m_left_enode->evaluate(p);
538 typename AVariableManager::VarVariant center_eval = m_center_enode->evaluate(p);
539 typename AVariableManager::VarVariant right_eval = m_right_enode->evaluate(p);
540
541 switch (m_lc_coperator) {
542 case ComparisonOperator::EQUALEQUAL:
543 if (not std::visit(EqualVisitor {}, left_eval, center_eval)) return false;
544 break;
545 case ComparisonOperator::GREATEREQUAL:
546 if (not std::visit(Visitor<std::greater_equal> {}, left_eval, center_eval)) return false;
547 break;
548 case ComparisonOperator::LESSEQUAL:
549 if (not std::visit(Visitor<std::less_equal> {}, left_eval, center_eval)) return false;
550 break;
551 case ComparisonOperator::GREATER:
552 if (not std::visit(Visitor<std::greater> {}, left_eval, center_eval)) return false;
553 break;
554 case ComparisonOperator::LESS:
555 if (not std::visit(Visitor<std::less> {}, left_eval, center_eval)) return false;
556 break;
557 case ComparisonOperator::NOTEQUAL:
558 if (std::visit(EqualVisitor {}, left_eval, center_eval)) return false;
559 break;
560 default:
561 throw std::runtime_error("TernaryRelational has an invalid m_lc_operator");
562 }
563 switch (m_cr_coperator) {
564 case ComparisonOperator::EQUALEQUAL:
565 if (not std::visit(EqualVisitor {}, center_eval, right_eval)) return false;
566 break;
567 case ComparisonOperator::GREATEREQUAL:
568 if (not std::visit(Visitor<std::greater_equal> {}, center_eval, right_eval)) return false;
569 break;
570 case ComparisonOperator::LESSEQUAL:
571 if (not std::visit(Visitor<std::less_equal> {}, center_eval, right_eval)) return false;
572 break;
573 case ComparisonOperator::GREATER:
574 if (not std::visit(Visitor<std::greater> {}, center_eval, right_eval)) return false;
575 break;
576 case ComparisonOperator::LESS:
577 if (not std::visit(Visitor<std::less> {}, center_eval, right_eval)) return false;
578 break;
579 case ComparisonOperator::NOTEQUAL:
580 if (std::visit(EqualVisitor {}, center_eval, right_eval)) return false;
581 break;
582 default:
583 throw std::runtime_error("TernaryRelational has an invalid m_cr_operator");
584 }
585 return true;
586 }

◆ 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 603 of file CutNodes.h.

604 {
605 std::stringstream stringstream;
606 stringstream << m_left_enode->decompile();
608 stringstream << m_center_enode->decompile();
610 stringstream << m_right_enode->decompile();
611 return stringstream.str();
612 }
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 590 of file CutNodes.h.

591 {
592 m_left_enode->print();
594 m_center_enode->print();
596 m_right_enode->print();
597 }

Friends And Related Function Documentation

◆ NodeFactory

friend class NodeFactory
friend

Definition at line 619 of file CutNodes.h.

Member Data Documentation

◆ m_center_enode

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

center expression of the ternary relational expression

Definition at line 638 of file CutNodes.h.

◆ m_cr_coperator

const ComparisonOperator m_cr_coperator
private

comparison operator to be applied to the evaluations of the center and right expressions

Definition at line 644 of file CutNodes.h.

◆ m_lc_coperator

const ComparisonOperator m_lc_coperator
private

comparison operator to be applied to the evaluations of the left and center expression

Definition at line 642 of file CutNodes.h.

◆ m_left_enode

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

left expression of the ternary relational expression

Definition at line 636 of file CutNodes.h.

◆ m_right_enode

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

right expression of the ternary relational expression

Definition at line 640 of file CutNodes.h.


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