#include <LogicExpression.h>
|
| static const char | kAND = '&' |
| | AND of sub-logics.
|
| static const char | kOR = '|' |
| | OR of sub-logics.
|
| static const char | kNOT = '!' |
| | NOT of a sub-logic. (only one sub-logic)
|
| static const char | kELEMENT = '#' |
| | simple element.
|
| static const char | kOPEN = '(' |
| | empty logic but may have sub-logics.
|
| static const char | kCLOSE = ')' |
| | ')' is a valid symbol, but not allowed as a state.
|
Definition at line 27 of file LogicExpression.h.
◆ LogicExpression() [1/2]
| LogicExpression::LogicExpression |
( |
std::ostream & | o = std::cout | ) |
|
constructor
Definition at line 14 of file LogicExpression.cxx.
14 :
18{}
std::ostream & m_ostream
output stream for all messages
static const char kELEMENT
simple element.
◆ ~LogicExpression()
| virtual TrigConf::LogicExpression::~LogicExpression |
( |
| ) |
|
|
virtualdefault |
◆ LogicExpression() [2/2]
| LogicExpression::LogicExpression |
( |
const std::string & | name, |
|
|
std::ostream & | o = std::cout ) |
◆ addSubLogic()
◆ clear()
| void LogicExpression::clear |
( |
| ) |
|
◆ element()
| const std::string & TrigConf::LogicExpression::element |
( |
| ) |
const |
|
inline |
◆ extractElementName()
| std::string LogicExpression::extractElementName |
( |
const std::string & | expr | ) |
|
|
static |
Definition at line 40 of file LogicExpression.cxx.
40 {
42 for (
unsigned int i=0;
i<expr.size(); ++
i) {
44 else break;
45 }
47}
static bool isValidElementChar(char c)
◆ isPlaceHolder()
| bool TrigConf::LogicExpression::isPlaceHolder |
( |
| ) |
const |
|
inline |
Definition at line 64 of file LogicExpression.h.
static const char kOPEN
empty logic but may have sub-logics.
◆ isValidElementChar()
| bool LogicExpression::isValidElementChar |
( |
char | c | ) |
|
|
static |
Definition at line 29 of file LogicExpression.cxx.
29 {
30 std::string valid_sym = "_";
31 if (isalpha(c) || isdigit(c) || valid_sym.find(c)!=std::string::npos) {
32 return true;
33 } else {
34 return false;
35 }
36}
◆ logicRep()
| std::string LogicExpression::logicRep |
( |
| ) |
const |
|
virtual |
Definition at line 176 of file LogicExpression.cxx.
176 {
181 LogicV_t::const_iterator
p;
184 s += (*p)->logicRep();
186 }
187 if (
s.size() > 1)
s[
s.size()-1] =
kCLOSE;
198 }
200}
static const char kAND
AND of sub-logics.
static const char kNOT
NOT of a sub-logic. (only one sub-logic)
static const char kCLOSE
')' is a valid symbol, but not allowed as a state.
const LogicV_t & subLogics() const
static const char kOR
OR of sub-logics.
◆ markPlaceHolder()
| void LogicExpression::markPlaceHolder |
( |
| ) |
|
◆ normalize()
| void LogicExpression::normalize |
( |
| ) |
|
Definition at line 204 of file LogicExpression.cxx.
204 {
205 LogicV_t::const_iterator
p;
207 (*p)->normalize();
208 }
216 for (p=sublogics.begin(); p!=sublogics.end(); ++p) {
218 }
219 }
220}
bool isPlaceHolder() const
void addSubLogic(const LogicExpression &sub)
void setElement(const std::string &e)
std::vector< std::shared_ptr< LogicExpression > > LogicV_t
◆ parse()
| int LogicExpression::parse |
( |
const std::string & | expr, |
|
|
bool | enclosed = false ) |
|
virtual |
Definition at line 51 of file LogicExpression.cxx.
51 {
54 bool no_problem=true;
55 char prev = ' ';
57
59 while (no_problem && i < expr.size()) {
61
62 switch (c) {
64 {
66 if ( (n = sub.parse(expr.substr(i+1), true)) > 0) {
70 } else {
71 no_problem = false;
72 }
73 }
74 break;
82 } else {
83 std::ostringstream formatedoutput;
86 no_problem = false;
87 }
88 break;
93 ) {
96 } else {
97 std::ostringstream formatedoutput;
98 formatedoutput <<
kAND <<
" or " <<
kOR <<
" must come after a logic element";
100 no_problem = false;
101 }
102 break;
112 }
else if ( (i+1)<expr.size() && expr[i+1]==
kOPEN) {
114 if ( (n = sub2.parse(expr.substr(i+2), true)) > 0) {
115 sub.addSubLogic(sub2);
118 } else {
119 no_problem = false;
120 }
121 } else {
122 printError(
"Was expecting a sub-logic after !", i);
123 no_problem = false;
124 }
125 } else {
126 printError(
"! must not come directly after a logic element", i);
127 no_problem = false;
128 }
130 break;
131 default:
132
136 if (
name.size() > 0) {
139 } else {
141 no_problem = false;
142 }
144 } else {
145 printError(
"A logic element may not come immediately after another logic element", i);
146 no_problem = false;
147 }
148 break;
149 }
151
152 }
153 if (!no_problem) {
154 return -1;
155 }
156
157 if (enclosed) {
158
159
160 printError(
"The expression started with a '(' but ')' not found.", i);
161 return 0;
162 }
164
166}
LogicExpression(std::ostream &o=std::cout)
constructor
static std::string extractElementName(const std::string &expr)
◆ print()
| void LogicExpression::print |
( |
const std::string & | indent = "" | ) |
|
Definition at line 268 of file LogicExpression.cxx.
268 {
275 LogicV_t::const_iterator
p;
277 (*p)->print(indent + " ");
278 }
283 }
286 } else {
288 }
289}
const std::shared_ptr< LogicExpression > subLogic(int i) const
◆ printCurrentState()
| void LogicExpression::printCurrentState |
( |
| ) |
|
Definition at line 259 of file LogicExpression.cxx.
259 {
260 char aaa[100];
261 sprintf(aaa, "Current state: State=%c Nsublogics=%d Element=%s",
264}
◆ printError()
| void LogicExpression::printError |
( |
const std::string & | message, |
|
|
int | i ) |
Definition at line 246 of file LogicExpression.cxx.
246 {
247 std::string
m=
"Error while parsing : ";
250 for (
int j=0; j<(
n+
i); ++j) s +=
" ";
255}
◆ setElement()
| void TrigConf::LogicExpression::setElement |
( |
const std::string & | e | ) |
|
|
inline |
◆ setState()
| void TrigConf::LogicExpression::setState |
( |
char | s | ) |
|
|
inline |
◆ state()
| char TrigConf::LogicExpression::state |
( |
| ) |
const |
|
inline |
◆ subLogic()
| const std::shared_ptr< LogicExpression > TrigConf::LogicExpression::subLogic |
( |
int | i | ) |
const |
|
inline |
◆ subLogics()
| const LogicV_t & TrigConf::LogicExpression::subLogics |
( |
| ) |
const |
|
inline |
◆ totalNumberOfElements()
| int LogicExpression::totalNumberOfElements |
( |
| ) |
const |
Definition at line 224 of file LogicExpression.cxx.
224 {
226 LogicV_t::const_iterator
p;
227
231 break;
234 n += (*p)->totalNumberOfElements();
235 }
236 break;
237 default:
239 break;
240 }
242}
◆ kAND
| const char TrigConf::LogicExpression::kAND = '&' |
|
static |
◆ kCLOSE
| const char TrigConf::LogicExpression::kCLOSE = ')' |
|
static |
')' is a valid symbol, but not allowed as a state.
Definition at line 37 of file LogicExpression.h.
◆ kELEMENT
| const char TrigConf::LogicExpression::kELEMENT = '#' |
|
static |
◆ kNOT
| const char TrigConf::LogicExpression::kNOT = '!' |
|
static |
◆ kOPEN
| const char TrigConf::LogicExpression::kOPEN = '(' |
|
static |
◆ kOR
| const char TrigConf::LogicExpression::kOR = '|' |
|
static |
◆ m_Element
| std::string TrigConf::LogicExpression::m_Element |
|
protected |
◆ m_LogicRep
| std::string TrigConf::LogicExpression::m_LogicRep |
|
protected |
◆ m_ostream
| std::ostream& TrigConf::LogicExpression::m_ostream |
|
protected |
◆ m_State
| char TrigConf::LogicExpression::m_State |
|
protected |
◆ m_SubLogics
| LogicV_t TrigConf::LogicExpression::m_SubLogics |
|
protected |
The documentation for this class was generated from the following files: