#include <automata_desc.h>
Inheritance diagram for CAutomataDesc:

Nevrax France
Definition at line 44 of file automata_desc.h.
Public Member Functions | |
| CAutomataDesc () | |
| Constructor. | |
| void | generateScript () |
| std::string | getAutomatName () const |
| Give the automat name. | |
| const std::list< sint32 > & | getEntryStates () const |
| const std::list< sint32 > & | getFailStates (sint32 stateId) const |
| std::string | getStateName (sint32 stateId) const |
| Gives the name of a state. | |
| const std::list< sint32 > & | getSuccessStates (sint32 stateId) const |
| std::string | removeSpaces (std::string &) |
| virtual | ~CAutomataDesc () |
| Destructor. | |
Build Fonctions | |
| void | addEntryState (sint32 entryId) |
| void | addFailState (sint32 id, sint32 faileId) |
| void | addState (sint32 id, std::string name) |
| void | addSuccessState (sint32 id, sint32 successId) |
| void | setAutomatName (std::string name) |
| void | setExploredState (sint32 stateId) |
| void | setVisitedState (sint32 stateId) |
| bool | visitedState (sint32 stateId) |
Derived from NLMISC::IStreamable | |
| std::string | getClassName () |
| void | serial (NLMISC::IStream &f) throw (NLMISC::EStream) |
Static Public Attributes | |
| const sint32 | IDFAIL = -2 |
| const sint32 | IDSUCCESS = -1 |
Private Member Functions | |
| bool | exploredState (sint32 stateId) |
Private Attributes | |
| std::string | _AutomatName |
| std::list< sint32 > | _EntryStates |
| std::set< sint32 > | _ExploredState |
| std::map< sint32, CState > | _States |
| std::set< sint32 > | _VisitedState |
|
|
Constructor.
Definition at line 35 of file automata_desc.cpp. References addState(), IDFAIL, and IDSUCCESS.
|
|
|
Destructor.
Definition at line 53 of file automata_desc.h.
00053 {}
|
|
|
Definition at line 108 of file automata_desc.cpp. References _EntryStates, and sint32.
00109 {
00110 _EntryStates.push_back(entryId);
00111 }
|
|
||||||||||||
|
Definition at line 100 of file automata_desc.cpp. References _States, exploredState(), and sint32.
00101 {
00102 if (!exploredState(id))
00103 {
00104 _States[id].FailStates.push_back(faileId);
00105 }
00106 }
|
|
||||||||||||
|
Definition at line 84 of file automata_desc.cpp. References _States, exploredState(), and sint32. Referenced by CAutomataDesc().
00085 {
00086 if (!exploredState(id))
00087 {
00088 _States[id].Name = name;
00089 }
00090 }
|
|
||||||||||||
|
Definition at line 92 of file automata_desc.cpp. References _States, exploredState(), and sint32.
00093 {
00094 if (!exploredState(id))
00095 {
00096 _States[id].SuccessStates.push_back(successId);
00097 }
00098 }
|
|
|
Definition at line 113 of file automata_desc.cpp. References _ExploredState, and sint32. Referenced by addFailState(), addState(), and addSuccessState().
00114 {
00115 std::set<sint32>::const_iterator iSet = _ExploredState.find(stateId);
00116 return (iSet != _ExploredState.end());
00117 }
|
|
|
Definition at line 129 of file automata_desc.cpp. References _States, getAutomatName(), getEntryStates(), getFailStates(), getStateName(), getSuccessStates(), IDFAIL, IDSUCCESS, removeSpaces(), and sint32.
00130 {
00131 ofstream tmp_script( "fsm_script.ras");
00132
00133 // Succes and failure states
00134 /* tmp_script << "From Actor : Define SuccessState" << endl << "{" << endl;
00135 tmp_script << "}" << endl << endl;
00136 tmp_script << "From Actor : Define FailureState" << endl << "{" << endl;
00137 tmp_script << "}" << endl << endl;
00138 */
00139
00140 tmp_script << "// " << getAutomatName() << " FSM definition generated script" << endl << endl;
00141 std::string name;
00142 // Generates states
00143 std::map<sint32,CState>::const_iterator it_m = _States.begin();
00144 while ( it_m != _States.end() )
00145 {
00146 sint32 state_id = (*it_m).first;
00147
00148 name = getStateName( state_id );
00149 // State name
00150 std::string state_name = removeSpaces( name );
00151
00152 tmp_script << "From Actor : Define " << "Actor" << state_name << endl << "{" << endl;
00153
00154 if ( state_id != IDSUCCESS && state_id != IDFAIL )
00155 {
00156 #ifdef NL_DEBUG
00157 tmp_script << "\tOnActivate()" << endl;
00158 tmp_script << "\t\tPrint('Etat " << state_name << " actif');" << endl;
00159 tmp_script << "\tEnd" << endl << endl;
00160 #endif
00161
00162 // Success transitions
00163 tmp_script << "\tRunTell(SuccessMsg msg)" << endl;
00164 std::list<sint32>::const_iterator it_s = getSuccessStates( state_id ).begin();
00165 while ( it_s != getSuccessStates( state_id ).end() )
00166 {
00167 name = getStateName( *it_s );
00168 state_name = removeSpaces( name );
00169 tmp_script << "\t\tswitch('" << state_name << "');" << endl;
00170 it_s++;
00171 }
00172 tmp_script << "\t\tReturn msg;" << endl;
00173 tmp_script << "\tEnd" << endl << endl;
00174
00175 // Failure transitions
00176 tmp_script << "\tRunTell(FailureMsg msg)" << endl;
00177 std::list<sint32>::const_iterator it_f = getFailStates( state_id ).begin();
00178 while ( it_f != getFailStates( state_id ).end() )
00179 {
00180 name = getStateName( *it_f );
00181 state_name = removeSpaces( name );
00182 tmp_script << "\t\tswitch('" << state_name << "');" << endl;
00183 it_f++;
00184 }
00185 tmp_script << "\t\tReturn msg;" << endl;
00186 tmp_script << "\tEnd" << endl;
00187 }
00188 else
00189 {
00190 tmp_script << "\tRun()" << endl;
00191 if ( state_id == IDSUCCESS )
00192 tmp_script << "\t\tFather().Send(TELL, new SuccessMsg(0.0));" << endl;
00193 else
00194 tmp_script << "\t\tFather().Send(TELL, new FailureMsg(0.0));" << endl;
00195 tmp_script << "\tEnd" << endl;
00196 }
00197
00198 // End of the State class
00199 tmp_script << "}" << endl << endl;
00200
00201 it_m++;
00202 }
00203
00204 // Generates FSM
00205 std::string automateName = getAutomatName();
00206 std::string fsm_name = removeSpaces( automateName );
00207 tmp_script << "From Fsm : Define " << fsm_name << endl << "{" << endl;
00208
00209 // Generates states as static components of the FSM
00210 tmp_script << "\tComponent:" << endl;
00211
00212 it_m = _States.begin();
00213 while ( it_m != _States.end() )
00214 {
00215 // State name
00216 name = getStateName( (*it_m).first );
00217 std::string state_name = removeSpaces( name );
00218 tmp_script << "\t\tActor" << state_name << "<'" << state_name << "'>;" << endl;
00219 it_m++;
00220 }
00221 tmp_script << "\tEnd" << endl << endl;
00222
00223 // Activates entry states
00224 tmp_script << "\tConstructor()" << endl;
00225 std::list<sint32>::const_iterator it_e = getEntryStates().begin();
00226 while ( it_e != getEntryStates().end() )
00227 {
00228 name = getStateName( *it_e );
00229 std::string state_name = removeSpaces( name );
00230 tmp_script << "\t\t" << state_name << ".activate();" << endl;
00231 it_e++;
00232 }
00233 tmp_script << "\tEnd" << endl;
00234
00235 // End of the Fsm Class
00236 tmp_script << "}" << endl;
00237
00238 tmp_script.close();
00239 }
|
|
|
Give the automat name.
Definition at line 41 of file automata_desc.cpp. References _AutomatName. Referenced by generateScript().
00042 {
00043 return _AutomatName;
00044 }
|
|
|
Implements NLMISC::IClassable. Definition at line 124 of file automata_desc.cpp.
00125 {
00126 return "CAutomataDesc";
00127 }
|
|
|
Gives the States linked to the automat entry.
Definition at line 46 of file automata_desc.cpp. References _EntryStates. Referenced by generateScript().
00047 {
00048 return _EntryStates;
00049 }
|
|
|
Gives the States linked to the stateId fail output.
Definition at line 58 of file automata_desc.cpp. References _States, and sint32. Referenced by generateScript().
00059 {
00060 std::map<sint32,CState>::const_iterator iStates;
00061 iStates = _States.find(stateId);
00062 return (*iStates).second.FailStates;
00063 }
|
|
|
Gives the name of a state.
Definition at line 65 of file automata_desc.cpp. References _States, and sint32. Referenced by generateScript().
|
|
|
Gives the States linked to the stateId success output.
Definition at line 51 of file automata_desc.cpp. References _States, and sint32. Referenced by generateScript().
00052 {
00053 std::map<sint32,CState>::const_iterator iStates;
00054 iStates = _States.find(stateId);
00055 return (*iStates).second.SuccessStates;
00056 }
|
|
|
Definition at line 241 of file automata_desc.cpp. References buffer. Referenced by generateScript().
|
|
|
Implements NLMISC::IStreamable. Definition at line 95 of file automata_desc.h. References _AutomatName, _EntryStates, and _States.
00096 {
00097 f.serialCont(_States);
00098 f.serialCont(_EntryStates);
00099 f.serial(_AutomatName);
00100 }
|
|
|
Definition at line 79 of file automata_desc.cpp. References _AutomatName.
00080 {
00081 _AutomatName = name;
00082 }
|
|
|
Definition at line 119 of file automata_desc.cpp. References _ExploredState, and sint32.
00120 {
00121 _ExploredState.insert(stateId);
00122 }
|
|
|
|
|
|
|
|
|
Definition at line 127 of file automata_desc.h. Referenced by getAutomatName(), serial(), and setAutomatName(). |
|
|
Definition at line 124 of file automata_desc.h. Referenced by addEntryState(), getEntryStates(), and serial(). |
|
|
Definition at line 126 of file automata_desc.h. Referenced by exploredState(), and setExploredState(). |
|
|
Definition at line 123 of file automata_desc.h. Referenced by addFailState(), addState(), addSuccessState(), generateScript(), getFailStates(), getStateName(), getSuccessStates(), and serial(). |
|
|
Definition at line 125 of file automata_desc.h. |
|
|
Definition at line 30 of file automata_desc.cpp. Referenced by CAutomataDesc(), and generateScript(). |
|
|
Definition at line 29 of file automata_desc.cpp. Referenced by CAutomataDesc(), and generateScript(). |
1.3.6