1_generator.cpp
Go to the documentation of this file.
1 /** @file 1_generator.cpp
2 
3 Tutorial, Generator methods.
4 
5 The Generator class implements the 5-tuple automaton G, consisting of
6 - Set of States Q,
7 - Alphabet Sigma,
8 - Transition Relation Delta,
9 - Set of Initial States Qo, and
10 - Set of Marked States Qm.
11 
12 This tutorial demonstrates how to insert/erase states, events and transitions.
13 It also demonstrates file IO.
14 
15 @ingroup Tutorials
16 
17 @include 1_generator.cpp
18 */
19 
20 
21 #include "libfaudes.h"
22 
23 // make faudes namespace available
24 using namespace faudes;
25 
26 
27 
28 /////////////////
29 // main program
30 /////////////////
31 
32 int main() {
33 
34  ////////////////////////////////////////////
35  // Constructors (part 1) and filling example
36  ////////////////////////////////////////////
37 
38  // at first we create an empty Generator object
39 
40  Generator g1;
41 
42  // do some random "user interaction" stuff with the Generator g1
43 
44  g1.InsState("s1");
45  g1.InsState("s2");
46  g1.InsState("s3");
47 
48  g1.InsEvent("a");
49  g1.InsEvent("b");
50 
51  g1.SetTransition("s1", "a", "s2");
52  g1.SetTransition("s2", "a", "s3");
53  g1.SetTransition("s3", "b", "s1");
54 
55  g1.SetInitState("s1");
56  g1.SetMarkedState("s2");
57  g1.SetMarkedState("s3");
58 
59  // inspect result on console
60 
61  std::cout << "################################\n";
62  std::cout << "# tutorial, handcraft generator \n";
63  g1.Write();
64  std::cout << "################################\n";
65 
66  // record test case
67  FAUDES_TEST_DUMP("g1", g1);
68 
69 
70 
71  ///////////////////////////////////////////////////
72  // Constructors (part 2) & Copying and versioning
73  ///////////////////////////////////////////////////
74 
75  // Create a 1:1 copy of the Generator with the copy constructor ...
76 
77  Generator g_copy(g1);
78 
79  // ... with assignment method, or assignement operator
80 
81  Generator g2;
82  g2.Assign(g1);
83  Generator g3=g2;
84 
85  // create a Generator copy with versioned events (for testing algorithms):
86  // versioning by an integer. E.g. for integer 3 events {"a", "b", "c"}
87  // become {"a_3", "b_3", "c_3"}.
88 
89  Generator version1;
90  g3.Version(3, version1);
91 
92  // versioning by a string. "a" -> "a_versionstring"
93 
94  Generator version2;
95  g3.Version("str", version2);
96 
97  // versioning by replacing a pattern "_str" -> "_machine_3"
98 
99  Generator version3;
100  version2.Version("_str", "_machine_3",version3);
101 
102  // editing by renaming an individual event
103 
104  version3.EventRename("a_machine_3","synch");
105 
106  // inspect result on console
107 
108  std::cout << "################################\n";
109  std::cout << "# tutorial, version of generator \n";
110  version3.Write();
111  std::cout << "################################\n";
112 
113  // record test case
114  FAUDES_TEST_DUMP("generator", version1);
115 
116 
117  ///////////////////////////////////////////////
118  // Methods for Input/Output
119  ///////////////////////////////////////////////
120 
121  // read a Generator from file
122 
123  g2.Read("data/simplemachine.gen");
124 
125  // create a Generator by reading a Generator file
126 
127  Generator g4("data/simplemachine.gen");
128 
129 
130  // write a Generator to file
131 
132  g4.Write("tmp_simplemachine.gen");
133 
134  // write a Generator to file with re-indexed states
135 
136  g4.ReindexOnWrite(true);
137  g4.Write("tmp_simplemachine_ridx.gen");
138 
139  // read back files (testing token io)
140  g4.Read("tmp_simplemachine.gen");
141  g4.Read("tmp_simplemachine_ridx.gen");
142 
143  // debug output of Generator to console
144 
145  std::cout << "################################\n";
146  std::cout << "# tutorial, debug dump \n";
147  g4.DWrite();
148  std::cout << "################################\n";
149 
150  // create dotfile for further processing by graphviz
151  // (map state indices to begin with 1)
152 
153  g4.DotWrite("tmp_simplemachine.dot");
154  g4.DDotWrite("tmp_simplemachine_debug.dot");
155 
156  // there also is a convenience method, that runs graphviz to
157  // generate graphical output; requires "dot" binary in $PATH
158  try {
159  g4.GraphWrite("tmp_simplemachinie.png");
160  } catch(faudes::Exception& exception) {
161  std::cout << "1_generator: cannot execute graphviz' dot. " << std::endl;
162  }
163 
164 
165  // create a debug string for an event with symbolic name + index
166 
167  std::string str_singleevent = g1.EStr(2);
168 
169  // create a debug string for a state with symbolic name + index.
170  // If there is no symblic name, a symbolic name of the index is constructed.
171 
172  std::string str_singlestate = g1.SStr(3);
173 
174  // build string of events in the Generator's alphabet
175 
176  std::string str_alph = g1.AlphabetToString();
177 
178  // build string of states in the Generator's set of states
179  std::string str_states = g1.StatesToString();
180 
181  // there also are TransRelToString(), InitStatesToString() and MarkedStatesToString()
182 
183 
184  //////////////////////////////////////
185  // Accessing the Generator's Members
186  //////////////////////////////////////
187 
188  // get the Generator's name
189 
190  std::string str_name = g1.Name();
191 
192  // set new name for Generator
193 
194  g1.Name("NewName");
195 
196 
197 
198  // the core members alphabet, stateset and transitionrelation may be retrieved
199  // as const references; ie. they can be inspected freely, but write access is
200  // exclusively via the provided Generator methods.
201 
202  // retrieve a const reference to and copy of the Generator's alphabet
203 
204  const EventSet& eset_ref_alph = g1.Alphabet();
205  EventSet eset_copy_alph = g1.Alphabet();
206 
207  // you cannot alter the alphabet of a generator via an alphabet method
208  // eset_ref_alph.Insert("new_event"); // compile time error!
209 
210  // however, the copy can be altered, but with no effect on the original generator
211 
212  eset_copy_alph.Insert("new_event");
213  if(g1.ExistsEvent("new_event")) std::cout << "### THIS CANNOT HAPPEN ###";
214 
215  // retrieve a const reference to and copy of the Generator's set of states "mStates"
216 
217  const StateSet& sset_ref_states = g1.States();
218  StateSet sset_copy_states = g1.States();
219 
220  // retrieve a const reference to and a copy of the Generator's transition relation "mTransRel"
221 
222  const TransSet& tset_ref_trel = g1.TransRel();
223  TransSet tset_copy_trel = g1.TransRel();
224 
225  // same with initial states and marked states
226 
227  const StateSet& sset_ref_istates = g1.InitStates();
228  StateSet sset_copy_istates = g1.InitStates();
229 
230  const StateSet& sset_ref_mstates = g1.MarkedStates();
231  StateSet sset_copy_mstates = g1.MarkedStates();
232 
233 
234 
235  //////////////////////////////////////////////////////////////////////////////
236  // Modifying the 5-tuple Generator (X, Sigma, Delta, X0 and Xm)
237  //////////////////////////////////////////////////////////////////////////////
238 
239  // insert an event by it's symbolic name in the alphabet
240  // (if the event is not known so far, a new index for the symbolic name is generated)
241  g1.InsEvent("newevent");
242 
243 
244  // insert an existing event into the Generator's alphabet (mAlphabet)
245  // (by "existing event" we refer to an event that has been previously inserted to some Generator)
246 
247  g1.InsEvent(1); // of course index 1 is already in the alphabet here...
248 
249  // insert a bunch of events (EventSet) and get the integer index if requested
250 
251  EventSet eset1;
252  eset1.Insert("newevent1");
253  Idx idx_tmp = eset1.Insert("newevent2");
254  g1.InsEvents(eset1);
255 
256  // delete an event from Generator ie delete from alphabet and transition relation
257 
258  g1.DelEvent("newevent1"); // by symbolic name
259  g1.DelEvent(idx_tmp); // by index
260 
261  // delete a bunch of events
262  // g1.DelEvents(eset1); // .. of course we have already deleted them before...
263 
264  // insert a new state. The state gets a integer index that is unique within
265  // the Generator
266 
267  idx_tmp = g1.InsState(); // anonymous state
268  idx_tmp = g1.InsState("newstate2"); // named state
269  idx_tmp = g1.InsState("77"); // named state
270 
271  // insert a new state as initial state
272 
273  idx_tmp = g1.InsInitState();
274  idx_tmp = g1.InsInitState("newinitstate");
275 
276  // ... same for marked states
277 
278  idx_tmp = g1.InsMarkedState();
279  idx_tmp = g1.InsMarkedState("newmarkedstate");
280 
281 
282  // delete single states from Generator ie stateset and transitionrelation
283 
284  g1.DelState(idx_tmp); // by index (relatively fast, for algorithms)
285  g1.DelState("newinitstate"); // by symbolic name, if name assigned
286 
287  // delete a bunch of states
288  // (this should be more efficient than deleting states individually)
289 
290  StateSet stateset1;
291  stateset1.Insert(1);
292  stateset1.Insert(2);
293  stateset1.Insert(3);
294  g1.DelStates(stateset1);
295 
296  // for further proceeding we insert some new states and events...
297 
298  Idx idx_s10 = g1.InsState("s10");
299  Idx idx_s11 = g1.InsState("s11");
300  Idx idx_s12 = g1.InsState("s12");
301  Idx idx_e10 = g1.InsEvent("e10");
302  Idx idx_e11 = g1.InsEvent("e11");
303 
304  // set a state that already exists in Generator as initial state
305 
306  g1.SetInitState(idx_s10);
307 
308  // set a state that already exists in Generator as marked state
309 
310  g1.SetMarkedState(idx_s11);
311 
312  // unset an existing state as initial state (does not remove from mStates)
313 
314  g1.ClrInitState(idx_s10);
315 
316  // unset an existing state as marked state (does not remove from stateset)
317 
318  g1.ClrMarkedState(idx_s10);
319 
320  // clear all initial states (does not remove from stateset)
321 
322  // g1.ClrInitStates(); // we do not really do it here, so it's commented
323 
324  // clear all marked states (mStates stays untouched)
325 
326  // g1.ClrMarkedStates(); // we do not really do it here, so it's commented
327 
328  // set a transition for existing states and events
329 
330  g1.SetTransition(idx_s10, idx_e10, idx_s11); // by indices
331  g1.SetTransition("s10", "e11", "s10"); // by symbolic names (slow)
332 
333 
334  // report back to console
335 
336  std::cout << "################################\n";
337  std::cout << "# tutorial, on the way ... \n";
338  g1.Write();
339  std::cout << "################################\n";
340 
341 
342  // clear a transition (does not touch mStates, mInitStates and mMarkedStates)
343 
344  g1.ClrTransition(idx_s10, idx_e10, idx_s11); // by index
345 
346  // transitions can also be cleared by names (slower) or by an assigned
347  // TransSet::Iterator (faster); use ClearTransRel() to remove all transitions
348 
349 
350  // clear the symbolic name for a state in the StateSymbolTable
351 
352  g1.ClrStateName(idx_s10);
353 
354  // exists event index/name in mAlphabet?
355 
356  bool bool_eventexists1 = g1.ExistsEvent("e11");
357  bool bool_eventexists2 = g1.ExistsEvent(2);
358 
359 
360  // exists state in mStates?
361 
362  bool bool_stateexists1 = g1.ExistsState(4);
363 
364 
365  // check if a state is an initial state
366 
367  bool bool_initstateexists = g1.ExistsInitState(4);
368 
369  // check if a state is a marked state
370 
371  bool bool_ismarkedstate = g1.ExistsMarkedState(4);
372 
373  // look up event name for index in the EventSymbolTable of the event domain
374 
375  std::string str_eventname1 = g1.EventName(1);
376 
377  // look up event index for name in the EventSymbolTable of the event domain
378 
379  Idx idx_eventindex = g1.EventIndex("e11");
380 
381  // get symbolic name assigned to state (returns "" if no name assigned).
382 
383  std::string str_tmp = g1.StateName(idx_s10);
384 
385  // get index for symbolic state name. only possible for state names of states in
386  // the Generator
387 
388  idx_tmp = g1.StateIndex("s12");
389 
390  // clear Generator (including alphabet)
391 
392  g4.Clear();
393 
394  // get the number of events in the Generator's alphabet
395 
396  Idx idx_eventnum = g1.AlphabetSize();
397 
398  // get the number of states
399 
400  Idx idx_statenum = g1.Size();
401 
402  // get the number of transitions
403 
404  Idx idx_transnum = g1.TransRelSize();
405 
406  // there also are InitStatesSize(), MarkedStatesSize()
407 
408  // is the alphabet of the Generator empty?
409 
410  bool bool_alphempty = g1.AlphabetEmpty();
411 
412  // is the Generator empty (number of states == 0) ?
413 
414  bool bool_isempty = g1.Empty();
415 
416  // see also TransRelEmpty, InitStatesEmpty, MarkedStatesEmpty
417 
418 
419  // insert a small loop
420 
421  Idx initstate = g1.InsInitState("in");
422  Idx markedstate = g1.InsMarkedState("out");
423  g1.SetTransition("in","a","out");
424  g1.SetTransition("out","a","in");
425 
426 
427  // show effect on console
428 
429  std::cout << "################################\n";
430  std::cout << "# tutorial, after ins and del \n";
431  g1.DWrite();
432  std::cout << "################################\n";
433 
434  // record test case
435  FAUDES_TEST_DUMP("g1, edited", g1);
436 
437  ///////////////////////
438  // Iterators
439  ///////////////////////
440 
441  // since the core members are all implemented as sets, iterators
442  // effectively are const_iterators, i.e. you cannot change the
443  // current value of an iterator. instead you may remove the value
444  // and insert the new value.
445 
446  // iteration over alphabet indices (member "mAlphabet")
447 
448  std::cout << "################################\n";
449  std::cout << "# tutorial, iterators 1 \n";
450  EventSet::Iterator eit;
451  for (eit = g1.AlphabetBegin(); eit != g1.AlphabetEnd(); ++eit) {
452  std::cout << "event \"" << g1.EventName(*eit) << "\" with index "<< *eit << std::endl;
453  }
454  std::cout << "################################\n";
455 
456  // iteration over state indices (member "mStates")
457 
458  std::cout << "################################\n";
459  std::cout << "# tutorial, iterators 2 \n";
460  StateSet::Iterator sit;
461  for (sit = g1.StatesBegin(); sit != g1.StatesEnd(); ++sit) {
462  std::cout << *sit << std::endl;
463  }
464  std::cout << "################################\n";
465 
466  // iteration over complete transition relation (member "mTransRel")
467 
468  std::cout << "################################\n";
469  std::cout << "# tutorial, iterators 3 \n";
470  TransSet::Iterator tit;
471  for (tit = g1.TransRelBegin(); tit != g1.TransRelEnd(); ++tit) {
472  std::cout << g1.TStr(*tit) << std::endl;
473  }
474  std::cout << "################################\n";
475 
476  // iteration over transitions from a given state; note that we avoid
477  // computation of the end of the iteration in every step
478 
479  std::cout << "################################\n";
480  std::cout << "# tutorial, iterators 4 \n";
481  idx_tmp = g1.StateIndex("s1");
482  TransSet::Iterator tit_end;
483  tit = g1.TransRelBegin(idx_tmp);
484  tit_end = g1.TransRelEnd(idx_tmp);
485  for (; tit != tit_end; ++tit) {
486  std::cout << g1.TStr(*tit) << std::endl;
487  }
488  std::cout << "################################\n";
489 
490  // variations: transitions of given state index + given event index:
491  // TransRelBegin(x1, ev) - TransRelEnd(x1, ev)
492 
493  // iteration over initial and marked states:
494  // InitStatesBegin() - InitStatesEnd() (member "mInitStates")
495  // MarkedStatesBegin() - MarkedStatesEnd() (member "mMarkedStates")
496 
497 
498  ////////////////////////////////////////////////////////////
499  // retrieve copies of the Generator's transition releation
500  // in different sorting orders than X1 -> Ev -> X2
501  ////////////////////////////////////////////////////////////
502 
503  // note: the availabity of iterator ranges depends on the sorting order;
504  // eg iteration with specified x2 requires X2->Ev->X1 or X2->X1->Ev sorting.
505 
506  // retrieve a copy that is sorted by X2 -> Ev -> X1 by the binary
507  // predicate TransSort::X2EvX1.
508 
509  TransSetX2EvX1 tset_x2evx1;
510  g1.TransRel(tset_x2evx1);
511 
512  // report to console
513 
514  std::cout << "################################\n";
515  std::cout << "# tutorial, x2-ev-x1 sorting\n";
517  for (tit2 = tset_x2evx1.Begin(); tit2 != tset_x2evx1.End(); ++tit2) {
518  std::cout << g1.TStr(*tit2) << std::endl;
519  }
520  std::cout << "################################\n";
521 
522 
523 
524  ////////////////////////
525  // Convenience Methods
526  ////////////////////////
527 
528  // remove all events from mAlphabet, that do not have a transition in
529  // mTransRel: g1.MinimizeAlphabet()
530 
531  // get an EventSet containing all the events that drive some transition
532 
533  EventSet eset_usedevents = g1.UsedEvents();
534 
535  // get an EventSet containing all the events that do not drive any transition
536 
537  EventSet eset_unusedevents = g1.UnusedEvents();
538 
539  // return the active event set at a given state
540 
541  EventSet eset_activeeventset = g1.ActiveEventSet(idx_s12);
542 
543  // return a StateSet containing all the states that are connected by
544  // some transition
545 
546  StateSet sset_trel_sspace = g1.TransRelStates();
547 
548  // return a StateSet containing all the successor states of a given predecessor
549  // state.
550 
551  StateSet sset_successors = g1.SuccessorStates(idx_s12);
552 
553  // note: if you need predecessor states, use a resorted transition relation
554 
555  /////////////////////////////////
556  // Symbolic state name handling
557  /////////////////////////////////
558 
559  // are symbolic state names enabled? depending on this boolean value
560  // library functions like Determine or StateMin may create symbolic
561  // state names automatically
562 
563  bool bool_statenamesenabled = g1.StateNamesEnabled();
564 
565  // disable state name creation in resulting generators for functions in
566  // the faudes library, that support this feature (nearly all) with
567  // "false"; enable state name creation with "true".
568 
569  g1.StateNamesEnabled(true); // anyway .. true is the default value
570 
571  // clear existing symbolic statenames for states in the Generator
572 
573  // g1.ClearStateNames();
574 
575  // set symbolic names for all states in the generator. the symbolic name becomes
576  // the equivalent string representation of the state's integer index. This is
577  // only usefull for debugging purposes.
578 
580 
581 
582  // show effect on console
583 
584  std::cout << "################################\n";
585  std::cout << "# tutorial, default names \n";
586  g1.Write();
587  std::cout << "################################\n";
588 
589 
590  ///////////////////////////////////
591  // Accessible, Coaccessible, Complete, Trim
592  ///////////////////////////////////
593 
594  // read example generator for reachability analysis
595  Generator greach("data/trimness_nottrim.gen");
596 
597  std::cout << "################################\n";
598  std::cout << "# tutorial, reachability test case \n";
599  greach.Write();
600  std::cout << "# tutorial, reachability relevant sets \n";
601  StateSet astates = greach.AccessibleSet();
602  StateSet cstates = greach.CoaccessibleSet();
603  StateSet tstates = greach.TerminalStates();
604  astates.Write();
605  cstates.Write();
606  tstates.Write();
607  std::cout << "# tutorial, reachability analysis \n";
608  bool isacc = greach.IsAccessible();
609  if(isacc)
610  std::cout << "accesibility: ok [error]\n";
611  else
612  std::cout << "accesibility: failed [expected]\n";
613  bool iscoacc = greach.IsCoaccessible();
614  if(iscoacc)
615  std::cout << "coaccesibility: ok [error]\n";
616  else
617  std::cout << "coaccesibility: failed [expected]\n";
618  bool iscompl = greach.IsComplete();
619  if(iscompl)
620  std::cout << "completeness: ok [error]\n";
621  else
622  std::cout << "completeness: failed [expected]\n";
623  bool istrim = greach.IsTrim();
624  if(istrim)
625  std::cout << "trimness: ok [error]\n";
626  else
627  std::cout << "trimness: failed [expected]\n";
628  bool isotrim = greach.IsOmegaTrim();
629  if(isotrim)
630  std::cout << "w-trimness: ok [error]\n";
631  else
632  std::cout << "w-trimness: failed [expected]\n";
633  std::cout << "################################\n";
634 
635  // record test case
636  FAUDES_TEST_DUMP("acc",astates);
637  FAUDES_TEST_DUMP("coacc",cstates);
638  FAUDES_TEST_DUMP("term",tstates);
639 
640  // Make the Generator accessible by removing transitions and states.
641  // The routine returns true if the generator has an initial state.
642  Generator gaccess(greach);
643  gaccess.Name("GAccessible");
644  bool bool_hasinit = gaccess.Accessible();
645 
646  // Make the Generator coaccessible by removing transitions and states.
647  // The routine returns true if the generator has a marked state.
648  Generator gcoaccess(greach);
649  gcoaccess.Name("GCoccessible");
650  bool bool_hasmarked = gcoaccess.Coaccessible();
651 
652  // Make the Generator complete by removing transitions and states.
653  // The routine returns true if the generator has an initial state.
654  Generator gcompl(greach);
655  gcompl.Name("GComplete");
656  gcompl.Complete();
657 
658  // Make the Generator trim by removing transitions and states.
659  // The routine returns true if the generator has an initial state
660  // and a marked state.
661  Generator gtrim(greach);
662  gtrim.Name("GTrim");
663  bool bool_isnontrivial = gtrim.Trim();
664 
665  // Make the Generator omega-trim by removing transitions and states.
666  // The routine returns true if the generator has an initial state
667  // and a marked state.
668  Generator gotrim(greach);
669  gotrim.Name("GOmegaTrim");
670  gotrim.OmegaTrim();
671 
672  // show effect on console
673  std::cout << "################################\n";
674  std::cout << "# tutorial, reachability results \n";
675  gaccess.Write();
676  gcoaccess.Write();
677  gcompl.Write();
678  gtrim.Write();
679  gotrim.Write();
680  std::cout << "################################\n";
681 
682  // contribute to html docu
683  greach.Write("tmp_greach.gen");
684  gaccess.Write("tmp_gaccess.gen");
685  gcoaccess.Write("tmp_gcoaccess.gen");
686  gcompl.Write("tmp_gcompl.gen");
687  gtrim.Write("tmp_gtrim.gen");
688  gotrim.Write("tmp_gotrim.gen");
689 
690  // Test protocol
691  FAUDES_TEST_DUMP("accessible",gaccess);
692  FAUDES_TEST_DUMP("coaccessible",gcoaccess);
693  FAUDES_TEST_DUMP("complete",gcompl);
694  FAUDES_TEST_DUMP("trim",gtrim);
695  FAUDES_TEST_DUMP("omega trim",gotrim);
696 
697 
698  ///////////////////////////////////
699  // Generalized Completeness
700  ///////////////////////////////////
701 
702  // read example generator for generalized completeness
703  Generator gsigcomplB("data/trimness_nottrim.gen");
704  Generator gsigcomplC("data/trimness_nottrim.gen");
705  EventSet sigoB;
706  sigoB.FromString("<A> b </A>");
707  EventSet sigoC;
708  sigoC.FromString("<A> c </A>");
709 
710  std::cout << "################################\n";
711  std::cout << "# tutorial, sigma_o-completeness test case \n";
712  greach.Write();
713  bool issigcompl = gsigcomplB.IsComplete(sigoB);
714  if(iscompl)
715  std::cout << "completeness: ok [error]\n";
716  else
717  std::cout << "completeness: failed [expected]\n";
718 
719 
720  // Make the Generator complete by removing transitions and states.
721  // The routine returns true if the generator has an initial state.
722  gsigcomplB.Name("GSigoCompleteB");
723  gsigcomplB.Complete(sigoB);
724  gsigcomplC.Name("GSigoCompleteC");
725  gsigcomplC.Complete(sigoC);
726 
727  // record test case
728  FAUDES_TEST_DUMP("iscmpl",issigcompl);
729  FAUDES_TEST_DUMP("gsigcomplB",gsigcomplB);
730  FAUDES_TEST_DUMP("gsigcomplC",gsigcomplC);
731 
732  // contribute to html docu
733  gsigcomplB.Write("tmp_gsigcomplb.gen");
734  gsigcomplC.Write("tmp_gsigcomplc.gen");
735 
736 
737  ///////////////////////////////////
738  // Test case evaluation
739  ///////////////////////////////////
741 
742  return 0;
743 }
744 
745 
746 
int main()
Definition: 1_generator.cpp:32
#define FAUDES_TEST_DIFF()
Test protocol diff macro.
Definition: cfl_helper.h:493
#define FAUDES_TEST_DUMP(mes, dat)
Test protocol record macro ("mangle" filename for platform independance)
Definition: cfl_helper.h:483
Faudes exception class.
Set of indices.
Definition: cfl_indexset.h:78
Idx Insert(void)
Insert new index to set.
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
bool Insert(const Idx &rIndex)
Add an element by index.
Iterator class for high-level api to TBaseSet.
Definition: cfl_baseset.h:387
Iterator Begin(void) const
Iterator to begin of set.
Iterator End(void) const
Iterator to end of set.
TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator
Iterator on transition.
Definition: cfl_transset.h:269
void DWrite(const Type *pContext=0) const
Write configuration data to console, debugging format.
Definition: cfl_types.cpp:225
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from file with label specified.
Definition: cfl_types.cpp:261
void FromString(const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from a string.
Definition: cfl_types.cpp:275
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
Base class of all FAUDES generators.
StateSet::Iterator StatesBegin(void) const
Iterator to Begin() of state set.
const TransSet & TransRel(void) const
Return reference to transition relation.
bool SetTransition(Idx x1, Idx ev, Idx x2)
Add a transition to generator by indices.
const StateSet & MarkedStates(void) const
Return const ref of marked states.
const EventSet & Alphabet(void) const
Return const reference to alphabet.
Idx InsMarkedState(void)
Create new anonymous state and set as marked state.
virtual void DDotWrite(const std::string &rFileName) const
Writes generator to dot input format (no re-indexing).
virtual vGenerator & Assign(const Type &rSrc)
Copy from other faudes type.
std::string StatesToString(void) const
Write stateset of this generator to a string (no re-indexing)
EventSet ActiveEventSet(Idx x1) const
Return active event set at state x1.
const StateSet & InitStates(void) const
Const ref to initial states.
TransSet::Iterator TransRelBegin(void) const
Iterator to Begin() of transition relation.
void ClrTransition(Idx x1, Idx ev, Idx x2)
Remove a transition by indices.
bool Accessible(void)
Make generator accessible.
Idx StateIndex(const std::string &rName) const
State index lookup.
bool DelEvent(Idx index)
Delete event from generator by index.
bool Trim(void)
Make generator trim.
bool IsAccessible(void) const
Check if generator is accessible.
void InsEvents(const EventSet &events)
Add new named events to generator.
void ClrMarkedState(Idx index)
Unset an existing state as marked state by index.
bool EventRename(Idx event, const std::string &rNewName)
Rename event in this generator.
EventSet::Iterator AlphabetBegin(void) const
Iterator to Begin() of alphabet.
StateSet TransRelStates(void) const
Return the states covered by transitions.
bool IsComplete(void) const
Check if generator is complete.
void ClrStateName(Idx index)
Clear name for individual state.
bool IsOmegaTrim(void) const
Check if generator is omega-trim.
void SetInitState(Idx index)
Set an existing state as initial state by index.
StateSet AccessibleSet(void) const
Compute set of accessible states.
Idx EventIndex(const std::string &rName) const
Event index lookup.
bool ExistsState(Idx index) const
Test existence of state in state set.
bool IsCoaccessible(void) const
Check if generator is Coaccessible.
bool Coaccessible(void)
Make generator Coaccessible.
std::string TStr(const Transition &rTrans) const
Return pretty printable transition (eg for debugging)
std::string StateName(Idx index) const
State name lookup.
virtual void DotWrite(const std::string &rFileName) const
Writes generator to dot input format.
void Name(const std::string &rName)
Set the generator's name.
bool DelState(Idx index)
Delete a state from generator by index.
StateSet::Iterator StatesEnd(void) const
Iterator to End() of state set.
void ClrInitState(Idx index)
Unset an existing state as initial state by index.
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.
bool ExistsEvent(Idx index) const
Test existence of event in alphabet.
std::string EStr(Idx index) const
Pretty printable event name for index (eg for debugging).
StateSet TerminalStates(void) const
Compute set of terminal states.
Idx InsState(void)
Add new anonymous state to generator.
void SetMarkedState(Idx index)
Set an existing state as marked state by index.
bool Empty(void) const
Check if generator is empty (no states)
Idx InsInitState(void)
Create new anonymous state and set as initial state.
bool ReindexOnWrite(void) const
Test whether file-i/o uses minimal state indicees.
bool StateNamesEnabled(void) const
Whether libFAUEDS functions are requested to generate state names.
bool InsEvent(Idx index)
Add an existing event to alphabet by index.
void SetDefaultStateNames(void)
Assign each state a default name based on its index.
void GraphWrite(const std::string &rFileName, const std::string &rOutFormat="", const std::string &rDotExec="dot") const
Produce graphical representation of this generator.
Idx TransRelSize(void) const
Get number of transitions.
virtual void Version(const std::string &rVersion, vGenerator &rResGen) const
Create another version of this generator.
EventSet UsedEvents(void) const
Return used events (executed in transitions)
EventSet UnusedEvents(void) const
Return unused events.
std::string EventName(Idx index) const
Event name lookup.
EventSet::Iterator AlphabetEnd(void) const
Iterator to End() of alphabet.
bool IsTrim(void) const
Check if generator is trim.
StateSet CoaccessibleSet(void) const
Compute set of Coaccessible states.
Idx Size(void) const
Get generator size (number of states)
Idx AlphabetSize(void) const
Get number of events in alphabet.
bool OmegaTrim(void)
Make generator omega-trim.
bool ExistsInitState(Idx index) const
Test existence of state in mInitStates.
std::string SStr(Idx index) const
Return pretty printable state name for index (eg for debugging)
virtual void Clear(void)
Clear generator data.
bool ExistsMarkedState(Idx index) const
Test existence of state in mMarkedStates.
std::string AlphabetToString(void) const
Write generators alphabet to string.
bool Complete(void)
Make generator Complete.
const StateSet & States(void) const
Return reference to state set.
StateSet SuccessorStates(Idx x1) const
Return the successor states of state x1.
bool AlphabetEmpty(void) const
Check if alphabet is Empty.
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)

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