00001 /*! 00002 * \file fsa.C 00003 * \brief Contains the implementation of FSA (finite state automata) classes. 00004 * 00005 * \note The implementations for some other classes are in here as well, but 00006 * they should probably be moved to another file. 00007 * 00008 * \sa fsa.H 00009 * 00010 */ 00011 00012 #include "fsa.H" 00013 00014 HASH *VIEWint_list::_dhash = 0; 00015 00016 void 00017 VIEWint::rem_interactor(State *s) 00018 { 00019 FSA* fsa = 0; 00020 for (int i=0; i < _cur_states.num(); i++) { 00021 if ((fsa = _cur_states[i])->start() == s) { 00022 _cur_states.remove(i); 00023 // XXX - following line assumes interactor was 00024 // added via 00025 // VIEWint::add_interactor(State *s), 00026 // which allocates a new FSA, 00027 // so we delete it now: 00028 delete fsa; 00029 break; 00030 } 00031 } 00032 } 00033 00034 // 00035 // Forwards events to any matching FSA's 00036 // 00037 void 00038 VIEWint::handle_event( 00039 CEvd &e 00040 ) 00041 { 00042 VIEW::push(_view); 00043 Event ev(_view, e); 00044 for (int i=0; i < _cur_states.num(); i++) { 00045 _cur_states[i]->handle_event(ev); 00046 } 00047 00048 while (!_events.empty()) { 00049 ev = Event(_view, _events.pop()); 00050 for (int t=0; t < _cur_states.num(); t++) { 00051 _cur_states[t]->handle_event(ev); 00052 } 00053 } 00054 VIEW::pop(); 00055 } 00056 00057 /* end of file fsa.C */