Belle II Software development
IdentifierNode< AVariableManager > Class Template Reference

Class which stores the name of a variable. More...

#include <CutNodes.h>

Inheritance diagram for IdentifierNode< AVariableManager >:
AbstractExpressionNode< AVariableManager >

Public Member Functions

AVariableManager::VarVariant evaluate (const Object *p) const override
 evaluate m_var with p and return the result
 
void print () const override
 Print node.
 
std::string decompile () const override
 Decompile Node back to a string.
 
void processVariable ()
 Get variable from AVariableManger.
 
 ~IdentifierNode ()
 Destructor.
 

Private Types

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

Private Member Functions

 IdentifierNode (const std::string &name)
 Constructor.
 

Private Attributes

const std::string m_name
 name of the variable
 
const Varm_var
 set if there was a valid variable in this cut
 

Friends

class NodeFactory
 

Detailed Description

template<class AVariableManager>
class Belle2::IdentifierNode< AVariableManager >

Class which stores the name of a variable.

Variable evaluation with the variable manager

Definition at line 941 of file CutNodes.h.

Member Typedef Documentation

◆ Object

typedef AVariableManager::Object Object
private

Template argument dependent Particle type definition.

Definition at line 945 of file CutNodes.h.

◆ Var

typedef AVariableManager::Var Var
private

Template argument dependent Variable type definition.

Definition at line 949 of file CutNodes.h.

Constructor & Destructor Documentation

◆ ~IdentifierNode()

~IdentifierNode ( )
inline

Destructor.

Definition at line 995 of file CutNodes.h.

995{}

◆ IdentifierNode()

IdentifierNode ( const std::string &  name)
inlineexplicitprivate

Constructor.

Parameters
name(const std::string&): name of the identifier in cut

Definition at line 1003 of file CutNodes.h.

1003: m_name{name}, m_var{nullptr} {processVariable();}
void processVariable()
Get variable from AVariableManger.
Definition: CutNodes.h:983
const std::string m_name
name of the variable
Definition: CutNodes.h:1004
const Var * m_var
set if there was a valid variable in this cut
Definition: CutNodes.h:1005

Member Function Documentation

◆ decompile()

std::string decompile ( ) const
inlineoverridevirtual

Decompile Node back to a string.

decompile(compile) should give the same result.

Implements AbstractExpressionNode< AVariableManager >.

Definition at line 975 of file CutNodes.h.

976 {
977 return m_name;
978 }

◆ evaluate()

AVariableManager::VarVariant evaluate ( const Object p) const
inlineoverridevirtual

evaluate m_var with p and return the result

Parameters
ppointer to the object, for which m_var should be evaluated.

Implements AbstractExpressionNode< AVariableManager >.

Definition at line 955 of file CutNodes.h.

956 {
957 if (m_var != nullptr) {
958 return m_var->function(p);
959 } else {
960 throw std::runtime_error("Cut string has an invalid format: Neither number nor variable name");
961 }
962 }

◆ print()

void print ( ) const
inlineoverridevirtual

Print node.

Implements AbstractExpressionNode< AVariableManager >.

Definition at line 966 of file CutNodes.h.

967 {
968 std::cout << m_name;
969 }

◆ processVariable()

void processVariable ( )
inline

Get variable from AVariableManger.

Definition at line 983 of file CutNodes.h.

984 {
985 AVariableManager& manager = AVariableManager::Instance();
986 m_var = manager.getVariable(m_name);
987 if (m_var == nullptr) {
988 throw std::runtime_error(
989 "Cut string has an invalid format: Variable not found: " + m_name);
990 }
991 }

Friends And Related Function Documentation

◆ NodeFactory

friend class NodeFactory
friend

Definition at line 998 of file CutNodes.h.

Member Data Documentation

◆ m_name

const std::string m_name
private

name of the variable

Definition at line 1004 of file CutNodes.h.

◆ m_var

const Var* m_var
private

set if there was a valid variable in this cut

Definition at line 1005 of file CutNodes.h.


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