|
libFAUDES
Sections
Index
|
pex_altaccess.cppGo to the documentation of this file.00001 /** @file pex_altaccess.cpp Example plugin */ 00002 00003 #include "pex_altaccess.h" 00004 #include <stack> 00005 00006 namespace faudes { 00007 00008 00009 // we use the alternative accessibility algorithm from tutorial 6 00010 // for our example plugin. 00011 00012 void AlternativeAccessible(vGenerator& rGen) { 00013 // create a todo stack for state indices 00014 std::stack<Idx> todo; 00015 // create an empty StateSet for the set of accessible state 00016 StateSet accessible_states; 00017 // iterator for a StateSet 00018 StateSet::Iterator sit; 00019 // initialize the algorithm by pushing all initial states on the todo stack 00020 for (sit = rGen.InitStatesBegin(); sit != rGen.InitStatesEnd(); ++sit) { 00021 todo.push(*sit); 00022 } 00023 // process the todo stack until it's empty 00024 while (not todo.empty()) { 00025 // get and delete the next state index from the todo stack 00026 const Idx current = todo.top(); 00027 todo.pop(); 00028 // insert the current state in the set of accessible states 00029 accessible_states.Insert(current); 00030 // create transition iterator for the states of the current state 00031 TransSet::Iterator tit = rGen.TransRelBegin(current); 00032 TransSet::Iterator tit_end = rGen.TransRelEnd(current); 00033 // push successor states ton todo stack if not already discovered 00034 while (tit != tit_end) { 00035 if (not accessible_states.Exists(tit->X2)) { 00036 todo.push(tit->X2); 00037 } 00038 ++tit; 00039 } 00040 } 00041 // delete the states and transitions which are not accessible 00042 rGen.DelStates(rGen.States() - accessible_states); 00043 } 00044 00045 00046 } // namespace faudes |
libFAUDES 2.18b --- 2010-12-17 --- c++ source docu by doxygen 1.6.3