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

FSMLoader.h

Go to the documentation of this file.
00001 #if !defined(_FSMLoader_H_)
00002 #define _FSMLoader_H_
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: FSMLoader.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.2  2002/06/20 12:22:10  bobka
00036 // LGPL license
00037 //
00038 // Revision 1.1  2002/05/03 23:21:56  bobka
00039 // Loader externalisiert, aber der alte ist noch drin.
00040 // Iterators for states und variables added.
00041 // some minor bugs fixed.
00042 //
00043 
00044 
00045 
00046 #include <cstdio>
00047 #include "FiniteStateMachine.h"
00048 
00050 namespace FSM {
00051 
00052 class CTokenizer;
00053 
00057 class CFSMLoader
00058 {
00059         public:
00060                 CFSMLoader(CFiniteStateMachine *fsm);
00061                 virtual ~CFSMLoader();
00062 
00063         protected:
00064                 CFiniteStateMachine* m_FSM;
00065 };
00066 
00070 class CFSMSimpleLoaderXML : public CFSMLoader
00071 {
00072         public:
00073                 CFSMSimpleLoaderXML(CFiniteStateMachine *fsm);
00074                 virtual ~CFSMSimpleLoaderXML();
00075 
00076                 // Input/Output FSM
00077                 bool Load(const char *filename);
00078                 bool Load(FILE *inFile);
00079 
00080         protected:
00081                 bool LoadFSM();
00082                 bool LoadVariable();
00083                 bool LoadState();
00084                 bool LoadParam(CFSMObject* obj);
00085                 bool LoadEnterAction(CFSMState* state);
00086                 bool LoadTransition(CFSMState* state);
00087                 bool LoadLeaveAction(CFSMState* state);
00088                 bool LoadTransAction(CFSMTransition* trans);
00089                 bool LoadCondition(CFSMTransition* trans);
00090 
00091         private:
00092                 CTokenizer* m_Tokenizer;
00093 };
00094 
00099 class CFSMLoaderXML : public CFSMLoader
00100 {
00101         public:
00102                 CFSMLoaderXML(CFiniteStateMachine *fsm);
00103                 virtual ~CFSMLoaderXML();
00104 
00105                 // Input/Output FSM
00106                 bool Load(const char *filename);
00107 
00108         protected:
00109 
00110         private:
00111 };
00112 
00116 class CFSMSaver
00117 {
00118         public:
00119                 CFSMSaver(const CFiniteStateMachine *fsm);
00120                 virtual ~CFSMSaver();
00121 
00126                 virtual bool SaveParameter(const char* name, const char* value) const =0;
00127                 
00128         protected:
00132                 bool SaveParameters(const CFSMObject* obj);
00133                 
00134                 const CFiniteStateMachine* m_FSM;
00135 };
00136 
00140 class CFSMSaverXML : public CFSMSaver
00141 {
00142         public:
00143                 CFSMSaverXML(const CFiniteStateMachine *fsm);
00144                 virtual ~CFSMSaverXML();
00145 
00146                 // Output FSM
00147                 bool Save(const char *filename);
00148                 bool Save(FILE *outFile);
00149 
00150                 // overloaded
00151                 virtual bool SaveParameter(const char* name, const char* value);
00152                 
00153         protected:
00154                 virtual bool SaveState(const CFSMState* state);
00155                 virtual bool SaveTransition(const CFSMTransition* trans);
00156                 virtual bool SaveAction(const CFSMAction *action, const char* tag="Action");
00157                 virtual bool SaveCondition(const CFSMCondition *cond);
00158 
00159         private:
00160                 const CFiniteStateMachine* m_FSM;
00161                 FILE* m_File;
00162 };
00163 
00164 }; // namespace FSM
00165 
00166 #endif // !defined(_FSMLoader_H_)

© 2002 by C-LAB
generated by doxygen