Belle II Software  release-08-01-10
ModuleCondition Class Reference

Wraps a condition set on a Module instance. More...

#include <ModuleCondition.h>

Collaboration diagram for ModuleCondition:

Public Types

enum  EConditionOperators {
  c_GT ,
  c_ST ,
  c_GE ,
  c_SE ,
  c_EQ ,
  c_NE
}
 The supported condition operators. More...
 
enum class  EAfterConditionPath {
  c_End ,
  c_Continue
}
 Different options for behaviour after a conditional path was executed. More...
 

Public Member Functions

 ModuleCondition (std::string expression, std::shared_ptr< Path > conditionPath, EAfterConditionPath afterConditionPath)
 initialize from string expression (see class doc). More...
 
 ~ModuleCondition ()=default
 Destructor, nothing to see here.
 
 ModuleCondition (const ModuleCondition &other)=default
 default copy constructor.
 
ModuleConditionoperator= (const ModuleCondition &other)=default
 and default assignment operator
 
bool evaluate (int value) const
 evaluate the condition using the given value. More...
 
const std::shared_ptr< Path > & getPath () const
 Returns the path of the condition. More...
 
int getConditionValue () const
 Returns the value of the condition. More...
 
EConditionOperators getConditionOperator () const
 Returns the value of the condition. More...
 
EAfterConditionPath getAfterConditionPath () const
 What to do after a conditional path is finished.
 
std::string getString () const
 A string representation of this condition.
 

Static Public Member Functions

static void exposePythonAPI ()
 Exposes methods of the ModuleCondition class to Python.
 

Private Member Functions

 ModuleCondition ()=delete
 no default constructed objects.
 

Private Attributes

std::shared_ptr< Pathm_conditionPath
 The path which which will be executed if the condition is evaluated to true.
 
EConditionOperators m_conditionOperator
 The operator of the condition (set by parsing the condition expression).
 
int m_conditionValue
 Numeric value used in the condition (set by parsing the condition expression).
 
EAfterConditionPath m_afterConditionPath
 What to do after a conditional path is finished.
 

Detailed Description

Wraps a condition set on a Module instance.

It supports conditions of the form [comparison operator][integer] e.g. ">5", "=7", "!= 0"

Additional spaces in front of the operator, between operator and integer number and after the integer number are allowed.

Supported operators are: "> , < , = , == , >= , <= , !="

Definition at line 29 of file ModuleCondition.h.

Member Enumeration Documentation

◆ EAfterConditionPath

enum EAfterConditionPath
strong

Different options for behaviour after a conditional path was executed.

Enumerator
c_End 

End current event after the conditional path.

c_Continue 

After the conditional path, resume execution after this module.

Definition at line 42 of file ModuleCondition.h.

42  {
43  c_End,
44  c_Continue,
45  };

◆ EConditionOperators

The supported condition operators.

Enumerator
c_GT 

Greater than: ">"

c_ST 

Smaller than: "<"

c_GE 

Greater or equal than: ">=".

c_SE 

Smaller or equal than: "<=".

c_EQ 

Equal: "=" or "=="

c_NE 

Not equal: "!=".

Definition at line 32 of file ModuleCondition.h.

Constructor & Destructor Documentation

◆ ModuleCondition()

ModuleCondition ( std::string  expression,
std::shared_ptr< Path conditionPath,
EAfterConditionPath  afterConditionPath 
)

initialize from string expression (see class doc).

Throws runtime_error if expression is invalid.

Member Function Documentation

◆ evaluate()

bool evaluate ( int  value) const

evaluate the condition using the given value.

E.g. for a condition ">5", this would return "value>5"

Definition at line 57 of file ModuleCondition.cc.

58 {
59  switch (m_conditionOperator) {
60  case c_GT : return value > m_conditionValue;
61  case c_ST : return value < m_conditionValue;
62  case c_GE : return value >= m_conditionValue;
63  case c_SE : return value <= m_conditionValue;
64  case c_EQ : return value == m_conditionValue;
65  case c_NE : return value != m_conditionValue;
66  }
67  return false;
68 }
EConditionOperators m_conditionOperator
The operator of the condition (set by parsing the condition expression).
@ c_GE
Greater or equal than: ">=".
@ c_SE
Smaller or equal than: "<=".
@ c_GT
Greater than: ">"
@ c_NE
Not equal: "!=".
@ c_EQ
Equal: "=" or "=="
@ c_ST
Smaller than: "<"
int m_conditionValue
Numeric value used in the condition (set by parsing the condition expression).

◆ getConditionOperator()

EConditionOperators getConditionOperator ( ) const
inline

Returns the value of the condition.


Definition at line 66 of file ModuleCondition.h.

◆ getConditionValue()

int getConditionValue ( ) const
inline

Returns the value of the condition.


Definition at line 63 of file ModuleCondition.h.

◆ getPath()

const std::shared_ptr<Path>& getPath ( ) const
inline

Returns the path of the condition.


Definition at line 60 of file ModuleCondition.h.


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