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

FSMState.h

Go to the documentation of this file.
00001 #if !defined(AFX_FSMSTATE_H__72C06899_E8FF_4311_A306_97314E778192__INCLUDED_)
00002 #define AFX_FSMSTATE_H__72C06899_E8FF_4311_A306_97314E778192__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: FSMState.h,v $
00029 // Revision 1.4  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.3  2002/08/13 11:06:32  vofka
00033 // automake support added
00034 //
00035 // Revision 1.2  2002/07/22 17:21:00  vofka
00036 // SimpleTransition, PushTransition, PopTransition added, not implemented yet
00037 //
00038 // Revision 1.1  2002/06/28 11:10:36  vofka
00039 // first time on sourceforge.net cvs
00040 //
00041 // Revision 1.5  2002/06/20 12:22:10  bobka
00042 // LGPL license
00043 //
00044 // Revision 1.4  2002/05/03 23:21:56  bobka
00045 // Loader externalisiert, aber der alte ist noch drin.
00046 // Iterators for states und variables added.
00047 // some minor bugs fixed.
00048 //
00049 // Revision 1.3  2001/11/28 15:42:00  bobka
00050 // a lot of changes
00051 //
00052 // Revision 1.2  2001/11/23 09:27:58  bobka
00053 // Load/Save funktioniert.
00054 // FSM* im Fileformat entfernt.
00055 // streams entfernt.
00056 // Laeuft unter Win32 und unter WinCE (WinCE_STL Modul auschecken)
00057 // static library unter WinCE funktioniert nicht, nur DLL.
00058 //
00059 // Revision 1.1  2001/11/15 10:37:32  bobka
00060 // initial checkin
00061 // not tested on linux!
00062 //
00063 
00064 // Base-Class
00065 #include "FSMObject.h"
00066 
00068 namespace FSM {
00069 
00070 // forward reference
00071 class CFiniteStateMachine;
00072 class CFSMTransition;
00073 class CFSMAction;
00074 class CFSMCondition;
00075 
00076 typedef list< CFSMTransition* > Transition_List;
00077 typedef list< CFSMAction* > Action_List;
00078 
00079 class CFSMState : public CFSMObject
00080 {
00081         public:
00082                 friend class CFiniteStateMachine;
00083 
00084                 //Transitions
00085                 CFSMTransition* AddTransition(const char* onEvent="ANY", const char *className="SimpleTransition");
00086                 CFSMTransition* AddSimpleTransition(const char *toStateName, const char* onEvent="ANY");
00087 
00089                 int GetTransitionNumber() const;
00090 
00092                 CFSMTransition* GetTransition(int index) const;
00093 
00095                 bool DeleteTransition(CFSMTransition* trans);
00096 
00102                 Transition_List::const_iterator GetTransitionsBegin() const;
00103 
00105                 Transition_List::const_iterator GetTransitionsEnd() const;
00106                 
00107                 // Enter/Leave Actions
00109                 CFSMAction* AddEnterAction(const char *className);
00110 
00112                 CFSMAction* AddLeaveAction(const char *className);
00113 
00115                 bool DeleteAction(CFSMAction *action);
00116 
00118                 CFSMAction* GetEnterAction(int index) const;
00119 
00121                 CFSMAction* GetLeaveAction(int index) const;
00122 
00128                 Action_List::const_iterator GetEnterActionsBegin() const;
00129 
00131                 Action_List::const_iterator GetEnterActionsEnd() const;
00132                 
00138                 Action_List::const_iterator GetLeaveActionsBegin() const;
00139 
00141                 Action_List::const_iterator GetLeaveActionsEnd() const;
00142                 
00143                 // Get/Set
00144                 const char*     GetName() const;
00145 
00146         protected:
00147                 // Construction/Destruction
00148                 static CFSMObject *Create();
00149                 virtual void DeleteThis();
00150 
00151                 // Set
00152                 void SetName(const char *name);
00153                 
00154                 // overloadables called by CFiniteStateMachine
00163                 virtual bool GetTransition(CFSMTransition** trans, const char *event, void *a, void *b);
00164 
00169                 virtual bool Activate();
00170 
00175                 virtual bool Deactivate();
00176 
00178                 Transition_List m_Transitions;
00179 
00181                 Action_List m_EnterActions;
00182 
00184                 Action_List m_LeaveActions;
00185 
00187                 CFSMState(); 
00188 
00190                 virtual ~CFSMState();
00191 
00192         private:
00193 
00194                 string m_Name;
00195 };
00196 
00197 }; // namespace FSM
00198 
00199 #endif // !defined(AFX_FSMSTATE_H__72C06899_E8FF_4311_A306_97314E778192__INCLUDED_)

© 2002 by C-LAB
generated by doxygen