ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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.

33 { LEAF, AND, OR };

Constructor & Destructor Documentation

◆ LogicLeaf() [1/2]

TrigConf::LogicLeaf::LogicLeaf ( )
delete

◆ LogicLeaf() [2/2]

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

Definition at line 48 of file Logic.cxx.

48  :
50 {
52 }

◆ ~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 86 of file Logic.cxx.

86  {
87  return {{m_name, true}};
88 }

◆ elementsCount()

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

Implements TrigConf::Logic.

Definition at line 92 of file Logic.cxx.

92  {
93  return {{m_name, m_count}};
94 }

◆ evaluate() [1/2]

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

Implements TrigConf::Logic.

Definition at line 66 of file Logic.cxx.

66  {
67  auto stateForThisLeaf = elementsState.find(m_content);
68  if( stateForThisLeaf == elementsState.end() ) {
69  throw LogicParsingException(std::string("Can't evaluate logic ") + m_content + " as it is missing in the state map");
70  }
71  return negate() ? !stateForThisLeaf->second : stateForThisLeaf->second;
72 }

◆ evaluate() [2/2]

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

Implements TrigConf::Logic.

Definition at line 76 of file Logic.cxx.

76  {
77  auto stateForThisLeaf = elementsCount.find(m_name);
78  if( stateForThisLeaf == elementsCount.end() ) {
79  throw LogicParsingException(std::string("Can't evaluate logic ") + m_content + " as " + m_name + " is missing in the counts map");
80  }
81  bool pass = stateForThisLeaf->second >= m_count;
82  return negate() ? !pass : pass;
83 }

◆ expression()

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

Definition at line 34 of file Logic.cxx.

34  {
35  return m_expression;
36 }

◆ negate()

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

Definition at line 24 of file Logic.cxx.

24  {
25  return m_negate;
26 }

◆ nodeType()

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

Definition at line 37 of file Logic.h.

37 { return m_nodeType; }

◆ print() [1/2]

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

Implements TrigConf::Logic.

Definition at line 98 of file Logic.cxx.

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

◆ print() [2/2]

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

Definition at line 39 of file Logic.cxx.

39  {
40  if(m_expression.size()>0) {
41  o << m_expression << std::endl;
42  o << std::string(m_expression.size(), '-') << std::endl;
43  }
44  print(o, 4, 0);
45 }

◆ setContent()

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

Definition at line 56 of file Logic.cxx.

56  {
58  std::smatch sm;
59  std::regex_match(content, sm, re);
60  m_name = sm[1];
61  m_count = sm[2].length()>0 ? boost::lexical_cast<unsigned int,std::string>(sm[2]) : 1;
62 }

◆ setExpression()

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

Definition at line 29 of file Logic.cxx.

29  {
30  m_expression = expr;
31 }

◆ setNegate()

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

Definition at line 19 of file Logic.cxx.

19  {
20  m_negate = negate;
21 }

Member Data Documentation

◆ m_content

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

Definition at line 81 of file Logic.h.

◆ m_count

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

Definition at line 83 of file Logic.h.

◆ m_expression

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

Definition at line 61 of file Logic.h.

◆ m_name

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

Definition at line 82 of file Logic.h.

◆ m_negate

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

Definition at line 60 of file Logic.h.

◆ m_nodeType

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

Definition at line 59 of file Logic.h.


The documentation for this class was generated from the following files:
TrigConf::LogicLeaf::setContent
void setContent(const std::string &content)
Definition: Logic.cxx:56
TrigConf::Logic::m_expression
std::string m_expression
Definition: Logic.h:61
TrigConf::Logic::LEAF
@ LEAF
Definition: Logic.h:33
TrigConf::Logic::Logic
Logic()=delete
TrigConf::Logic::negate
bool negate() const
Definition: Logic.cxx:24
grepfile.content
string content
Definition: grepfile.py:56
TrigConf::Logic::AND
@ AND
Definition: Logic.h:33
re
const std::regex re("([-\\w.]+)(?:\\[x(\\d+)\\])?$")
TrigConf::LogicLeaf::m_name
std::string m_name
Definition: Logic.h:82
TrigConf::LogicLeaf::elementsCount
std::map< std::string, unsigned int > elementsCount() const override
Definition: Logic.cxx:92
TrigConf::Logic::m_nodeType
NodeType m_nodeType
Definition: Logic.h:59
TrigConf::LogicLeaf::m_count
unsigned int m_count
Definition: Logic.h:83
TrigConf::Logic::OR
@ OR
Definition: Logic.h:33
TrigConf::Logic::print
void print(std::ostream &=std::cout) const
Definition: Logic.cxx:39
TrigConf::LogicLeaf::m_content
std::string m_content
Definition: Logic.h:81
TrigConf::Logic::m_negate
bool m_negate
Definition: Logic.h:60