Home | nevrax.com |
|
logic_condition.hGo to the documentation of this file.00001 00007 /* Copyright, 2000 Nevrax Ltd. 00008 * 00009 * This file is part of NEVRAX NEL. 00010 * NEVRAX NEL is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2, or (at your option) 00013 * any later version. 00014 00015 * NEVRAX NEL is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 00020 * You should have received a copy of the GNU General Public License 00021 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00023 * MA 02111-1307, USA. 00024 */ 00025 00026 #ifndef LOGIC_CONDITION_H 00027 #define LOGIC_CONDITION_H 00028 00029 #include "nel/misc/types_nl.h" 00030 #include "nel/misc/stream.h" 00031 00032 namespace NLLOGIC 00033 { 00034 00035 class CLogicStateMachine; 00036 class CLogicConditionNode; 00037 00045 class CLogicComparisonBlock 00046 { 00048 CLogicStateMachine * _LogicStateMachine; 00049 00050 public: 00051 00053 std::string VariableName; 00054 00056 std::string Operator; 00057 00059 sint64 Comparand; 00060 00064 CLogicComparisonBlock() 00065 { 00066 _LogicStateMachine = 0; 00067 VariableName = "no_name"; 00068 Operator = ">"; 00069 Comparand = 0; 00070 } 00071 00077 void setLogicStateMachine( CLogicStateMachine * logicStateMachine ); 00078 00084 bool testLogic(); 00085 00089 void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); 00090 }; 00091 00092 00093 00094 00095 00103 class CLogicConditionLogicBlock 00104 { 00106 CLogicStateMachine * _LogicStateMachine; 00107 00108 public: 00109 00111 enum TLogicConditionLogicBlockType 00112 { 00113 NOT = 0, 00114 COMPARISON, 00115 SUB_CONDITION, 00116 }; 00117 00119 TLogicConditionLogicBlockType Type; 00120 00122 std::string SubCondition; 00123 00125 CLogicComparisonBlock ComparisonBlock; 00126 00130 CLogicConditionLogicBlock() 00131 { 00132 Type = SUB_CONDITION; 00133 SubCondition = "no_condition"; 00134 } 00135 00141 bool isNotBlock() const { return (Type == NOT); } 00142 00148 void setLogicStateMachine( CLogicStateMachine * logicStateMachine ); 00149 00155 bool testLogic(); 00156 00162 void fillVarSet( std::set<std::string>& condVars ); 00163 00167 void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); 00168 }; 00169 00170 00171 00179 class CLogicConditionNode 00180 { 00182 CLogicStateMachine * _LogicStateMachine; 00183 00184 public: 00185 00187 enum TConditionNodeType 00188 { 00189 TERMINATOR = 0, 00190 LOGIC_NODE 00191 }; 00192 00194 TConditionNodeType Type; 00195 00196 // if this node is a logical node : 00198 CLogicConditionLogicBlock LogicBlock; 00199 00201 std::vector<CLogicConditionNode *> _Nodes; 00202 00206 CLogicConditionNode() 00207 { 00208 _LogicStateMachine = 0; 00209 Type = TERMINATOR; 00210 } 00211 00217 void setLogicStateMachine( CLogicStateMachine * logicStateMachine ); 00218 00224 void addNode( CLogicConditionNode * node ); 00225 00231 bool testLogic(); 00232 00238 void fillVarSet( std::set<std::string>& condVars ); 00239 00243 void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); 00244 00248 ~CLogicConditionNode(); 00249 }; 00250 00251 00252 00253 00261 class CLogicCondition 00262 { 00264 std::string _ConditionName; 00265 00266 public: 00267 00269 std::vector<CLogicConditionNode> Nodes; 00270 00274 CLogicCondition() 00275 { 00276 _ConditionName = "no_condition"; 00277 } 00278 00284 void setLogicStateMachine( CLogicStateMachine * logicStateMachine ); 00285 00291 void setName( std::string name ) { _ConditionName = name; } 00292 00298 std::string getName() { return _ConditionName; } 00299 00305 void addNode( CLogicConditionNode node ) { Nodes.push_back( node ); } 00306 00312 bool testLogic(); 00313 00319 void fillVarSet( std::set<std::string>& condVars ); 00320 00324 void serial(class NLMISC::IStream &f) throw(NLMISC::EStream); 00325 }; 00326 00327 } // NLLOGIC 00328 00329 #endif //LOGIC_CONDITION 00330 00331 00332 |