CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
GlobalLogicParser Class Reference

#include <GlobalLogicParser.h>

Inheritance diagram for GlobalLogicParser:

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
}
 
typedef std::vector< TokenRPNRpnVector
 

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 OperationRulegetRuleFromType (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< OperandTokenm_operandTokenVector
 vector of operand tokens More...
 
RpnVector m_rpnVector
 RPN vector - equivalent to the logical expression. More...
 

Static Protected Attributes

static struct OperationRule m_operationRules []
 

Detailed Description

Description: see header file.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

Definition at line 17 of file GlobalLogicParser.h.

Member Typedef Documentation

typedef std::vector<TokenRPN> GlobalLogicParser::RpnVector

Definition at line 46 of file GlobalLogicParser.h.

Member Enumeration Documentation

Enumerator
OP_NULL 
OP_INVALID 
OP_AND 
OP_OR 
OP_NOT 
OP_OPERAND 
OP_OPENBRACKET 
OP_CLOSEBRACKET 

Definition at line 29 of file GlobalLogicParser.h.

Constructor & Destructor Documentation

GlobalLogicParser::GlobalLogicParser ( )

constructor(s)

default constructor

Definition at line 37 of file GlobalLogicParser.cc.

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 46 of file GlobalLogicParser.cc.

GlobalLogicParser::GlobalLogicParser ( const std::string &  logicalExpressionVal)

from a constant logical expression numerical expression will be empty

Definition at line 57 of file GlobalLogicParser.cc.

GlobalLogicParser::GlobalLogicParser ( std::string &  logicalExpressionVal)

Definition at line 75 of file GlobalLogicParser.cc.

GlobalLogicParser::GlobalLogicParser ( const std::string  logicalExpressionVal,
const std::string  numericalExpressionVal 
)

from a logical and a numerical expression

Definition at line 109 of file GlobalLogicParser.cc.

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 134 of file GlobalLogicParser.cc.

GlobalLogicParser::~GlobalLogicParser ( )
virtual

destructor

Definition at line 152 of file GlobalLogicParser.cc.

Member Function Documentation

void GlobalLogicParser::addBracketSpaces ( const std::string &  srcExpression,
std::string &  dstExpression 
)
protected

add spaces before and after parantheses

Definition at line 1559 of file GlobalLogicParser.cc.

void GlobalLogicParser::buildOperandTokenVector ( )

build from the RPN vector the operand token vector dummy tokenNumber and tokenResult

Definition at line 434 of file GlobalLogicParser.cc.

void GlobalLogicParser::buildOperandTokenVectorNumExp ( )

build from the RPN vector the operand token vector using a numerical expression

Definition at line 883 of file GlobalLogicParser.cc.

bool GlobalLogicParser::buildRpnVector ( const std::string &  logicalExpressionVal)

build the rpn vector

buildRpnVector Build the postfix notation.

Parameters
expressionThe expression to be parsed.
Returns
"true" if everything was parsed. "false" if an error occured.

Definition at line 196 of file GlobalLogicParser.cc.

bool GlobalLogicParser::checkLogicalExpression ( std::string &  logicalExpressionVal)

check a logical expression for correctness - add/remove spaces if needed

Definition at line 160 of file GlobalLogicParser.cc.

void GlobalLogicParser::clearRpnVector ( )

clear possible old rpn vector

Definition at line 424 of file GlobalLogicParser.cc.

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 1133 of file GlobalLogicParser.cc.

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 1033 of file GlobalLogicParser.cc.

const bool GlobalLogicParser::expressionResult ( ) const
virtual

return the result for the logical expression require a proper operand token vector

Definition at line 685 of file GlobalLogicParser.cc.

const bool GlobalLogicParser::expressionResultNumExp ( ) const
virtual

return the result for the logical expression require a proper numerical expression

Definition at line 946 of file GlobalLogicParser.cc.

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 1228 of file GlobalLogicParser.cc.

GlobalLogicParser::OperationType GlobalLogicParser::getOperation ( const std::string &  tokenString,
OperationType  lastOperation,
TokenRPN rpnToken 
) const
protectedvirtual

getOperation Get the operation from a string and check if it is allowed

Parameters
tokenStringThe string to examine.
lastOperationThe last operation.
rpnTokenThe destination where the token for postfix notation is written to.
Returns
The Operation type or OP_INVALID, if the operation is not allowed

Definition at line 1490 of file GlobalLogicParser.cc.

const GlobalLogicParser::OperationRule * GlobalLogicParser::getRuleFromType ( OperationType  oType)
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

Parameters
oTypeThe type of the operation.
Returns
The reference to the entry or 0 if the Rule was not found.

Definition at line 1538 of file GlobalLogicParser.cc.

std::string GlobalLogicParser::logicalExpression ( ) const
inline

return the logical expression

Definition at line 84 of file GlobalLogicParser.h.

std::string GlobalLogicParser::numericalExpression ( ) const
inline

return the numerical expression

Definition at line 90 of file GlobalLogicParser.h.

int GlobalLogicParser::operandIndex ( const std::string &  operandNameVal) const

return the position index of the operand in the logical expression

Definition at line 496 of file GlobalLogicParser.cc.

std::string GlobalLogicParser::operandName ( const int  iOperand) const

return the name of the (iOperand)th operand in the logical expression

Definition at line 568 of file GlobalLogicParser.cc.

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 642 of file GlobalLogicParser.cc.

bool GlobalLogicParser::operandResult ( const int  tokenNumberVal) const

return the result for an operand with tokenNumberVal using the operand token vector

Definition at line 663 of file GlobalLogicParser.cc.

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 769 of file GlobalLogicParser.cc.

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 785 of file GlobalLogicParser.cc.

std::vector<OperandToken>& GlobalLogicParser::operandTokenVector ( )
inline

return the vector of operand tokens

Definition at line 108 of file GlobalLogicParser.h.

const std::vector<OperandToken>& GlobalLogicParser::operandTokenVector ( ) const
inline

Definition at line 109 of file GlobalLogicParser.h.

RpnVector GlobalLogicParser::rpnVector ( ) const
inline

return the RPN vector

Definition at line 101 of file GlobalLogicParser.h.

Referenced by GlobalAlgorithm::GlobalAlgorithm().

bool GlobalLogicParser::setLogicalExpression ( const std::string &  logicalExpressionVal)
protected

set the logical expression - check for correctness the input string

Definition at line 1587 of file GlobalLogicParser.cc.

bool GlobalLogicParser::setNumericalExpression ( const std::string &  numericalExpressionVal)
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 1618 of file GlobalLogicParser.cc.

Member Data Documentation

std::string GlobalLogicParser::m_logicalExpression
protected

logical expression to be parsed

Definition at line 198 of file GlobalLogicParser.h.

std::string GlobalLogicParser::m_numericalExpression
protected

numerical expression (logical expression with operands replaced with the actual values)

Definition at line 202 of file GlobalLogicParser.h.

std::vector<OperandToken> GlobalLogicParser::m_operandTokenVector
protected

vector of operand tokens

Definition at line 208 of file GlobalLogicParser.h.

struct OperationRule GlobalLogicParser::m_operationRules[]
staticprotected

Definition at line 180 of file GlobalLogicParser.h.

RpnVector GlobalLogicParser::m_rpnVector
protected

RPN vector - equivalent to the logical expression.

Definition at line 205 of file GlobalLogicParser.h.