# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

automata_desc.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX D.T.C. SYSTEM.
00010  * NEVRAX D.T.C. SYSTEM 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 D.T.C. SYSTEM 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 D.T.C. SYSTEM; 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 NL_AUTOMATADESC_H
00027 #define NL_AUTOMATADESC_H
00028 
00029 #include "nel/misc.h"
00030 #include <list>
00031 #include <map>
00032 #include <set>
00033 
00034 
00044 class CAutomataDesc : public NLMISC::IStreamable
00045 {
00046 public:
00047         static const sint32 IDSUCCESS;  // = -1
00048         static const sint32 IDFAIL;             // = -2
00049 
00051         CAutomataDesc();
00053         virtual ~CAutomataDesc() {}
00054 
00056         std::string     getAutomatName() const;
00057 
00062         const std::list<sint32> &getEntryStates() const;
00063 
00068         const std::list<sint32> &getSuccessStates(sint32 stateId) const;
00069 
00074         const std::list<sint32> &getFailStates(sint32 stateId) const;
00075 
00077         std::string getStateName(sint32 stateId) const;
00078 
00083         void setAutomatName(std::string name);
00084         void addState(sint32 id, std::string name);
00085         void addSuccessState(sint32 id, sint32 successId);
00086         void addFailState(sint32 id, sint32 faileId);
00087         void addEntryState(sint32 entryId);
00088         void setVisitedState(sint32 stateId);
00089         bool visitedState(sint32 stateId);
00090         void setExploredState(sint32 stateId);
00092 
00094 
00095         void serial(NLMISC::IStream &f) throw(NLMISC::EStream)
00096         {
00097                 f.serialCont(_States);
00098                 f.serialCont(_EntryStates);
00099                 f.serial(_AutomatName);
00100         }
00101         std::string getClassName();
00103 
00104 
00105         void generateScript();
00106         std::string removeSpaces(std::string &);
00107 
00108 private :
00109         struct CState
00110         {
00111                 std::string                     Name;
00112                 std::list<sint32>       SuccessStates;
00113                 std::list<sint32>       FailStates;
00114 
00115                 void serial(NLMISC::IStream &f)
00116                 {
00117                         f.serial(Name);
00118                         f.serialCont(SuccessStates);
00119                         f.serialCont(FailStates);
00120                 }
00121         };
00122         
00123         std::map<sint32,CState> _States;
00124         std::list<sint32>               _EntryStates;
00125         std::set<sint32>                _VisitedState;
00126         std::set<sint32>                _ExploredState;
00127         std::string                             _AutomatName;
00128 
00129         bool exploredState(sint32 stateId);
00130 };
00131 
00132 
00133 #endif // NL_AUTOMATADESC_H
00134 
00135 /* End of automata_desc.h */