NLLOGIC::CLogicVariable Class Reference

#include <logic_variable.h>

Inheritance diagram for NLLOGIC::CLogicVariable:

NLLOGIC::CLogicCounter

Detailed Description

CLogicVariable

Author:
Stephane Coutelas

Nevrax France

Date:
2001

Definition at line 44 of file logic_variable.h.

Public Member Functions

void applyModification (std::string op, sint64 value)
 CLogicVariable ()
std::string getName () const
sint64 getValue () const
virtual void processLogic ()
virtual void read (xmlNodePtr node)
void setName (std::string name)
void setValue (sint64 value)
void setVerbose (bool b)
virtual void write (xmlNodePtr node) const

Protected Attributes

std::string _Name
 variable name

sint64 _Value
 variable value

bool _Verbose
 true if verbose mode is active


Constructor & Destructor Documentation

NLLOGIC::CLogicVariable::CLogicVariable  ) 
 

Default constructor

Definition at line 42 of file logic_variable.cpp.

References _Verbose.

00043 {
00044         _Value = 0;
00045         _Name = "unamed_var";
00046         _Verbose = false;
00047 
00048 } // CLogicVariable //


Member Function Documentation

void NLLOGIC::CLogicVariable::applyModification std::string  op,
sint64  value
 

Apply modifications on a variable

Parameters:
op can be one of these operators :"SET"("set"),"ADD"("add"),"SUB"("sub"),"MUL"("mul"),"DIV"("div")
value is the value to use along with the modificator

Definition at line 73 of file logic_variable.cpp.

References _Verbose, nlinfo, nlwarning, sint64, and value.

00074 {
00075         if( op == "SET" || op == "set" )
00076         {
00077                 _Value = value;
00078         }
00079         else
00080         if( op == "ADD" || op == "add" )
00081         {
00082                 _Value += value;
00083         }
00084         else
00085         if( op == "SUB" || op == "sub" )
00086         {
00087                 _Value -= value;
00088         }
00089         else
00090         if( op == "MUL" || op == "mul")
00091         {
00092                 _Value *= value;
00093         }
00094         else
00095         if( op == "DIV" || op == "div")
00096         {
00097                 if( value != 0 ) _Value /= value;
00098         }
00099         else
00100         {
00101                 nlwarning("(LGCS)<CLogicVariable::applyModification> The operator \"%s\" is unknown",op.c_str());
00102                 return;
00103         }
00104 
00105         if( _Verbose )
00106         {
00107                 nlinfo("variable \"%s\" value is now %f",_Name.c_str(),(double)_Value);
00108         }
00109 
00110 } // applyModification //

std::string NLLOGIC::CLogicVariable::getName void   )  const [inline]
 

Get the variable name

Returns:
the name of the variable

Definition at line 76 of file logic_variable.h.

Referenced by NLLOGIC::CLogicStateMachine::addCounter(), and NLLOGIC::CLogicStateMachine::addVariable().

00076 { return _Name; }

sint64 NLLOGIC::CLogicVariable::getValue  )  const [inline]
 

Get the variable value

Returns:
the variable's value

Definition at line 90 of file logic_variable.h.

References sint64.

Referenced by NLLOGIC::CLogicCounter::manageRunningMode(), NLLOGIC::CLogicComparisonBlock::testLogic(), NLLOGIC::CLogicCounter::update(), and NLLOGIC::CLogicCounter::write().

00090 { return _Value; }

void NLLOGIC::CLogicVariable::processLogic  )  [virtual]
 

update the variable

Definition at line 117 of file logic_variable.cpp.

00118 {
00119 
00120 
00121 } // processLogic //

void NLLOGIC::CLogicVariable::read xmlNodePtr  node  )  [virtual]
 

Reimplemented in NLLOGIC::CLogicCounter.

Definition at line 147 of file logic_variable.cpp.

References _Verbose, NLLOGIC::getXMLProp(), and NLLOGIC::xmlCheckNodeName().

00148 {
00149         xmlCheckNodeName (node, "VARIABLE");
00150 
00151         _Name = getXMLProp (node, "Name");
00152         _Value = atoiInt64 (getXMLProp (node, "Value").c_str());
00153         _Verbose = atoi(getXMLProp (node, "Verbose").c_str()) == 1;
00154 }

void NLLOGIC::CLogicVariable::setName std::string  name  )  [inline]
 

Set the variable name

Parameters:
name is the name of the variable

Definition at line 69 of file logic_variable.h.

Referenced by NLLOGIC::CLogicCounter::CLogicCounter().

00069 { _Name = name; }

void NLLOGIC::CLogicVariable::setValue sint64  value  ) 
 

Set the variable value

Parameters:
value is the new value of the variable

Definition at line 56 of file logic_variable.cpp.

References _Verbose, nlinfo, sint64, and value.

Referenced by NLLOGIC::CLogicCounter::CLogicCounter(), NLLOGIC::CLogicCounter::manageRunningMode(), NLLOGIC::CLogicCounter::read(), and NLLOGIC::CLogicCounter::update().

00057 { 
00058         _Value = value;
00059         
00060         if( _Verbose )
00061         {
00062                 nlinfo("variable \"%s\" value is now %f",_Name.c_str(),(double)_Value);
00063         }
00064 
00065 } // setValue //

void NLLOGIC::CLogicVariable::setVerbose bool  b  )  [inline]
 

Set the verbose mode active or inactive

Parameters:
varName is the name of the variable
b is true to activate the verbose mode, false else

Definition at line 98 of file logic_variable.h.

References _Verbose.

00098 { _Verbose = b; }

void NLLOGIC::CLogicVariable::write xmlNodePtr  node  )  const [virtual]
 

serial

Reimplemented in NLLOGIC::CLogicCounter.

Definition at line 139 of file logic_variable.cpp.

References _Verbose.

00140 {
00141         xmlNodePtr elmPtr = xmlNewChild ( node, NULL, (const xmlChar*)"VARIABLE", NULL);
00142         xmlSetProp (elmPtr, (const xmlChar*)"Name", (const xmlChar*)_Name.c_str());
00143         xmlSetProp (elmPtr, (const xmlChar*)"Value", (const xmlChar*)toString(_Value).c_str());
00144         xmlSetProp (elmPtr, (const xmlChar*)"Verbose", (const xmlChar*)toString(_Verbose).c_str());
00145 }


Field Documentation

std::string NLLOGIC::CLogicVariable::_Name [protected]
 

variable name

Definition at line 52 of file logic_variable.h.

sint64 NLLOGIC::CLogicVariable::_Value [protected]
 

variable value

Definition at line 49 of file logic_variable.h.

bool NLLOGIC::CLogicVariable::_Verbose [protected]
 

true if verbose mode is active

Definition at line 55 of file logic_variable.h.

Referenced by applyModification(), CLogicVariable(), read(), setValue(), setVerbose(), and write().


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