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

#include <Logic.h>

Inheritance diagram for TrigConf::LogicAND:
Collaboration diagram for TrigConf::LogicAND:

Public Types

enum  NodeType { LEAF , AND , OR }

Public Member Functions

 LogicAND ()
 LogicAND (std::unique_ptr< Logic > &&left)
virtual ~LogicAND () override=default
bool evaluate (const std::map< std::string, bool > &elementsState) 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
void addSubLogic (std::unique_ptr< Logic > &&right)
const std::vector< std::unique_ptr< Logic > > & subLogics () const
std::vector< std::unique_ptr< Logic > > takeSubLogics ()
void print (std::ostream &=std::cout) const
NodeType nodeType () const
void setNegate (bool negate=true)
bool negate () const
void setExpression (const std::string &)
const std::string & expression () const

Private Member Functions

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

Private Attributes

std::vector< std::unique_ptr< Logic > > m_subs
NodeType m_nodeType { LEAF }
bool m_negate { false }
std::string m_expression { "" }

Detailed Description

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

◆ LogicAND() [1/2]

TrigConf::LogicAND::LogicAND ( )

Definition at line 147 of file Logic.cxx.

147 :
149{}
LogicOPS(NodeType nodeType)
Definition Logic.cxx:105

◆ LogicAND() [2/2]

TrigConf::LogicAND::LogicAND ( std::unique_ptr< Logic > && left)

Definition at line 151 of file Logic.cxx.

151 :
152 LogicOPS(Logic::AND, std::move(left))
153{}

◆ ~LogicAND()

virtual TrigConf::LogicAND::~LogicAND ( )
overridevirtualdefault

Member Function Documentation

◆ addSubLogic()

void TrigConf::LogicOPS::addSubLogic ( std::unique_ptr< Logic > && right)
inherited

Definition at line 116 of file Logic.cxx.

117{
118 m_subs.push_back(std::move(right));
119}
std::vector< std::unique_ptr< Logic > > m_subs
Definition Logic.h:97

◆ elements()

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

Implements TrigConf::Logic.

Definition at line 176 of file Logic.cxx.

176 {
177 std::map<std::string, bool> elements;
178 for( auto & subLogic : subLogics() ) {
179 for ( const auto& el : subLogic->elements() ) {
180 elements.insert(el);
181 }
182 }
183 return elements;
184}
std::map< std::string, bool > elements() const override
Definition Logic.cxx:176
const std::vector< std::unique_ptr< Logic > > & subLogics() const
Definition Logic.cxx:122

◆ elementsCount()

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

Implements TrigConf::Logic.

Definition at line 187 of file Logic.cxx.

187 {
188 std::map<std::string, unsigned int> elementsCount;
189 for( auto & subLogic : subLogics() ) {
190 for ( const auto& el : subLogic->elementsCount() ) {
191 elementsCount.insert(el);
192 }
193 }
194 return elementsCount;
195}
std::map< std::string, unsigned int > elementsCount() const override
Definition Logic.cxx:187

◆ evaluate() [1/2]

bool TrigConf::LogicAND::evaluate ( const std::map< std::string, bool > & elementsState) const
overridevirtual

Implements TrigConf::Logic.

Definition at line 156 of file Logic.cxx.

156 {
157 for( auto & subLogic : subLogics() ) {
158 if(! subLogic->evaluate(elementsState) ) { // if one evaluates to false, we can stop
159 return negate() ? true : false;
160 }
161 }
162 return negate() ? false : true;
163}
bool negate() const
Definition Logic.cxx:22

◆ evaluate() [2/2]

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

Implements TrigConf::Logic.

Definition at line 166 of file Logic.cxx.

166 {
167 for( auto & subLogic : subLogics() ) {
168 if(! subLogic->evaluate(elementsCount) ) { // if one evaluates to false, we can stop
169 return negate() ? true : false;
170 }
171 }
172 return negate() ? false : true;
173}

◆ 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 << "\n";
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::LogicOPS::print ( std::ostream & o,
size_t indSize,
size_t indLevel ) const
overrideprivatevirtualinherited

Implements TrigConf::Logic.

Definition at line 134 of file Logic.cxx.

134 {
135 o << std::string(indSize*indLevel, ' ');
136 if( negate() ) { o << "NOT "; }
137 o << (nodeType()==Logic::AND ? "AND (" : "OR (") << std::endl;
138 for( auto & subLogic : m_subs ) {
139 subLogic->print(o,indSize, indLevel+1);
140 }
141 o << std::string(indSize*indLevel, ' ') << ")" << std::endl;
142}
NodeType nodeType() const
Definition Logic.h:37

◆ 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}

◆ subLogics()

const std::vector< std::unique_ptr< TrigConf::Logic > > & TrigConf::LogicOPS::subLogics ( ) const
inherited

Definition at line 122 of file Logic.cxx.

122 {
123 return m_subs;
124}

◆ takeSubLogics()

std::vector< std::unique_ptr< TrigConf::Logic > > TrigConf::LogicOPS::takeSubLogics ( )
inherited

Definition at line 127 of file Logic.cxx.

127 {
128 auto tmp = std::move(m_subs);
129 m_subs.clear();
130 return tmp;
131}

Member Data Documentation

◆ m_expression

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

Definition at line 61 of file Logic.h.

61{ "" };

◆ 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 };

◆ m_subs

std::vector<std::unique_ptr<Logic> > TrigConf::LogicOPS::m_subs
privateinherited

Definition at line 97 of file Logic.h.


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