NLLOGIC::CLogicConditionLogicBlock Class Reference

#include <logic_condition.h>


Detailed Description

CLogicConditionLogicBlock

Author:
Stephane Coutelas

Nevrax France

Date:
2001

Definition at line 108 of file logic_condition.h.

Public Types

enum  TLogicConditionLogicBlockType { NOT = 0, COMPARISON, SUB_CONDITION }
 all condition logic block types More...


Public Member Functions

 CLogicConditionLogicBlock ()
void fillVarSet (std::set< std::string > &condVars)
bool isNotBlock () const
void read (xmlNodePtr node)
void setLogicStateMachine (CLogicStateMachine *logicStateMachine)
bool testLogic ()
void write (xmlNodePtr node) const

Data Fields

CLogicComparisonBlock ComparisonBlock
 comparison block

std::string SubCondition
 name of the sub-condition

TLogicConditionLogicBlockType Type
 type of this condition block


Private Attributes

CLogicStateMachine_LogicStateMachine
 state machine managing this logic block


Member Enumeration Documentation

enum NLLOGIC::CLogicConditionLogicBlock::TLogicConditionLogicBlockType
 

all condition logic block types

Enumeration values:
NOT 
COMPARISON 
SUB_CONDITION 

Definition at line 116 of file logic_condition.h.

Referenced by read().

00117         {
00118                 NOT = 0,
00119                 COMPARISON,
00120                 SUB_CONDITION,
00121         };


Constructor & Destructor Documentation

NLLOGIC::CLogicConditionLogicBlock::CLogicConditionLogicBlock  )  [inline]
 

Default constructor

Definition at line 135 of file logic_condition.h.

References SUB_CONDITION, and SubCondition.

00136         {
00137                 Type = SUB_CONDITION;
00138                 SubCondition = "no_condition";
00139         }


Member Function Documentation

void NLLOGIC::CLogicConditionLogicBlock::fillVarSet std::set< std::string > &  condVars  ) 
 

Fill a set with all the variables name referenced by this condition

Parameters:
condVars a set to store the variable names

Definition at line 193 of file logic_condition.cpp.

References COMPARISON, ComparisonBlock, condition, NLLOGIC::CLogicStateMachine::getCondition(), SUB_CONDITION, SubCondition, and NLLOGIC::CLogicComparisonBlock::VariableName.

Referenced by NLLOGIC::CLogicConditionNode::fillVarSet().

00194 {
00195         if( Type == COMPARISON )
00196         {
00197                 condVars.insert( ComparisonBlock.VariableName );
00198         }
00199         else
00200         {
00201                 if( Type == SUB_CONDITION )
00202                 {
00203                         CLogicCondition condition;
00204                         if( _LogicStateMachine->getCondition(SubCondition,condition) )
00205                         {
00206                                 condition.fillVarSet( condVars );
00207                         }
00208                 }
00209         }
00210 
00211 } // fillVarSet //

bool NLLOGIC::CLogicConditionLogicBlock::isNotBlock  )  const [inline]
 

Return info about the type of the block

Returns:
true if this block is a NOT block

Definition at line 146 of file logic_condition.h.

References NOT.

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

00146 { return (Type == NOT); }

void NLLOGIC::CLogicConditionLogicBlock::read xmlNodePtr  node  ) 
 

Definition at line 265 of file logic_condition.cpp.

References COMPARISON, ComparisonBlock, NLLOGIC::getXMLProp(), NOT, NLLOGIC::CLogicComparisonBlock::read(), SUB_CONDITION, SubCondition, TLogicConditionLogicBlockType, and NLLOGIC::xmlCheckNodeName().

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

00266 {
00267         xmlCheckNodeName (node, "CONDITION_LOGIC_NODE");
00268 
00269         Type = (TLogicConditionLogicBlockType)atoi(getXMLProp (node, "Type").c_str());
00270         switch( Type )
00271         {
00272                 case NOT : break;
00273                         
00274                 case COMPARISON :
00275                 {
00276                         ComparisonBlock.read (node);
00277                 }
00278                 break;
00279 
00280                 case SUB_CONDITION :
00281                 {
00282                         SubCondition = getXMLProp (node, "SubCondition");
00283                 }
00284                 break;
00285         };
00286 }

