SourceForge Project Site
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FSMCondition.h

Go to the documentation of this file.
00001 #if !defined(AFX_FSMCONDITION_H__A3DB3A96_76D7_4B69_A67C_8F6A8601F9B9__INCLUDED_)
00002 #define AFX_FSMCONDITION_H__A3DB3A96_76D7_4B69_A67C_8F6A8601F9B9__INCLUDED_
00003 
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007 
00008 /*
00009  * The Finite State Machine (FSM) Library
00010  * Copyright (C) 2002 Siemens C-LAB Paderborn
00011  * All rights reserved.
00012  *
00013  * This program is  free  software;  you can redistribute it and/or modify it
00014  * under the terms of the  GNU Lesser General Public License  as published by 
00015  * the  Free Software Foundation;  either version 2.1 of the License,  or (at 
00016  * your option) any later version.
00017  *
00018  * This  program  is  distributed in  the  hope that it will  be useful,  but
00019  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00020  * or  FITNESS FOR A  PARTICULAR PURPOSE.  See the  GNU Lesser General Public  
00021  * License for more details.
00022  *
00023  * You should  have received  a copy of the GNU Lesser General Public License
00024  * along with  this program;  if not, write to the  Free Software Foundation,
00025  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
00026  */
00027 
00028 // $Log: FSMCondition.h,v $
00029 // Revision 1.2  2002/08/20 14:48:41  vofka
00030 // FiniteStateMachine-config.h removed from installing. Loading exported to the loader class. Saver introduced. Error codes exported to FSMErrorCodes.
00031 //
00032 // Revision 1.1  2002/06/28 11:10:36  vofka
00033 // first time on sourceforge.net cvs
00034 //
00035 // Revision 1.5  2002/06/20 12:22:10  bobka
00036 // LGPL license
00037 //
00038 // Revision 1.4  2001/12/07 11:14:50  bobka
00039 // <!--  ... <...> ... --> fixed
00040 // <Param Name="Expression" Value="bla=42" /> to ConditionTestVariable added
00041 // <Variable .. /> fixed
00042 // '>=' and '<=' bug fixed (was hidden by '>' and '<')
00043 // SetAttribute erro at loading fixed (was not reported)
00044 //
00045 // Revision 1.3  2001/11/28 15:42:00  bobka
00046 // a lot of changes
00047 //
00048 // Revision 1.2  2001/11/23 09:27:57  bobka
00049 // Load/Save funktioniert.
00050 // FSM* im Fileformat entfernt.
00051 // streams entfernt.
00052 // Laeuft unter Win32 und unter WinCE (WinCE_STL Modul auschecken)
00053 // static library unter WinCE funktioniert nicht, nur DLL.
00054 //
00055 // Revision 1.1  2001/11/15 10:37:32  bobka
00056 // initial checkin
00057 // not tested on linux!
00058 //
00059 
00060 // Base-Class
00061 #include "FSMObject.h"
00062 
00064 namespace FSM {
00065 
00066 
00067 // forward reference
00068 class CFiniteStateMachine;
00069 
00070 class CFSMCondition :  public CFSMObject
00071 {
00072         public:
00073                 friend class CFSMTransition;
00074 
00075                 // Overloadables
00076                 virtual bool CheckCondition(const char* event, void *a, void *b) = 0;
00077 
00078         protected:
00079 
00080                 // Overloadables
00081                 virtual bool Activate();   // called when the state is activated
00082                 virtual bool Deactivate(); // called when the state is deactivated
00083 
00084                 CFSMCondition();
00085                 virtual ~CFSMCondition();
00086         private:
00087 };
00088 
00089 class CFSMConditionTestVariable :  public CFSMCondition
00090 {
00091         public:
00092                 friend class CFSMTransition;
00093                 friend class CFiniteStateMachine;
00094 
00095                 enum OP {
00096                         EQUAL,
00097                         NEQUAL,
00098                         GREATER,
00099                         LESS,
00100                         GREATER_EQ,
00101                         LESS_EQ
00102                 };
00103 
00104                 // Construction/Destruction
00105                 static CFSMObject *Create();
00106                 virtual void DeleteThis();
00107 
00108                 // Get/Set
00109                 void SetCondition(const char* varName, OP testCondition, int testValue);
00110                 bool SetExpression(const char* expression); // "bla==42"
00111 
00112                 const char* GetVariable()  const;
00113                 OP          GetCondition() const;
00114                 int         GetValue()     const;
00115 
00116                 // Overloaded
00117                 virtual bool SetParameter(const char* paramName, const char* paramValue);
00118                 virtual bool CheckCondition(const char* event, void *a, void *b);
00119 
00120         protected:
00121 
00122                 // Overloaded
00123                 virtual bool SaveParameters(CFSMSaver *out) const;
00124 
00125         private:
00126                 CFSMConditionTestVariable();
00127                 virtual ~CFSMConditionTestVariable();
00128 
00129                 string  variableName;
00130                 OP              condition;
00131                 int             value;
00132 };
00133 
00134 }; // namespace FSM
00135 
00136 #endif // !defined(AFX_FSMCONDITION_H__A3DB3A96_76D7_4B69_A67C_8F6A8601F9B9__INCLUDED_)

© 2002 by C-LAB
generated by doxygen