NLLOGIC::CLogicComparisonBlock Class Reference

#include <logic_condition.h>


Detailed Description

CLogicComparisonBlock

Author:
Stephane Coutelas

Nevrax France

Date:
2001

Definition at line 47 of file logic_condition.h.

Public Member Functions

 CLogicComparisonBlock ()
void read (xmlNodePtr node)
void setLogicStateMachine (CLogicStateMachine *logicStateMachine)
bool testLogic ()
void write (xmlNodePtr node) const

Data Fields

sint64 Comparand
 comparand

std::string Operator
 comparison operator

std::string VariableName
 variable name


Private Attributes

CLogicStateMachine_LogicStateMachine
 state machine managing this comparison block


Constructor & Destructor Documentation

NLLOGIC::CLogicComparisonBlock::CLogicComparisonBlock  )  [inline]
 

Default constructor

Definition at line 66 of file logic_condition.h.

References _LogicStateMachine, Comparand, Operator, and VariableName.

00067         {
00068                 _LogicStateMachine = 0;
00069                 VariableName = "no_name";
00070                 Operator = ">";
00071                 Comparand = 0;
00072         }


Member Function Documentation

void NLLOGIC::CLogicComparisonBlock::read xmlNodePtr  node  ) 
 

Definition at line 107 of file logic_condition.cpp.

References Comparand, NLLOGIC::getXMLProp(), Operator, VariableName, and NLLOGIC::xmlCheckNodeName().

Referenced by NLLOGIC::CLogicConditionLogicBlock::read().

00108 {
00109         xmlCheckNodeName (node, "COMPARISON_BLOCK");
00110 
00111         VariableName = getXMLProp (node, "VariableName");
00112         Operator = getXMLProp (node, "Operator");
00113         Comparand = atoiInt64(getXMLProp (node, "Comparand").c_str());
00114 }

void NLLOGIC::CLogicComparisonBlock::setLogicStateMachine CLogicStateMachine logicStateMachine  ) 
 

Set the logic state machine

Parameters:
logicStateMachine is the state machine containing this block

Definition at line 43 of file logic_condition.cpp.

References _LogicStateMachine, and nlwarning.

Referenced by NLLOGIC::CLogicConditionLogicBlock::setLogicStateMachine().

00044 { 
00045         if( logicStateMachine == 0 )
00046         {
00047                 nlwarning("(LOGIC)<CLogicComparisonBlock::setLogicStateMachine> The state machine is null");
00048         }
00049         else
00050         {
00051                 _LogicStateMachine = logicStateMachine; 
00052         }
00053         
00054 } // setLogicStateMachine //

bool NLLOGIC::CLogicComparisonBlock::testLogic  ) 
 

Test the condition

Returns:
true if this condition is fulfiled, false else

Definition at line 61 of file logic_condition.cpp.

References _LogicStateMachine, Comparand, NLLOGIC::CLogicVariable::getValue(), NLLOGIC::CLogicStateMachine::getVariable(), nlwarning, Operator, and VariableName.

Referenced by NLLOGIC::CLogicConditionLogicBlock::testLogic().

00062 {
00063         CLogicVariable var;
00064         if( _LogicStateMachine->getVariable( VariableName, var ) == false )
00065         {
00066                 nlwarning("(LOGIC)<CLogicComparisonBlock::testLogic> The variable %s is unknown in the state machine",VariableName.c_str());
00067                 return false;
00068         }
00069 
00070         if( Operator == "<"  )  return ( var.getValue() <  Comparand );
00071         if( Operator == "<=" )  return ( var.getValue() <= Comparand );
00072         if( Operator == ">"  )  return ( var.getValue() >  Comparand );
00073         if( Operator == ">=" )  return ( var.getValue() >= Comparand );
00074         if( Operator == "==" )  return ( var.getValue() == Comparand );
00075         if( Operator == "!=" )  return ( var.getValue() != Comparand );
00076 
00077         nlwarning("(LOGIC)<CLogicComparisonBlock::testLogic> The comparison block operator %s is unknown",Operator.c_str());
00078         return false;
00079 
00080 } // testLogic //

void NLLOGIC::CLogicComparisonBlock::write xmlNodePtr  node  )  const
 

serial

Definition at line 99 of file logic_condition.cpp.

References Comparand, Operator, and VariableName.

Referenced by NLLOGIC::CLogicConditionLogicBlock::write().

00100 {
00101         xmlNodePtr elmPtr = xmlNewChild ( node, NULL, (const xmlChar*)"COMPARISON_BLOCK", NULL);
00102         xmlSetProp (elmPtr, (const xmlChar*)"VariableName", (const xmlChar*)VariableName.c_str());
00103         xmlSetProp (elmPtr, (const xmlChar*)"Operator", (const xmlChar*)Operator.c_str());
00104         xmlSetProp (elmPtr, (const xmlChar*)"Comparand", (const xmlChar*)toString(Comparand).c_str());
00105 }


Field Documentation

CLogicStateMachine* NLLOGIC::CLogicComparisonBlock::_LogicStateMachine [private]
 

state machine managing this comparison block

Definition at line 50 of file logic_condition.h.

Referenced by CLogicComparisonBlock(), setLogicStateMachine(), and testLogic().

sint64 NLLOGIC::CLogicComparisonBlock::Comparand
 

comparand

Definition at line 61 of file logic_condition.h.

Referenced by CLogicComparisonBlock(), read(), testLogic(), and write().

std::string NLLOGIC::CLogicComparisonBlock::Operator
 

comparison operator

Definition at line 58 of file logic_condition.h.

Referenced by CLogicComparisonBlock(), read(), testLogic(), and write().

std::string NLLOGIC::CLogicComparisonBlock::VariableName
 

variable name

Definition at line 55 of file logic_condition.h.

Referenced by CLogicComparisonBlock(), NLLOGIC::CLogicConditionLogicBlock::fillVarSet(), read(), testLogic(), and write().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 12:52:53 2004 for NeL by doxygen 1.3.6