pex_altaccess.cpp
Go to the documentation of this file.
1 /** @file pex_altaccess.cpp Example plugin */
2 
3 #include "pex_altaccess.h"
4 #include <stack>
5 
6 namespace faudes {
7 
8 
9 // we use the alternative accessibility algorithm from tutorial 6
10 // for our example plugin.
11 
13  // create a todo stack for state indices
14  std::stack<Idx> todo;
15  // create an empty StateSet for the set of accessible state
16  StateSet accessible_states;
17  // iterator for a StateSet
18  StateSet::Iterator sit;
19  // initialize the algorithm by pushing all initial states on the todo stack
20  for (sit = rGen.InitStatesBegin(); sit != rGen.InitStatesEnd(); ++sit) {
21  todo.push(*sit);
22  }
23  // process the todo stack until it's empty
24  while (not todo.empty()) {
25  // get and delete the next state index from the todo stack
26  const Idx current = todo.top();
27  todo.pop();
28  // insert the current state in the set of accessible states
29  accessible_states.Insert(current);
30  // create transition iterator for the states of the current state
31  TransSet::Iterator tit = rGen.TransRelBegin(current);
32  TransSet::Iterator tit_end = rGen.TransRelEnd(current);
33  // push successor states ton todo stack if not already discovered
34  while (tit != tit_end) {
35  if (not accessible_states.Exists(tit->X2)) {
36  todo.push(tit->X2);
37  }
38  ++tit;
39  }
40  }
41  // delete the states and transitions which are not accessible
42  rGen.DelStates(rGen.States() - accessible_states);
43 }
44 
45 
46 } // namespace faudes
Set of indices.
Definition: cfl_indexset.h:78
Idx Insert(void)
Insert new index to set.
TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator
Iterator on transition.
Definition: cfl_transset.h:269
Base class of all FAUDES generators.
StateSet::Iterator InitStatesBegin(void) const
Iterator to Begin() of mInitStates.
TransSet::Iterator TransRelBegin(void) const
Iterator to Begin() of transition relation.
void DelStates(const StateSet &rDelStates)
Delete a set of states Cleans mpStates, mInitStates, mMarkedStates, mpTransrel, and mpStateSymboltabl...
TransSet::Iterator TransRelEnd(void) const
Iterator to End() of transition relation.
StateSet::Iterator InitStatesEnd(void) const
Iterator to End() of mInitStates.
const StateSet & States(void) const
Return reference to state set.
bool Exists(const T &rElem) const
Test existence of element.
Definition: cfl_baseset.h:2115
void AlternativeAccessible(Generator &rGen)
Alternative accessibility algorithm.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
Example plugin.

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen