#include <GlobalLogicParser.h>
Classes | |
struct | OperandToken |
struct | OperationRule |
struct | TokenRPN |
Public Types | |
enum | OperationType { OP_NULL = 1, OP_INVALID = 2, OP_AND = 4, OP_OR = 8, OP_NOT = 16, OP_OPERAND = 32, OP_OPENBRACKET = 64, OP_CLOSEBRACKET = 128, OP_XOR = 256 } |
typedef std::vector< TokenRPN > | RpnVector |
Public Member Functions | |
void | buildOperandTokenVector () |
void | buildOperandTokenVectorNumExp () |
bool | buildRpnVector (const std::string &) |
build the rpn vector More... | |
bool | checkLogicalExpression (std::string &) |
check a logical expression for correctness - add/remove spaces if needed More... | |
void | clearRpnVector () |
clear possible old rpn vector More... | |
void | convertIntToNameLogicalExpression (const std::map< int, std::string > &intToNameMap) |
void | convertNameToIntLogicalExpression (const std::map< std::string, int > &nameToIntMap) |
virtual const bool | expressionResult () const |
virtual const bool | expressionResultNumExp () const |
std::vector< GlobalLogicParser::OperandToken > | expressionSeedsOperandList () |
GlobalLogicParser () | |
constructor(s) More... | |
GlobalLogicParser (const RpnVector &, const std::vector< OperandToken > &) | |
GlobalLogicParser (const std::string &logicalExpressionVal) | |
GlobalLogicParser (std::string &logicalExpressionVal) | |
GlobalLogicParser (const std::string logicalExpressionVal, const std::string numericalExpressionVal) | |
from a logical and a numerical expression More... | |
GlobalLogicParser (const std::string &logicalExpressionVal, const std::string &numericalExpressionVal, const bool dummy) | |
std::string | logicalExpression () const |
return the logical expression More... | |
std::string | numericalExpression () const |
return the numerical expression More... | |
int | operandIndex (const std::string &operandNameVal) const |
return the position index of the operand in the logical expression More... | |
std::string | operandName (const int iOperand) const |
return the name of the (iOperand)th operand in the logical expression More... | |
bool | operandResult (const std::string &operandNameVal) const |
bool | operandResult (const int tokenNumberVal) const |
bool | operandResultNumExp (const std::string &operandNameVal) const |
bool | operandResultNumExp (const int iOperand) const |
std::vector< OperandToken > & | operandTokenVector () |
return the vector of operand tokens More... | |
const std::vector< OperandToken > & | operandTokenVector () const |
RpnVector | rpnVector () const |
return the RPN vector More... | |
virtual | ~GlobalLogicParser () |
destructor More... | |
Protected Member Functions | |
void | addBracketSpaces (const std::string &, std::string &) |
add spaces before and after parantheses More... | |
virtual OperationType | getOperation (const std::string &tokenString, OperationType lastOperation, TokenRPN &rpnToken) const |
const OperationRule * | getRuleFromType (OperationType t) |
get the rule entry to an operation type More... | |
bool | setLogicalExpression (const std::string &) |
set the logical expression - check for correctness the input string More... | |
bool | setNumericalExpression (const std::string &) |
Protected Attributes | |
std::string | m_logicalExpression |
logical expression to be parsed More... | |
std::string | m_numericalExpression |
std::vector< OperandToken > | m_operandTokenVector |
vector of operand tokens More... | |
RpnVector | m_rpnVector |
RPN vector - equivalent to the logical expression. More... | |
Static Protected Attributes | |
static const struct OperationRule | m_operationRules [] |
Description: see header file.
Implementation: <TODO: enter implementation details>
Definition at line 17 of file GlobalLogicParser.h.
typedef std::vector<TokenRPN> GlobalLogicParser::RpnVector |
Definition at line 42 of file GlobalLogicParser.h.
Enumerator | |
---|---|
OP_NULL | |
OP_INVALID | |
OP_AND | |
OP_OR | |
OP_NOT | |
OP_OPERAND | |
OP_OPENBRACKET | |
OP_CLOSEBRACKET | |
OP_XOR |
Definition at line 25 of file GlobalLogicParser.h.
GlobalLogicParser::GlobalLogicParser | ( | ) |
GlobalLogicParser::GlobalLogicParser | ( | const RpnVector & | rpnVec, |
const std::vector< OperandToken > & | opTokenVector | ||
) |
from the RPN vector and the operand token vector no checks for consistency, empty logical and numerical expressions requires special care when used
Definition at line 43 of file GlobalLogicParser.cc.
References m_operandTokenVector, and m_rpnVector.
GlobalLogicParser::GlobalLogicParser | ( | const std::string & | logicalExpressionVal | ) |
from a constant logical expression numerical expression will be empty
Definition at line 50 of file GlobalLogicParser.cc.
References Exception, and setLogicalExpression().
GlobalLogicParser::GlobalLogicParser | ( | std::string & | logicalExpressionVal | ) |
Definition at line 62 of file GlobalLogicParser.cc.
References addBracketSpaces(), buildOperandTokenVector(), buildRpnVector(), Exception, m_logicalExpression, AlCaHLTBitMon_QueryRunRegistry::string, and trim().
GlobalLogicParser::GlobalLogicParser | ( | const std::string | logicalExpressionVal, |
const std::string | numericalExpressionVal | ||
) |
from a logical and a numerical expression
Definition at line 92 of file GlobalLogicParser.cc.
References Exception, setLogicalExpression(), and setNumericalExpression().
GlobalLogicParser::GlobalLogicParser | ( | const std::string & | logicalExpressionVal, |
const std::string & | numericalExpressionVal, | ||
const bool | dummy | ||
) |
from a logical and a numerical expression no checks for correctness - use it only after the correctness was tested
Definition at line 110 of file GlobalLogicParser.cc.
References buildRpnVector(), clearRpnVector(), Exception, m_logicalExpression, and m_numericalExpression.
|
virtual |
|
protected |
add spaces before and after parantheses
Definition at line 1399 of file GlobalLogicParser.cc.
References brackets, position, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by checkLogicalExpression(), GlobalLogicParser(), setLogicalExpression(), and setNumericalExpression().
void GlobalLogicParser::buildOperandTokenVector | ( | ) |
build from the RPN vector the operand token vector dummy tokenNumber and tokenResult
Definition at line 378 of file GlobalLogicParser.cc.
References m_operandTokenVector, m_rpnVector, OP_AND, OP_NOT, OP_OPERAND, OP_OR, OP_XOR, GlobalLogicParser::OperandToken::tokenName, GlobalLogicParser::OperandToken::tokenNumber, and GlobalLogicParser::OperandToken::tokenResult.
Referenced by GlobalLogicParser().
void GlobalLogicParser::buildOperandTokenVectorNumExp | ( | ) |
build from the RPN vector the operand token vector using a numerical expression
Definition at line 770 of file GlobalLogicParser.cc.
References m_operandTokenVector, m_rpnVector, OP_AND, OP_NOT, OP_OPERAND, OP_OR, OP_XOR, operandResultNumExp(), GlobalLogicParser::OperandToken::tokenName, GlobalLogicParser::OperandToken::tokenNumber, and GlobalLogicParser::OperandToken::tokenResult.
bool GlobalLogicParser::buildRpnVector | ( | const std::string & | logicalExpressionVal | ) |
build the rpn vector
buildRpnVector Build the postfix notation.
expression | The expression to be parsed. |
Definition at line 164 of file GlobalLogicParser.cc.
References clearRpnVector(), getOperation(), m_rpnVector, OP_AND, OP_CLOSEBRACKET, OP_INVALID, OP_NOT, OP_NULL, OP_OPENBRACKET, OP_OPERAND, OP_OR, OP_XOR, AlCaHLTBitMon_QueryRunRegistry::string, and gpuVertexFinder::ws.
Referenced by checkLogicalExpression(), GlobalLogicParser(), and setLogicalExpression().
bool GlobalLogicParser::checkLogicalExpression | ( | std::string & | logicalExpressionVal | ) |
check a logical expression for correctness - add/remove spaces if needed
Definition at line 131 of file GlobalLogicParser.cc.
References addBracketSpaces(), buildRpnVector(), clearRpnVector(), LogDebug, AlCaHLTBitMon_QueryRunRegistry::string, and trim().
void GlobalLogicParser::clearRpnVector | ( | ) |
clear possible old rpn vector
Definition at line 374 of file GlobalLogicParser.cc.
References m_rpnVector.
Referenced by buildRpnVector(), checkLogicalExpression(), GlobalLogicParser(), and setLogicalExpression().
void GlobalLogicParser::convertIntToNameLogicalExpression | ( | const std::map< int, std::string > & | intToNameMap | ) |
convert a logical expression composed with integer numbers to a logical expression composed with names using a map (int, string)
Definition at line 998 of file GlobalLogicParser.cc.
References TauDecayModes::dec, getOperation(), getRuleFromType(), m_logicalExpression, OP_INVALID, OP_NULL, OP_OPERAND, GlobalLogicParser::TokenRPN::operand, AlCaHLTBitMon_QueryRunRegistry::string, and trim().
void GlobalLogicParser::convertNameToIntLogicalExpression | ( | const std::map< std::string, int > & | nameToIntMap | ) |
convert the logical expression composed with names to a logical expression composed with int numbers using a (string, int) map
Definition at line 917 of file GlobalLogicParser.cc.
References getOperation(), getRuleFromType(), Json::intValue, LogDebug, m_logicalExpression, OP_INVALID, OP_NULL, OP_OPERAND, GlobalLogicParser::TokenRPN::operand, AlCaHLTBitMon_QueryRunRegistry::string, and trim().
|
virtual |
return the result for the logical expression require a proper operand token vector
Definition at line 593 of file GlobalLogicParser.cc.
References b1, b2, m_rpnVector, OP_AND, OP_NOT, OP_OPERAND, OP_OR, OP_XOR, and operandResult().
Referenced by HLTL1TSeed::seedsL1TriggerObjectMaps().
|
virtual |
return the result for the logical expression require a proper numerical expression
Definition at line 831 of file GlobalLogicParser.cc.
References b1, b2, m_rpnVector, OP_AND, OP_NOT, OP_OPERAND, OP_OR, OP_XOR, and operandResultNumExp().
std::vector< GlobalLogicParser::OperandToken > GlobalLogicParser::expressionSeedsOperandList | ( | ) |
return the list of operand tokens for the logical expression which are to be used as seeds
Definition at line 1079 of file GlobalLogicParser.cc.
References b1, b2, m_operandTokenVector, m_rpnVector, OP_AND, OP_NOT, OP_OPERAND, OP_OR, OP_XOR, GlobalLogicParser::OperandToken::tokenName, GlobalLogicParser::OperandToken::tokenNumber, and GlobalLogicParser::OperandToken::tokenResult.
Referenced by HLTL1TSeed::HLTL1TSeed().
|
protectedvirtual |
getOperation Get the operation from a string and check if it is allowed
tokenString | The string to examine. |
lastOperation | The last operation. |
rpnToken | The destination where the token for postfix notation is written to. |
Definition at line 1340 of file GlobalLogicParser.cc.
References mps_fire::i, m_operationRules, OP_INVALID, OP_OPERAND, GlobalLogicParser::TokenRPN::operand, and GlobalLogicParser::TokenRPN::operation.
Referenced by buildRpnVector(), convertIntToNameLogicalExpression(), convertNameToIntLogicalExpression(), operandIndex(), operandName(), and operandResultNumExp().
|
protected |
get the rule entry to an operation type
getRuleFromType Looks for the entry in the operation rules and returns a reference if it was found
oType | The type of the operation. |
Definition at line 1384 of file GlobalLogicParser.cc.
References mps_fire::i, m_operationRules, and OP_NULL.
Referenced by convertIntToNameLogicalExpression(), and convertNameToIntLogicalExpression().
|
inline |
return the logical expression
Definition at line 77 of file GlobalLogicParser.h.
References m_logicalExpression.
|
inline |
return the numerical expression
Definition at line 83 of file GlobalLogicParser.h.
References m_numericalExpression.
int GlobalLogicParser::operandIndex | ( | const std::string & | operandNameVal | ) | const |
return the position index of the operand in the logical expression
Definition at line 437 of file GlobalLogicParser.cc.
References getOperation(), m_logicalExpression, OP_INVALID, OP_NULL, OP_OPERAND, GlobalLogicParser::TokenRPN::operand, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by operandResultNumExp().
std::string GlobalLogicParser::operandName | ( | const int | iOperand | ) | const |
return the name of the (iOperand)th operand in the logical expression
Definition at line 498 of file GlobalLogicParser.cc.
References getOperation(), m_logicalExpression, OP_INVALID, OP_NULL, OP_OPERAND, GlobalLogicParser::TokenRPN::operand, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.
bool GlobalLogicParser::operandResult | ( | const std::string & | operandNameVal | ) | const |
return the result for an operand with name operandNameVal in the logical expression using the operand token vector
Definition at line 560 of file GlobalLogicParser.cc.
References mps_fire::i, and m_operandTokenVector.
Referenced by expressionResult(), and operandResultNumExp().
bool GlobalLogicParser::operandResult | ( | const int | tokenNumberVal | ) | const |
return the result for an operand with tokenNumberVal using the operand token vector
Definition at line 576 of file GlobalLogicParser.cc.
References mps_fire::i, and m_operandTokenVector.
bool GlobalLogicParser::operandResultNumExp | ( | const std::string & | operandNameVal | ) | const |
return the result for an operand with name operandNameVal in the logical expression using a numerical expression
Definition at line 675 of file GlobalLogicParser.cc.
References operandIndex(), operandResult(), and mps_fire::result.
Referenced by buildOperandTokenVectorNumExp(), and expressionResultNumExp().
bool GlobalLogicParser::operandResultNumExp | ( | const int | iOperand | ) | const |
return the result for an operand with index iOperand in the logical expression using a numerical expression
Definition at line 688 of file GlobalLogicParser.cc.
References getOperation(), m_numericalExpression, OP_INVALID, OP_NULL, OP_OPERAND, GlobalLogicParser::TokenRPN::operand, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.
|
inline |
return the vector of operand tokens
Definition at line 100 of file GlobalLogicParser.h.
References m_operandTokenVector.
Referenced by HLTL1TSeed::HLTL1TSeed(), and HLTL1TSeed::seedsL1TriggerObjectMaps().
|
inline |
Definition at line 101 of file GlobalLogicParser.h.
References m_operandTokenVector.
|
inline |
return the RPN vector
Definition at line 93 of file GlobalLogicParser.h.
References m_rpnVector.
Referenced by GlobalAlgorithm::GlobalAlgorithm().
|
protected |
set the logical expression - check for correctness the input string
Definition at line 1421 of file GlobalLogicParser.cc.
References addBracketSpaces(), buildRpnVector(), clearRpnVector(), m_logicalExpression, AlCaHLTBitMon_QueryRunRegistry::string, and trim().
Referenced by GlobalLogicParser().
|
protected |
set the numerical expression (the logical expression with each operand replaced with the value) from a string check also for correctness the input string
Definition at line 1449 of file GlobalLogicParser.cc.
References addBracketSpaces(), m_numericalExpression, AlCaHLTBitMon_QueryRunRegistry::string, and trim().
Referenced by GlobalLogicParser().
|
protected |
logical expression to be parsed
Definition at line 182 of file GlobalLogicParser.h.
Referenced by convertIntToNameLogicalExpression(), convertNameToIntLogicalExpression(), GlobalLogicParser(), logicalExpression(), operandIndex(), operandName(), and setLogicalExpression().
|
protected |
numerical expression (logical expression with operands replaced with the actual values)
Definition at line 186 of file GlobalLogicParser.h.
Referenced by GlobalLogicParser(), numericalExpression(), operandResultNumExp(), and setNumericalExpression().
|
protected |
vector of operand tokens
Definition at line 192 of file GlobalLogicParser.h.
Referenced by buildOperandTokenVector(), buildOperandTokenVectorNumExp(), expressionSeedsOperandList(), GlobalLogicParser(), operandResult(), and operandTokenVector().
|
staticprotected |
Definition at line 166 of file GlobalLogicParser.h.
Referenced by getOperation(), and getRuleFromType().
|
protected |
RPN vector - equivalent to the logical expression.
Definition at line 189 of file GlobalLogicParser.h.
Referenced by buildOperandTokenVector(), buildOperandTokenVectorNumExp(), buildRpnVector(), clearRpnVector(), expressionResult(), expressionResultNumExp(), expressionSeedsOperandList(), GlobalLogicParser(), and rpnVector().