ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConf::LogicLeaf Class Reference

#include <Logic.h>

Inheritance diagram for TrigConf::LogicLeaf:
Collaboration diagram for TrigConf::LogicLeaf:

Public Types

enum  NodeType { LEAF , AND , OR }

Public Member Functions

 LogicLeaf ()=delete
 LogicLeaf (const std::string &content)
virtual ~LogicLeaf () override=default
void setContent (const std::string &content)
bool evaluate (const std::map< std::string, bool > &elements) const override
bool evaluate (const std::map< std::string, unsigned int > &elementsCount) const override
std::map< std::string, bool > elements () const override
std::map< std::string, unsigned int > elementsCount () const override
NodeType nodeType () const
void setNegate (bool negate=true)
bool negate () const
void setExpression (const std::string &)
const std::string & expression () const
void print (std::ostream &=std::cout) const

Private Member Functions

virtual void print (std::ostream &, size_t indSize, size_t indLevel) const override

Private Attributes

std::string m_content { "" }
std::string m_name { "" }
unsigned int m_count { 1 }
NodeType m_nodeType { LEAF }
bool m_negate { false }
std::string m_expression { "" }

Detailed Description

Definition at line 65 of file Logic.h.

Member Enumeration Documentation

◆ NodeType

enum TrigConf::Logic::NodeType
inherited
Enumerator
LEAF 
AND 
OR 

Definition at line 33 of file Logic.h.

Constructor & Destructor Documentation

◆ LogicLeaf() [1/2]

TrigConf::LogicLeaf::LogicLeaf ( )
delete

◆ LogicLeaf() [2/2]

TrigConf::LogicLeaf::LogicLeaf ( const std::string & content)

Definition at line 46 of file Logic.cxx.

46 :
48{
49 setContent(content);
50}
void setContent(const std::string &content)
Definition Logic.cxx:54

◆ ~LogicLeaf()

virtual TrigConf::LogicLeaf::~LogicLeaf ( )
overridevirtualdefault

Member Function Documentation

◆ elements()

std::map< std::string, bool > TrigConf::LogicLeaf::elements ( ) const
overridevirtual

Implements TrigConf::Logic.

Definition at line 84 of file Logic.cxx.

84 {
85 return {{m_name, true}};
86}
std::string m_name
Definition Logic.h:82

◆ elementsCount()

std::map< std::string, unsigned int > TrigConf::LogicLeaf::elementsCount ( ) const
overridevirtual

Implements TrigConf::Logic.

Definition at line 90 of file Logic.cxx.

90 {
91 return {{m_name, m_count}};
92}
unsigned int m_count
Definition Logic.h:83

◆ evaluate() [1/2]

bool TrigConf::LogicLeaf::evaluate ( const std::map< std::string, bool > & elements) const
overridevirtual

Implements TrigConf::Logic.

Definition at line 64 of file Logic.cxx.

64 {
65 auto stateForThisLeaf = elementsState.find(m_content);
66 if( stateForThisLeaf == elementsState.end() ) {
67 throw LogicParsingException(std::string("Can't evaluate logic ") + m_content + " as it is missing in the state map");
68 }
69 return negate() ? !stateForThisLeaf->second : stateForThisLeaf->second;
70}
std::string m_content
Definition Logic.h:81
bool negate() const
Definition Logic.cxx:22

◆ evaluate() [2/2]

bool TrigConf::LogicLeaf::evaluate ( const std::map< std::string, unsigned int > & elementsCount) const
overridevirtual

Implements TrigConf::Logic.

Definition at line 74 of file Logic.cxx.

74 {
75 auto stateForThisLeaf = elementsCount.find(m_name);
76 if( stateForThisLeaf == elementsCount.end() ) {
77 throw LogicParsingException(std::string("Can't evaluate logic ") + m_content + " as " + m_name + " is missing in the counts map");
78 }
79 bool pass = stateForThisLeaf->second >= m_count;
80 return negate() ? !pass : pass;
81}
std::map< std::string, unsigned int > elementsCount() const override
Definition Logic.cxx:90

◆ expression()

const std::string & TrigConf::Logic::expression ( ) const
inherited

Definition at line 32 of file Logic.cxx.

32 {
33 return m_expression;
34}
std::string m_expression
Definition Logic.h:61

◆ negate()

bool TrigConf::Logic::negate ( ) const
inherited

Definition at line 22 of file Logic.cxx.

22 {
23 return m_negate;
24}
bool m_negate
Definition Logic.h:60

◆ nodeType()

NodeType TrigConf::Logic::nodeType ( ) const
inlineinherited

Definition at line 37 of file Logic.h.

37{ return m_nodeType; }
NodeType m_nodeType
Definition Logic.h:59

◆ print() [1/2]

void TrigConf::Logic::print ( std::ostream & o = std::cout) const
inherited

Definition at line 37 of file Logic.cxx.

37 {
38 if(m_expression.size()>0) {
39 o << m_expression << std::endl;
40 o << std::string(m_expression.size(), '-') << std::endl;
41 }
42 print(o, 4, 0);
43}
void print(std::ostream &=std::cout) const
Definition Logic.cxx:37

◆ print() [2/2]

void TrigConf::LogicLeaf::print ( std::ostream & o,
size_t indSize,
size_t indLevel ) const
overrideprivatevirtual

Implements TrigConf::Logic.

Definition at line 96 of file Logic.cxx.

96 {
97 o << std::string(indSize*indLevel, ' ');
98 if( negate() ) { o << "NOT "; }
99 o << m_content << std::endl;
100}

◆ setContent()

void TrigConf::LogicLeaf::setContent ( const std::string & content)

Definition at line 54 of file Logic.cxx.

54 {
56 std::smatch sm;
57 std::regex_match(content, sm, re);
58 m_name = sm[1];
59 m_count = sm[2].length() > 0 ? static_cast<unsigned int>(std::stoul(sm[2])) : 1;
60}
const boost::regex re(r_e)
str content
Definition grepfile.py:56

◆ setExpression()

void TrigConf::Logic::setExpression ( const std::string & expr)
inherited

Definition at line 27 of file Logic.cxx.

27 {
28 m_expression = expr;
29}

◆ setNegate()

void TrigConf::Logic::setNegate ( bool negate = true)
inherited

Definition at line 17 of file Logic.cxx.

17 {
19}

Member Data Documentation

◆ m_content

std::string TrigConf::LogicLeaf::m_content { "" }
private

Definition at line 81 of file Logic.h.

81{ "" };

◆ m_count

unsigned int TrigConf::LogicLeaf::m_count { 1 }
private

Definition at line 83 of file Logic.h.

83{ 1 };

◆ m_expression

std::string TrigConf::Logic::m_expression { "" }
privateinherited

Definition at line 61 of file Logic.h.

61{ "" };

◆ m_name

std::string TrigConf::LogicLeaf::m_name { "" }
private

Definition at line 82 of file Logic.h.

82{ "" };

◆ m_negate

bool TrigConf::Logic::m_negate { false }
privateinherited

Definition at line 60 of file Logic.h.

60{ false };

◆ m_nodeType

NodeType TrigConf::Logic::m_nodeType { LEAF }
privateinherited

Definition at line 59 of file Logic.h.

59{ LEAF };

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