void NLLOGIC::CLogicConditionLogicBlock::setLogicStateMachine CLogicStateMachine logicStateMachine  ) 
 

Set the logic state machine

Parameters:
logicStateMachine is the state machine containing this block

Definition at line 126 of file logic_condition.cpp.

References ComparisonBlock, nlwarning, and NLLOGIC::CLogicComparisonBlock::setLogicStateMachine().

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

00127 { 
00128         if( logicStateMachine == 0 )
00129         {
00130                 nlwarning("(LOGIC)<CCLogicConditionLogicBlock::setLogicStateMachine> The state machine is null");
00131         }
00132         else
00133         {
00134                 // set the state machine of this node
00135                 _LogicStateMachine = logicStateMachine; 
00136 
00137                 // set the state machine of the logic block 
00138                 ComparisonBlock.setLogicStateMachine( logicStateMachine );
00139         }
00140 
00141 } // setLogicStateMachine //

bool NLLOGIC::CLogicConditionLogicBlock::testLogic  ) 
 

Test the condition

Returns:
true if this condition is fulfiled, false else

Definition at line 148 of file logic_condition.cpp.

References COMPARISON, ComparisonBlock, condition, NLLOGIC::CLogicStateMachine::getCondition(), NLLOGIC::CLogicStateMachine::getName(), nlerror, nlwarning, NOT, SUB_CONDITION, SubCondition, and NLLOGIC::CLogicComparisonBlock::testLogic().

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

00149 {
00150         switch( Type )
00151         {
00152                 case NOT :
00153                 {
00154                         return true;
00155                 }
00156                 break;
00157 
00158                 case COMPARISON :
00159                 {
00160                         return ComparisonBlock.testLogic();
00161                 }
00162                 break;
00163 
00164                 case SUB_CONDITION :
00165                 {
00166                         CLogicCondition condition;
00167                         if( _LogicStateMachine->getCondition(SubCondition,condition) )
00168                         {
00169                                 return condition.testLogic();
00170                         }
00171                         else
00172                         {
00173                                 nlwarning("(LOGIC)<CLogicConditionLogicBlock::testLogic> The subcondition \"%s\" is unknown in the state machine \"%s\"",
00174                                         SubCondition.c_str(),_LogicStateMachine->getName().c_str());
00175                         }
00176                         
00177                 }
00178 
00179                 default :
00180                         nlerror("(LOGIC)<CLogicConditionLogicBlock::testLogic> logic block type %d is unknown",Type);
00181         }
00182         
00183         return false;
00184 
00185 } // testLogic //

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

serial

Definition at line 243 of file logic_condition.cpp.

References COMPARISON, ComparisonBlock, NOT, SUB_CONDITION, SubCondition, uint32, and NLLOGIC::CLogicComparisonBlock::write().

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

00244 {
00245         xmlNodePtr elmPtr = xmlNewChild ( node, NULL, (const xmlChar*)"CONDITION_LOGIC_NODE", NULL);
00246         xmlSetProp (elmPtr, (const xmlChar*)"Type", (const xmlChar*)toString((uint32)Type).c_str());
00247         switch( Type )
00248         {
00249                 case NOT : break;
00250                         
00251                 case COMPARISON :
00252                 {
00253                         ComparisonBlock.write(elmPtr);
00254                 }
00255                 break;
00256 
00257                 case SUB_CONDITION :
00258                 {
00259                         xmlSetProp (elmPtr, (const xmlChar*)"SubCondition", (const xmlChar*)SubCondition.c_str());
00260                 }
00261                 break;
00262         };
00263 }


Field Documentation

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

state machine managing this logic block

Definition at line 111 of file logic_condition.h.

CLogicComparisonBlock NLLOGIC::CLogicConditionLogicBlock::ComparisonBlock
 

comparison block

Definition at line 130 of file logic_condition.h.

Referenced by fillVarSet(), read(), setLogicStateMachine(), testLogic(), and write().

std::string NLLOGIC::CLogicConditionLogicBlock::SubCondition
 

name of the sub-condition

Definition at line 127 of file logic_condition.h.

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

TLogicConditionLogicBlockType NLLOGIC::CLogicConditionLogicBlock::Type
 

type of this condition block

Definition at line 124 of file logic_condition.h.


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