cfl_generator.cpp
Go to the documentation of this file.
1 /** @file cfl_generator.cpp Class vGenerator */
2 
3 /* FAU Discrete Event Systems Library (libfaudes)
4 
5  Copyright (C) 2006 Bernd Opitz
6  Copyright (C) 2007 Thomas Moor
7  Exclusive copyright is granted to Klaus Schmidt
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 
24 #include "cfl_generator.h"
25 #include <stack>
26 
27 
28 namespace faudes {
29 
30 // msObjectCount (static)
32 
33 // State names default (static)
35 
36 // Reindex default (static)
38 
39 
40 // static default prototypes (construct on first use design pattern)
42  static EventSet fls;
43  return fls;
44 }
46  static StateSet fls;
47  return fls;
48 }
50  static TransSet fls;
51  return fls;
52 }
54  static AttributeVoid fls;
55  return fls;
56 }
57 
58 
59 
60 
61 // constructor
63  // base
64  Type(),
65  // my name
66  mMyName("Generator"),
67  // have std symboltables
68  mpStateSymbolTable(&mStateSymbolTable),
69  mpEventSymbolTable(GlobalEventSymbolTablep()),
70  // other members
71  mStateNamesEnabled(msStateNamesEnabledDefault),
72  mReindexOnWrite(msReindexOnWriteDefault),
73  // initialise heap members
74  mpAlphabet(0),
75  mpStates(0),
76  mpTransRel(0),
77  mpGlobalAttribute(0),
78  // initialise prototypes
79  pAlphabetPrototype(&AlphabetVoid()),
80  pStatesPrototype(&StatesVoid()),
81  pTransRelPrototype(&TransRelVoid()),
82  pGlobalPrototype(&GlobalVoid())
83 {
84  FAUDES_OBJCOUNT_INC("Generator");
85  FD_DG("vGenerator(" << this << ")::vGenerator()");
86  // track generator objects
87  msObjectCount++;
89  // allocate core members
90  NewCore();
91  // fix std names
92  mInitStates.Name("InitStates");
93  mMarkedStates.Name("MarkedStates");
94 }
95 
96 // copy constructor
98  // my name
99  mMyName("Generator"),
100  // have std symboltables
101  mpStateSymbolTable(&mStateSymbolTable),
102  mpEventSymbolTable(GlobalEventSymbolTablep()),
103  // other members
104  mStateNamesEnabled(msStateNamesEnabledDefault),
105  mReindexOnWrite(msReindexOnWriteDefault),
106  // initialise heap members
107  mpAlphabet(0),
108  mpStates(0),
109  mpTransRel(0),
110  mpGlobalAttribute(0),
111  // initialise prototypes
112  pAlphabetPrototype(&AlphabetVoid()),
113  pStatesPrototype(&StatesVoid()),
114  pTransRelPrototype(&TransRelVoid()),
115  pGlobalPrototype(&GlobalVoid())
116 {
117  FAUDES_OBJCOUNT_INC("Generator");
118  FD_DG("vGenerator(" << this << ")::vGenerator(" << &rOtherGen << ")");
119  // track generator objects
120  msObjectCount++;
121  mId = msObjectCount;
122  // allocate core members
123  NewCore();
124  // perform copy
125  DoAssign(rOtherGen);
126 }
127 
128 // construct from file
129 vGenerator::vGenerator(const std::string& rFileName) :
130  // my name
131  mMyName("Generator"),
132  // have std symboltables
133  mpStateSymbolTable(&mStateSymbolTable),
134  mpEventSymbolTable(GlobalEventSymbolTablep()),
135  // other members
136  mStateNamesEnabled(msStateNamesEnabledDefault),
137  mReindexOnWrite(msReindexOnWriteDefault),
138  // initialise heap members
139  mpAlphabet(0),
140  mpStates(0),
141  mpTransRel(0),
142  mpGlobalAttribute(0),
143  // initialise prototypes
144  pAlphabetPrototype(&AlphabetVoid()),
145  pStatesPrototype(&StatesVoid()),
146  pTransRelPrototype(&TransRelVoid()),
147  pGlobalPrototype(&GlobalVoid())
148 {
149  FAUDES_OBJCOUNT_INC("Generator");
150  FD_DG("vGenerator(" << this << ")::vGenerator(" << rFileName << ")");
151  // track generator objects
152  msObjectCount++;
153  mId = msObjectCount;
154  // allocate core members
155  NewCore();
156  // fix std names
157  mInitStates.Name("InitStates");
158  mMarkedStates.Name("MarkedStates");
159  // set defaults for file io
160  mStateNamesEnabled=true;
161  // do read
162  Read(rFileName,"Generator");
163  // restore defaults
165 }
166 
167 // construct on heap
169  FD_DG("vGenerator(" << this << ")::New()");
170  // allocate
171  vGenerator* res = new vGenerator();
172  // fix configuration
176  return res;
177 }
178 
179 // construct on heap
181  FD_DG("vGenerator(" << this << ")::Copy()");
182  // copy construct
183  vGenerator* res = new vGenerator(*this);
184  return res;
185 }
186 
187 // cast
188 const Type* vGenerator::Cast(const Type* pOther) const {
189  return dynamic_cast< const vGenerator* > (pOther);
190 }
191 
192 
193 // destruct
195  FAUDES_OBJCOUNT_DEC("Generator");
196  // free my members
197  DeleteCore();
198 }
199 
200 // configure attribute types
201 void vGenerator::ConfigureAttributeTypes(const AttributeVoid* pNewGlobalPrototype,
202  const StateSet* pNewStatesPrototype, const EventSet* pNewAlphabetPrototype,
203  const TransSet* pNewTransRelPrototype) {
204  FD_DG("vGenerator(" << this << ")::ConfigureAtributes(..)");
205  pGlobalPrototype= pNewGlobalPrototype;
206  pStatesPrototype= pNewStatesPrototype;
207  pAlphabetPrototype= pNewAlphabetPrototype;
208  pTransRelPrototype= pNewTransRelPrototype;
209  FD_DG("vGenerator(" << this << ")::ConfigureAtributes(): done");
210 }
211 
212 // indicate new core
214  // fix std names
215  if(mpAlphabet) mpAlphabet->Name("Alphabet");
216  if(mpStates) mpStates->Name("States");
217  if(mpTransRel) mpTransRel->Name("TransRel");
218  // fix symbol table
220 }
221 
222 // protected helper: allocate core on heap
224  DeleteCore();
225  // allocate (use prototypes, fallback to void attributes)
227  else mpAlphabet = new EventSet();
229  else mpStates = new StateSet();
231  else mpTransRel = new TransSet();
233  else mpGlobalAttribute = new AttributeVoid();
234  // update callback
235  UpdateCore();
236 }
237 
238 // protected helper: free core from heap
240  if(mpAlphabet) delete mpAlphabet;
241  if(mpStates) delete mpStates;
242  if(mpTransRel) delete mpTransRel;
244  mpAlphabet=0;
245  mpStates=0;
246  mpTransRel=0;
248  // update callback
249  UpdateCore();
250 }
251 
252 
253 
254 // copy from other vGenerator (try to convert attributes)
255 void vGenerator::DoAssign(const vGenerator& rGen) {
256  FD_DG("vGenerator(" << this << ")::DoAssign(" << &rGen << ")");
257  // bail out on match
258  if(&rGen==this) return;
259  // prepare result (call clear for virtual stuff)
260  Clear();
261  // have same event symboltable
263  // copy state symboltable
265  // set other members
266  Name(rGen.Name());
271  // core members, try attributes
272  InjectStates(*rGen.mpStates);
273  InjectAlphabet(*rGen.mpAlphabet);
274  InjectTransRel(*rGen.mpTransRel);
276 #ifdef FAUDES_DEBUG_CODE
277  if(!Valid()) {
278  FD_DG("vGenerator()::Copy(): invalid generator");
279  DWrite();
280  abort();
281  }
282 #endif
283  FD_DG("vGenerator(" << this << ")::DoAssign(" << &rGen << "): done");
284 }
285 
286 // copy from other vGenerator (try to convert attributes)
288  FD_DG("vGenerator(" << this << ")::Assign([type] " << &rSrc << ")");
289  // bail out on match
290  if(&rSrc==this) return *this;
291  // run DoAssign if object casts to a generator
292  const vGenerator* vgen=dynamic_cast<const vGenerator*>(&rSrc);
293  if(vgen) {
294  DoAssign(*vgen);
295  return *this;
296  }
297  // clear to default
298  Clear();
299  return *this;
300 }
301 
302 // copy from other vGenerator (clear attributes)
304  FD_DG("vGenerator(" << this << ")::Assign(" << &rGen << ")");
305  // prepare result (call clear for virtual stuff)
306  Clear();
307  // have same event symboltable
309  // copy state symboltable
311  // set other members
312  Name(rGen.Name());
317  // core members, ignore attributes
321 #ifdef FAUDES_DEBUG_CODE
322  if(!Valid()) {
323  FD_DG("vGenerator()::Copy(): invalid generator");
324  DWrite();
325  abort();
326  }
327 #endif
328  return *this;
329 }
330 
331 
332 // Move(gen) destructive copy
334  FD_DG("vGenerator(" << this << ")::Move(" << &rGen << ")");
335  // test types
336  bool tmm=false;
337  const Type* pt;
338  const Type* opt;
339  pt=&Alphabet();
340  opt=&rGen.Alphabet();
341  if(typeid(*pt)!=typeid(*opt)) tmm=true;
342  pt=&States();
343  opt=&rGen.States();
344  if(typeid(*pt)!=typeid(*opt)) tmm=true;
345  pt=&TransRel();
346  opt=&rGen.TransRel();
347  if(typeid(*pt)!=typeid(*opt)) tmm=true;
348  pt=&GlobalAttribute();
349  opt=&rGen.GlobalAttribute();
350  if(typeid(*pt)!=typeid(*opt)) tmm=true;
351  // use copy on mismatch to convert
352  if(tmm) {
353  FD_DG("vGenerator(" << this << ")::Move(" << &rGen << "): using std copy");
354  rGen.DoAssign(*this);
355  Clear();
356  return;
357  }
358  // prepare result (call clear for virtual stuff)
359  rGen.Clear();
360  // have same event symboltable
362  // copy state symboltable (todo: make this pointer based?)
364  // copy members
365  rGen.Name(Name());
370  // delete destination core
371  if(rGen.mpStates) delete rGen.mpStates;
372  if(rGen.mpAlphabet) delete rGen.mpAlphabet;
373  if(rGen.mpTransRel) delete rGen.mpTransRel;
374  if(rGen.mpGlobalAttribute) delete rGen.mpGlobalAttribute;
375  // move and invalidate core members
376  rGen.mpStates=mpStates;
377  rGen.mpAlphabet=mpAlphabet;
378  rGen.mpTransRel=mpTransRel;
380  mpStates=0;
381  mpAlphabet=0;
382  mpTransRel=0;
384  // register core update
385  rGen.UpdateCore();
386  // install new empty core members
387  NewCore();
388  // clear myself (incl derived classes members)
389  Clear();
390 }
391 
392 // operator =
394  FD_DG("vGenerator(" << this << ")::operator = " << &rOtherGen);
395  FD_DG("vGenerator(" << this << ")::operator = types " << typeid(*this).name() << " <= " << typeid(rOtherGen).name());
396  return Assign(rOtherGen);
397 }
398 
399 // Version(idx)
400 void vGenerator::Version(Idx version, vGenerator& rResGen) const {
401  FD_DG("vGenerator(" << this << ")::Version(" << version << ")");
402  std::ostringstream o;
403  o << version;
404  Version(o.str(),rResGen);
405 }
406 
407 // Version(string)
408 void vGenerator::Version(const std::string& rVersion, vGenerator& rResGen) const {
409  FD_DG("vGenerator(" << this << ")::Version(" << rVersion << ")");
410  // second arg must not be us
411  if(this==&rResGen) {
412  std::stringstream errstr;
413  errstr << "Destination must not match source.";
414  throw Exception("vGenerator::Version(string)", errstr.str(), 96);
415  }
416  // prepare Empty generator
417  rResGen.Clear();
418  rResGen.GlobalAttribute(GlobalAttribute());
419  EventSet::Iterator eit;
420  StateSet::Iterator lit;
421  TransSet::Iterator tit;
422  std::map<Idx,Idx> eventoldnewmap;
423  rResGen.Name(Name()+"_"+rVersion);
424  // create versioned mAlphabet
425  for (eit = AlphabetBegin(); eit != AlphabetEnd(); ++eit) {
426  Idx newevent= rResGen.InsEvent(EventName(*eit)+"_"+rVersion);
427  eventoldnewmap[*eit] = newevent;
428  rResGen.EventAttribute(newevent,EventAttribute(*eit));
429  }
430  // create new stateset
431  for (lit = StatesBegin(); lit != StatesEnd(); ++lit) {
432  rResGen.InsState(*lit);
433  rResGen.StateAttribute(*lit,StateAttribute(*lit)); //would be faster if directly copied ?
434  if (StateName(*lit) != "") rResGen.StateName(*lit,StateName(*lit));
435  }
436  // created versioned transrel
437  for (tit = TransRelBegin(); tit != TransRelEnd(); ++tit) {
438  Transition trans=Transition(tit->X1, eventoldnewmap[tit->Ev], tit->X2);
439  rResGen.SetTransition(trans);
440  rResGen.TransAttribute(trans, TransAttribute(*tit));
441  }
442  // set i/m states
443  rResGen.mInitStates=mInitStates;
445  // behavioural flags
448 }
449 
450 
451 // Version(string,string)
452 void vGenerator::Version(const std::string& rPattern, const std::string& rReplacement, vGenerator& rResGen) const {
453  FD_DG("vGenerator(" << this << ")::Version(" << rPattern << ", " << rReplacement << ", ...)");
454  // second arg must not be us
455  if(this==&rResGen) {
456  std::stringstream errstr;
457  errstr << "Destination must not match source.";
458  throw Exception("vGenerator::Version(string,string)", errstr.str(), 96);
459  }
460  // ignore invalid pattern
461  if(rPattern.empty()) {
462  rResGen.Assign(*this);
463  return;
464  }
465  // trivial case
466  if(rPattern==rReplacement) {
467  rResGen.Assign(*this);
468  return;
469  }
470  // prepare Empty generator
471  rResGen.Clear();
472  rResGen.GlobalAttribute(GlobalAttribute());
473  rResGen.Name(Name()+"_v");
474  EventSet::Iterator eit;
475  StateSet::Iterator lit;
476  TransSet::Iterator tit;
477  std::map<Idx,Idx> eventoldnewmap;
478  // create versioned mAlphabet
479  std::string newstring;
480  std::string::size_type pos = 0;
481  int patternlength=rPattern.size();
482  int replacementlength=rReplacement.size();
483  for (eit = AlphabetBegin(); eit != AlphabetEnd(); ++eit) {
484  // search for all pattern occurences in event name and replace
485  newstring=EventName(*eit);
486  pos=0;
487  while( (pos = newstring.find(rPattern, pos)) != std::string::npos ) {
488  newstring.replace(pos, patternlength, rReplacement);
489  //pos++;
490  pos=pos+replacementlength;
491  }
492  Idx newevent= rResGen.InsEvent(newstring);
493  eventoldnewmap[*eit] = newevent;
494  rResGen.EventAttribute(newevent,EventAttribute(*eit));
495  }
496  // have a nice neme too
497  newstring=Name();
498  pos=0;
499  while( (pos = newstring.find(rPattern, pos)) != std::string::npos ) {
500  newstring.replace(pos, patternlength, rReplacement);
501  pos=pos+replacementlength;
502  }
503  rResGen.Name(newstring);
504  // create new stateset
505  for(lit = StatesBegin(); lit != StatesEnd(); ++lit) {
506  rResGen.InsState(*lit);
507  rResGen.StateAttribute(*lit,StateAttribute(*lit)); //would be faster if directly copied ?
508  if(StateName(*lit) != "") rResGen.StateName(*lit,StateName(*lit));
509  }
510  // created versioned transrel
511  for(tit = TransRelBegin(); tit != TransRelEnd(); ++tit) {
512  Transition trans=Transition(tit->X1, eventoldnewmap[tit->Ev], tit->X2);
513  rResGen.SetTransition(trans);
514  rResGen.TransAttribute(trans, TransAttribute(*tit));
515  }
516  // set i/m states
517  rResGen.mInitStates=mInitStates;
519  // behavioural flags
522 }
523 
524 
525 // Name(rName)
526 void vGenerator::Name(const std::string& rName) {
527  FD_DV("vGenerator(" << this << ")::Name(\"" << rName << "\")");
528  mMyName = rName;
529 }
530 
531 // Name()
532 const std::string& vGenerator::Name(void) const {
533  return mMyName;
534 }
535 
536 // Valid()
537 bool vGenerator::Valid(void) const {
538  FD_DG("vGenerator(" << this << ")::Valid()");
539  // core members on heap
540  if(mpAlphabet==0) return false;
541  if(mpStates==0) return false;
542  if(mpTransRel==0) return false;
543  if(mpGlobalAttribute==0) return false;
544  // transitions to be known
545  TransSet::Iterator tit;
546  StateSet::Iterator lit;
547  for(tit = TransRelBegin(); tit != TransRelEnd(); ++tit) {
548  if(! ExistsState(tit->X1)) return false;
549  if(! ExistsEvent(tit->Ev)) return false;
550  if(! ExistsState(tit->X2)) return false;
551  }
552  // init states to be known
553  for(lit = InitStatesBegin(); lit != InitStatesEnd(); ++lit)
554  if(! ExistsState(static_cast<Idx>(*lit))) return false;
555  for(lit = MarkedStatesBegin(); lit != MarkedStatesEnd(); ++lit)
556  if(! ExistsState(static_cast<Idx>(*lit))) return false;
557  // sets to have proper names
558  if(mpAlphabet->Name() != "Alphabet") return false;
559  if(mpStates->Name() != "States") return false;
560  if(mInitStates.Name() != "InitStates") return false;
561  if(mMarkedStates.Name() != "MarkedStates") return false;
562  // event symbol table
563  NameSet::Iterator eit;
564  for(eit = AlphabetBegin(); eit != AlphabetEnd(); eit ++) {
565  if(EventName(*eit)=="") return false;
566  }
567  // done
568  return true;
569 }
570 
571 // AlphabetSize()
573  return mpAlphabet->Size();
574 }
575 
576 // Size()
577 Idx vGenerator::Size(void) const {
578  return mpStates->Size();
579 }
580 
581 // Clear()
582 void vGenerator::Clear(void) {
583  FD_DG("vGenerator(" << this << ")::Clear()");
584  mpAlphabet->Clear();
585  mpStates->Clear();
587  mpTransRel->Clear();
588  mInitStates.Clear();
591  FD_DG("vGenerator(" << this << ")::Clear(): done");
592 }
593 
594 // ClearGlobalAttribute()
597 }
598 
599 // ClearStateAttributes()
602 }
603 
604 // ClearEventAttributes()
607 }
608 
609 // ClearTransAttributes()
612 }
613 
614 // ClearAttributes()
620 }
621 
622 
623 // ClearStates()
625  mpStates->Clear();
626  mpTransRel->Clear();
627  mInitStates.Clear();
630 }
631 
632 // TransRelSize()
634  return mpTransRel->Size();
635 }
636 
637 // InitStatesSize()
639  return mInitStates.Size();
640 }
641 
642 // MarkedStatesSize()
644  return mMarkedStates.Size();
645 }
646 
647 // AlphabetEmpty()
648 bool vGenerator::AlphabetEmpty(void) const {
649  return mpAlphabet->Empty();
650 }
651 
652 // Empty()
653 bool vGenerator::Empty(void) const {
654  return mpStates->Empty();
655 }
656 
657 // TransRelEmpty()
658 bool vGenerator::TransRelEmpty(void) const {
659  return mpTransRel->Empty();
660 }
661 
662 // InitStatesEmpty()
663 bool vGenerator::InitStatesEmpty(void) const {
664  return mInitStates.Empty();
665 }
666 
667 // MarkedStatesEmpty()
669  return mMarkedStates.Empty();
670 }
671 
672 
673 // ClearMinStateIndexMap()
675  FD_DG("vGenerator::ClearMinStateIndexMap()");
676  // fake const
677  vGenerator* fakeconst = const_cast<vGenerator*>(this);
678  fakeconst->mMinStateIndexMap.clear();
679 }
680 
681 // MinStateIndexMap()
682 const std::map<Idx,Idx>& vGenerator::MinStateIndexMap(void) const {
683  return mMinStateIndexMap;
684 }
685 
686 
687 // SetMinStateIndexMap()
689  FD_DG("vGenerator::SetMinStateIndexMap()");
690  // fake const
691  vGenerator* fakeconst = const_cast<vGenerator*>(this);
692  // clear map
693  fakeconst->ClearMinStateIndexMap();
694  StateSet::Iterator it;
695  Idx minindex = 0;
696  // if generator states get names
697  if(StateNamesEnabled()) {
698  // named initial states first
699  for(it = InitStatesBegin(); it != InitStatesEnd(); ++it) {
700  if(StateName(static_cast<Idx>(*it)) != "") {
701  fakeconst->mMinStateIndexMap[*it] = ++minindex;
702  }
703  }
704  // then all other named states
705  for(it = StatesBegin(); it != StatesEnd(); ++it) {
706  if(mMinStateIndexMap.count(*it) == 0) {
707  if(StateName(static_cast<Idx>(*it)) != "") {
708  fakeconst->mMinStateIndexMap[*it] = ++minindex;
709  }
710  }
711  }
712  // at last all anonymous states
713  for(it = StatesBegin(); it != StatesEnd(); ++it) {
714  if(mMinStateIndexMap.count(*it) == 0) {
715  fakeconst->mMinStateIndexMap[*it] = ++minindex;
716  }
717  }
718  }
719  // if generator states are all anonymous
720  else {
721  // all initial states first
722  for(it = InitStatesBegin(); it != InitStatesEnd(); ++it) {
723  fakeconst->mMinStateIndexMap[*it] = ++minindex;
724  }
725  // then the rest
726  for(it = StatesBegin(); it != StatesEnd(); ++it) {
727  if(mMinStateIndexMap.count(*it) == 0) {
728  fakeconst->mMinStateIndexMap[*it] = ++minindex;
729  }
730  }
731  }
732 #ifdef FAUDES_DEBUG_CONTAINER
733  std::map<Idx,Idx>::const_iterator _it;
734  for(_it = mMinStateIndexMap.begin(); _it != mMinStateIndexMap.end(); ++_it) {
735  FD_DC("vGenerator::MinStateIndexMap: " << _it->first
736  << " <-- " << SStr(_it->second));
737  }
738 #endif
739 }
740 
741 
742 // MinStateIndex(index)
744  std::map<Idx,Idx>::const_iterator minit;
745  minit = mMinStateIndexMap.find(index);
746  if(minit != mMinStateIndexMap.end()) {
747  return minit->second;
748  }
749  return index;
750 }
751 
752 
753 // Max StateIndex
755  if(mpStates->Empty()) return 0;
756  return *(--(mpStates->End()));
757 }
758 
759 // Re-enumerate states to obtain a consecutive state set
761  // bail out on trivial
762  // if(MaxStateIndex()==Size()) return; tmoor 201206: dont bail out to be consistent with token IO
763  // prepare buffer and index map
764  vGenerator* dst = New();
765  dst->InsEvents(Alphabet());
767  // doit: states
768  StateSet::Iterator sit;
769  Idx s;
770  for(sit=StatesBegin(); sit!=StatesEnd(); ++sit) {
771  s=MinStateIndex(*sit);
772  dst->InsState(s);
773  dst->StateAttribute(s,StateAttribute(*sit));
774  if(StateNamesEnabled())
775  dst->StateName(s,StateName(*sit));
776  }
777  for(sit=InitStatesBegin(); sit!=InitStatesEnd(); ++sit) {
778  s=MinStateIndex(*sit);
779  dst->SetInitState(s);
780  }
781  for(sit=MarkedStatesBegin(); sit!=MarkedStatesEnd(); ++sit) {
782  s=MinStateIndex(*sit);
783  dst->SetMarkedState(s);
784  }
785  // doit: transitions
786  TransSet::Iterator tit;
787  for(tit=TransRelBegin(); tit!=TransRelEnd(); tit++) {
788  Transition dt(MinStateIndex(tit->X1),tit->Ev,MinStateIndex(tit->X2));
789  dst->SetTransition(dt);
790  dst->TransAttribute(dt,TransAttribute(*tit));
791  }
792  // move relevant core members
794  delete mpStates;
795  delete mpTransRel;
796  mpStates=dst->mpStates;
797  mpTransRel=dst->mpTransRel;
798  dst->mpStates=0;
799  dst->mpTransRel=0;
800  // move other members
801  mInitStates=dst->InitStates();
803  // update callback
804  UpdateCore();
805  // delete buffer
806  delete dst;
807  // invalidate map
809 }
810 
811 
812 // EventSymbolTablep() const
814  return mpEventSymbolTable;
815 }
816 
817 // GlobalEventSymbolTablep() const
820 }
821 
822 // EventSymbolTablep(pSymTab)
824  mpEventSymbolTable=pSymTab;
825  // todo: set symboltable in mpAlphabet
826 }
827 
828 // EventSymbolTablep(rOtherGen)
831 }
832 
833 // EventIndex(rName)
834 Idx vGenerator::EventIndex(const std::string& rName) const {
835  return mpEventSymbolTable->Index(rName);
836 }
837 
838 // EventName(index)
839 std::string vGenerator::EventName(Idx index) const {
840  return mpEventSymbolTable->Symbol(index);
841 }
842 
843 // EventName(index, name)
844 void vGenerator::EventName(Idx index, const std::string& rName) {
845  FD_DG("vGenerator(" << this << ")::EventName("
846  << index << ",\"" << rName << "\")");
847 #ifdef FAUDES_CHECKED
848  if (! ExistsEvent(index)) {
849  std::stringstream errstr;
850  errstr << "event \"" << index << "\" not found in generator \""
851  << Name() << "\"";
852  throw Exception("vGenerator::EventName(name)", errstr.str(), 89);
853  }
854 #endif
855  mpEventSymbolTable->SetEntry(index, rName);
856 }
857 
858 // UniqueEventName(rName)
859 std::string vGenerator::UniqueEventName(const std::string& rName) const {
860  std::string name=rName;
861  if(name=="") name="ev";
862  return mpEventSymbolTable->UniqueSymbol(name) ;
863 }
864 
865 
866 // EventRename
867 bool vGenerator::EventRename(Idx event, const std::string& rNewName) {
868  // consistency
869  FD_DG("vGenerator(" << this << ")::EventRename(" << EStr(event) << ", " << rNewName << ")");
870 #ifdef FAUDES_CHECKED
871  if (! ExistsEvent(event)) {
872  std::stringstream errstr;
873  errstr << "event \"" << event << "\" not found in generator \""
874  << Name() << "\"";
875  throw Exception("vGenerator::EventReame(name)", errstr.str(), 89);
876  }
877 #endif
878  // prepare formal result
879  bool res=ExistsEvent(rNewName);
880  // insert new event
881  Idx newidx=InsEvent(rNewName);
882  // bail out if events are the same
883  if(newidx==event) return true;
884  // copy event attribute
885  if(!res) EventAttribute(newidx,EventAttribute(event));
886  // store new transitions (with their attributes)
887  TransSet* newtrans= TransRel().New();
888  // iterate over transitions
890  while(tit != TransRelEnd()) {
891  if(tit->Ev!=event) {++tit; continue;}
892  Transition trans= Transition(tit->X1, newidx, tit->X2);
893  newtrans->Insert(trans);
894  newtrans->Attribute(trans,TransAttribute(*tit));
895  ClrTransition(tit++);
896  }
897  // merge transitions
898  for(tit=newtrans->Begin(); tit!=newtrans->End(); tit++) {
899  SetTransition(*tit);
900  TransAttribute(*tit,newtrans->Attribute(*tit));
901  }
902  // free temp
903  delete newtrans;
904  // remore original event
905  DelEvent(event);
906  // done
907  FD_DG("vGenerator(" << this << ")::EventRename(" << EStr(event) << ", " << rNewName << "):OK");
908  return res;
909 }
910 
911 // EventRename
912 bool vGenerator::EventRename(const std::string& rOldName, const std::string& rNewName) {
913  Idx oev = EventIndex(rOldName);
914  return EventRename(oev,rNewName);
915 }
916 
917 // NewEventSet()
919  EventSet res;
921  return res;
922 }
923 
924 // NewEventSetp()
926  EventSet* res = new EventSet();
928  return res;
929 }
930 
931 
932 // StateSymbolTable() const
934  return mStateSymbolTable;
935 }
936 
937 // StateSymbolTable(rSymTab)
939  mStateSymbolTable=rSymTab;
941 }
942 
943 // StateIndex(rName)
944 Idx vGenerator::StateIndex(const std::string& rName) const {
945  return mpStateSymbolTable->Index(rName);
946 }
947 
948 // StateName(index)
949 std::string vGenerator::StateName(Idx index) const {
950  return mpStateSymbolTable->Symbol(index);
951 }
952 
953 // StateName(index, name)
954 void vGenerator::StateName(Idx index, const std::string& rName) {
955  FD_DG("vGenerator(" << this << ")::StateName("
956  << index << ",\"" << rName << "\")");
957 #ifdef FAUDES_CHECKED
958  if (! ExistsState(index)) {
959  std::stringstream errstr;
960  errstr << "state name \"" << rName << "\" not found in generator \""
961  << Name() << "\"";
962  throw Exception("vGenerator::StateName(name)", errstr.str(), 90);
963  }
964 #endif
965  mpStateSymbolTable->SetEntry(index, rName);
966 }
967 
968 
969 // ClearStateNames()
971  FD_DG("vGenerator(" << this << ")::ClearStateNames()");
973 }
974 
975 
976 // ClrStateName(index)
978  FD_DG("Generator(" << this << ")::ClrStateName(\"" << index << "\")");
979 #ifdef FAUDES_CHECKED
980  if (! ExistsState(index)) {
981  std::stringstream errstr;
982  errstr << "state \"" << index << "\" not found in generator \""
983  << Name() << "\"";
984  throw Exception("vGenerator::ClrStateName(name)", errstr.str(), 90);
985  }
986 #endif
988 }
989 
990 // ClrStateName(rName)
991 void vGenerator::ClrStateName(const std::string& rName) {
992  FD_DG("vGenerator(" << this << ")::ClrStateName(\"" << rName << "\")");
993  Idx index = StateIndex(rName);
994  ClrStateName(index);
995 }
996 
997 
998 // StateNamesEnabled()
1000  return mStateNamesEnabled;
1001 }
1002 
1003 // StateNamesEnabled(flag)
1005  mStateNamesEnabled = flag;
1006  if(!flag) ClearStateNames();
1007 }
1008 
1009 // StateNamesEnabled(flag)
1012 }
1013 
1014 // SetDefaultStateNames()
1016  FD_DG("vGenerator(" << this << ")::SetDefaultStateNames()");
1018  StateSet::Iterator it;
1019  for (it = StatesBegin(); it != StatesEnd(); ++it) {
1020  std::string dname;
1021  dname = std::string("S")+ToStringInteger(*it);
1022  mpStateSymbolTable->SetEntry(*it,dname);
1023  }
1024 }
1025 
1026 // EnforceStateNames(rTemplate)
1027 void vGenerator::EnforceStateNames(const std::string& rTemplate) {
1028  FD_DG("vGenerator(" << this << ")::EnforceStateNames(temp)");
1029  StateSet::Iterator it;
1030  for (it = StatesBegin(); it != StatesEnd(); ++it) {
1031  if(StateName(*it)=="") {
1032  std::string name=UniqueStateName(rTemplate + "_1");
1033  StateName(*it,name);
1034  }
1035  }
1036 }
1037 
1038 // UniqueStateName(rName)
1039 std::string vGenerator::UniqueStateName(const std::string& rName) const {
1040  std::string name=rName;
1041  if(name=="") name="st";
1042  return mpStateSymbolTable->UniqueSymbol(name) ;
1043 }
1044 
1045 
1046 // iterator AlphabetBegin() const
1047 EventSet::Iterator vGenerator::AlphabetBegin(void) const {
1048  return mpAlphabet->Begin();
1049 }
1050 
1051 // iterator AlphabetEnd() const
1052 EventSet::Iterator vGenerator::AlphabetEnd(void) const {
1053  return mpAlphabet->End();
1054 }
1055 
1056 // iterator StatesBegin() const
1057 StateSet::Iterator vGenerator::StatesBegin(void) const {
1058  return mpStates->Begin();
1059 }
1060 
1061 // iterator StatesEnd() const
1062 StateSet::Iterator vGenerator::StatesEnd(void) const {
1063  return mpStates->End();
1064 }
1065 
1066 // iterator TransRelBegin() const
1068  return mpTransRel->Begin();
1069 }
1070 
1071 // iterator TransRelEnd() const
1073  return mpTransRel->End();
1074 }
1075 
1076 // iterator TransRelBegin(x1) const
1078  return mpTransRel->Begin(x1);
1079 }
1080 
1081 // iterator TransRelEnd(x1) const
1083  return mpTransRel->End(x1);
1084 }
1085 
1086 // iterator TransRelBegin(x1, ev) const
1088  return mpTransRel->Begin(x1, ev);
1089 }
1090 
1091 // iterator TransRelEnd(x1, ev) const
1093  return mpTransRel->End(x1, ev);
1094 }
1095 
1096 // iterator FindTransition(trans)
1098  return mpTransRel->Find(rTrans);
1099 }
1100 
1101 // iterator FindTransition(x1, ex x2)
1103  return mpTransRel->Find(Transition(x1, ev, x2));
1104 }
1105 
1106 // iterator FindTransition(x1, ev, x2)
1108  const std::string& rX1, const std::string& rEv, const std::string& rX2) const
1109 {
1110  return mpTransRel->Find(StateIndex(rX1), EventIndex(rEv), StateIndex(rX2));
1111 }
1112 
1113 // iterator ExistsTransition(trans)
1114 bool vGenerator::ExistsTransition(const Transition& rTrans) const {
1115  return mpTransRel->Exists(rTrans);
1116 }
1117 
1118 // iterator ExistsTransition(x1, ex x2)
1119 bool vGenerator::ExistsTransition(Idx x1, Idx ev, Idx x2) const {
1120  return mpTransRel->Exists(Transition(x1, ev, x2));
1121 }
1122 
1123 // iterator ExistsTransition(x1, ev, x2)
1125  const std::string& rX1, const std::string& rEv, const std::string& rX2) const
1126 {
1127  return mpTransRel->Exists(StateIndex(rX1), EventIndex(rEv), StateIndex(rX2));
1128 }
1129 
1130 // iterator ExistsTransition(x1, ev)
1132  return mpTransRel->ExistsByX1Ev(x1, ev);
1133 }
1134 
1135 // iterator ExistsTransition(x1)
1137  return mpTransRel->ExistsByX1(x1);
1138 }
1139 
1140 
1141 // idx InitState() const
1143  if(mInitStates.Size()!=1) return 0;
1144  return *mInitStates.Begin();
1145 }
1146 
1147 
1148 
1149 // iterator InitStatesBegin() const
1150 StateSet::Iterator vGenerator::InitStatesBegin(void) const {
1151  return mInitStates.Begin();
1152 }
1153 
1154 // iterator InitStatesEnd() const
1155 StateSet::Iterator vGenerator::InitStatesEnd(void) const {
1156  return mInitStates.End();
1157 }
1158 
1159 // iterator MarkedStatesBegin()
1160 StateSet::Iterator vGenerator::MarkedStatesBegin(void) const {
1161  return mMarkedStates.Begin();
1162 }
1163 
1164 // iterator MarkedStatesEnd() const
1165 StateSet::Iterator vGenerator::MarkedStatesEnd(void) const {
1166  return mMarkedStates.End();
1167 }
1168 
1169 // InjectAlphabet(newalphabet)
1170 void vGenerator::InjectAlphabet(const EventSet& rNewAlphabet) {
1171  FD_DG("vGenerator::InjectAlphabet() " << rNewAlphabet.ToString());
1172 #ifdef FAUDES_CHECKED
1173  if(rNewAlphabet.SymbolTablep()!=mpEventSymbolTable) {
1174  std::stringstream errstr;
1175  errstr << "symboltable mismatch aka not implemented" << std::endl;
1176  throw Exception("vGenerator::InjectAlphabet", errstr.str(), 88);
1177  }
1178 #endif
1179  *mpAlphabet = rNewAlphabet;
1180  mpAlphabet->Name("Alphabet");
1181 }
1182 
1183 // RestrictAlphabet(newalphabet)
1184 void vGenerator::RestrictAlphabet(const EventSet& rNewAlphabet) {
1185  FD_DG("vGenerator::RestrictAlphabet() " << rNewAlphabet.ToString());
1186 #ifdef FAUDES_CHECKED
1187  if(rNewAlphabet.SymbolTablep()!=mpEventSymbolTable) {
1188  std::stringstream errstr;
1189  errstr << "symboltable mismatch aka not implemented" << std::endl;
1190  throw Exception("vGenerator::RestrictAlphabet", errstr.str(), 88);
1191  }
1192 #endif
1193  mpAlphabet->RestrictSet(rNewAlphabet);
1194  mpTransRel->RestrictEvents(rNewAlphabet);
1195 }
1196 
1197 // InsEvent(index)
1199  FD_DG("vGenerator(" << this << ")::InsEvent(" << index << ")");
1200  return mpAlphabet->Insert(index);
1201 }
1202 
1203 // InsEvent(rName)
1204 Idx vGenerator::InsEvent(const std::string& rName) {
1205  FD_DG("vGenerator(" << this << ")::InsEvent(\"" << rName << "\")");
1206  return mpAlphabet->Insert(rName);
1207 }
1208 
1209 // InsEvents(events)
1210 void vGenerator::InsEvents(const EventSet& events) {
1211  mpAlphabet->InsertSet(events);
1212 }
1213 
1214 // DelEvent(index)
1216  FD_DG("vGenerator(" << this << ")::DelEvent(" << index << ")");
1217  mpTransRel->EraseByEv(index);
1218  return mpAlphabet->Erase(index);
1219 }
1220 
1221 // DelEvent(rName)
1222 bool vGenerator::DelEvent(const std::string& rName) {
1223  FD_DG("vGenerator(" << this << ")::DelEvent(\"" << rName << "\")");
1224  Idx index = mpAlphabet->Index(rName);
1225  mpTransRel->EraseByEv(index);
1226  return mpAlphabet->Erase(index);
1227 }
1228 
1229 // DelEvents(events)
1230 void vGenerator::DelEvents(const EventSet& rEvents) {
1231  FD_DG("vGenerator(" << this << ")::DelEvents(\""
1232  << rEvents.ToString() << "\")");
1233  EventSet::Iterator it;
1234  for (it = rEvents.Begin(); it != rEvents.End(); ++it) {
1235  DelEvent(*it);
1236  }
1237 }
1238 
1239 // DelEventFromAlphabet(index)
1241  FD_DG("vGenerator(" << this << ")::DelEventFromAlphabet("
1242  << index << ")");
1243  return mpAlphabet->Erase(index);
1244 }
1245 
1246 // InsState()
1248  FD_DG("vGenerator(" << this << ")::InsState()");
1249  return mpStates->Insert();
1250 }
1251 
1252 // InsState(index)
1254  FD_DG("vGenerator(" << this << ")::InsState(" << index << ")");
1255  return mpStates->Insert(index);
1256 }
1257 
1258 // InsState(rName)
1259 Idx vGenerator::InsState(const std::string& rName) {
1260  FD_DG("vGenerator(" << this << ")::InsState(\"" << rName << "\")");
1261  Idx index=mpStates->Insert();
1262  StateName(index,rName);
1263  return index;
1264 }
1265 
1266 // InsStates(states)
1267 void vGenerator::InsStates(const StateSet& states) {
1268  mpStates->InsertSet(states);
1269 }
1270 
1271 // InjectState(index)
1273  FD_DG("vGenerator(" << this << ")::InjectState(\"" << SStr(index) << "\")");
1274  mpStates->Insert(index);
1275 }
1276 
1277 // InjectStates(rNewStates)
1278 void vGenerator::InjectStates(const StateSet& rNewStates) {
1279  FD_DG("vGenerator(" << this << ")::InjectStates(" << rNewStates.ToString() << ")");
1280  *mpStates=rNewStates;
1281  mpStates->Name("States");
1283  FD_DG("vGenerator(" << this << ")::InjectStates(): report " << mpStates->ToString());
1284 }
1285 
1286 // InsInitState()
1288  FD_DG("vGenerator(" << this << ")::InsInitState()");
1289  Idx index;
1290  index = InsState();
1291  mInitStates.Insert(index);
1292  return index;
1293 }
1294 
1295 // InsInitState(name)
1296 Idx vGenerator::InsInitState(const std::string& rName) {
1297  FD_DG("vGenerator(" << this << ")::InsInitState(\"" << rName << "\")");
1298  Idx index;
1299  index = InsState(rName);
1300  mInitStates.Insert(index);
1301  return index;
1302 }
1303 
1304 // InsInitState(name)
1306  bool res=InsState(index);
1307  mInitStates.Insert(index);
1308  return res;
1309 }
1310 
1311 // InsInitStates(states)
1313  mpStates->InsertSet(states);
1314  mInitStates.InsertSet(states);
1315 }
1316 
1317 // InsMarkedState()
1319  FD_DG("vGenerator(" << this << ")::InsMarkedState()");
1320  Idx index;
1321  index = InsState();
1322  mMarkedStates.Insert(index);
1323  return index;
1324 }
1325 
1326 // InsInitState(name)
1328  bool res=InsState(index);
1329  mMarkedStates.Insert(index);
1330  return res;
1331 }
1332 
1333 // InsMarkedState(rName)
1334 Idx vGenerator::InsMarkedState(const std::string& rName) {
1335  FD_DG("vGenerator(" << this << ")::InsMarkedState(\"" << rName << "\")");
1336  Idx index;
1337  index = InsState(rName);
1338  mMarkedStates.Insert(index);
1339  return index;
1340 }
1341 
1342 // InsMarkedStates(states)
1344  mpStates->InsertSet(states);
1345  mMarkedStates.InsertSet(states);
1346 }
1347 
1348 
1349 // DelState(index)
1351  FD_DG("vGenerator(" << this << ")::DelState(" << index << ")");
1352  // mInitStates
1353  mInitStates.Erase(index);
1354  // mstates
1355  mMarkedStates.Erase(index);
1356  // transrel
1357  mpTransRel->EraseByX1OrX2(index);
1358  // symbolic name
1359  mpStateSymbolTable->ClrEntry(index);
1360  // finally ... remove the state
1361  return mpStates->Erase(index);
1362 }
1363 
1364 // DelState(rName)
1365 bool vGenerator::DelState(const std::string& rName) {
1366  FD_DG("vGenerator(" << this << ")::DelState(\"" << rName << "\")");
1367  Idx index;
1368  index = StateIndex(rName);
1369 #ifdef FAUDES_CHECKED
1370  if (index == 0) {
1371  std::stringstream errstr;
1372  errstr << "state name \"" << rName << "\" not found in generator \""
1373  << Name() << "\"";
1374  throw Exception("vGenerator::DelState(name)", errstr.str(), 90);
1375  }
1376 #endif
1377  return DelState(index);
1378 }
1379 
1380 // DelStates(rDelStates)
1381 void vGenerator::DelStates(const StateSet& rDelStates) {
1382  FD_DG("vGenerator(" << this << ")::DelStates("
1383  << rDelStates.ToString() << ")");
1384  StateSet::Iterator cit;
1385  StateSet::Iterator cit_end;
1386  // symbolic state names
1387  for (cit = rDelStates.Begin(); cit != rDelStates.End(); ++cit) {
1389  }
1390  // statesets
1391  mpStates->EraseSet(rDelStates);
1392  mInitStates.EraseSet(rDelStates);
1393  mMarkedStates.EraseSet(rDelStates);
1394  // mpTransRel:
1395  mpTransRel->EraseByX1OrX2(rDelStates);
1396 }
1397 
1398 // DelStateFromStates(index)
1400  FD_DG("vGenerator(" << this << ")::DelStateFromStates(" << index << ")");
1401  // mStates + global
1402  return mpStates->Erase(index);
1403 }
1404 
1405 // DelStateFromStates(pos)
1406 StateSet::Iterator vGenerator::DelStateFromStates(StateSet::Iterator pos) {
1407  FD_DG("vGenerator(" << this << ")::DelState(" << *pos << ")");
1408  return mpStates->Erase(pos);
1409 }
1410 
1411 // RestrictStates(rStates)
1412 void vGenerator::RestrictStates(const StateSet& rStates) {
1413  FD_DG("vGenerator(" << this << ")::RestrictStates("
1414  << rStates.ToString() << ")");
1415 
1416  StateSet::Iterator cit;
1417  StateSet::Iterator cit_end;
1418  // symbolic state names
1419  for(cit = StatesBegin(); cit != StatesEnd(); ++cit) {
1420  if(!rStates.Exists(*cit)) mpStateSymbolTable->ClrEntry(*cit);
1421  }
1422  // statesets
1423  mpStates->RestrictSet(rStates);
1424  mInitStates.RestrictSet(rStates);
1425  mMarkedStates.RestrictSet(rStates);
1426  // mpTransRel:
1427  mpTransRel->RestrictStates(rStates);
1428 }
1429 
1430 
1431 // SetInitState(index)
1433  FD_DG("vGenerator(" << this << ")::SetInitState(" << index << ")");
1434 #ifdef FAUDES_CHECKED
1435  if (! mpStates->Exists(index)) {
1436  std::stringstream errstr;
1437  errstr << "vGenerator::SetMarkedState: index " << index
1438  << " not in stateset";
1439  throw Exception("vGenerator::SetInitState(..)", errstr.str(), 91);
1440  }
1441 #endif
1442  mInitStates.Insert(index);
1443 }
1444 
1445 // SetInitState(rName)
1446 void vGenerator::SetInitState(const std::string& rName) {
1447  FD_DG("vGenerator(" << this << ")::SetInitState(\"" << rName << "\")");
1448  Idx index = StateIndex(rName);
1449 #ifdef FAUDES_CHECKED
1450  if (index == 0) {
1451  std::stringstream errstr;
1452  errstr << "State name \"" << rName << "\" not known in Generator";
1453  throw Exception("vGenerator::SetInitState(..)", errstr.str(), 90);
1454  }
1455 #endif
1456  SetInitState(index);
1457 }
1458 
1459 // InjectInitStates(rNewInitStates)
1460 void vGenerator::InjectInitStates(const StateSet& rNewInitStates) {
1461  FD_DG("vGenerator(" << this << ")::InjectInitStates("
1462  << rNewInitStates.ToString() << ")");
1463  mInitStates = rNewInitStates;
1464  mInitStates.Name("InitStates");
1465 }
1466 
1467 // ClrInitState(index)
1469  FD_DG("vGenerator(" << this << ")::ClrInitState(" << index << ")");
1470 #ifdef FAUDES_CHECKED
1471  if (! mpStates->Exists(index)) {
1472  std::stringstream errstr;
1473  errstr << "vGenerator::SetMarkedState: index " << index
1474  << " not in stateset";
1475  throw Exception("vGenerator::ClrInitState(..)", errstr.str(), 91);
1476  }
1477 #endif
1478  mInitStates.Erase(index);
1479 }
1480 
1481 // ClrInitState(rName)
1482 void vGenerator::ClrInitState(const std::string& rName) {
1483  FD_DG("vGenerator(" << this << ")::ClrInitState(\"" << rName << "\")");
1484  Idx index = StateIndex(rName);
1485 #ifdef FAUDES_CHECKED
1486  if (index == 0) {
1487  std::stringstream errstr;
1488  errstr << "State name \"" << rName << "\" not known in Generator";
1489  throw Exception("vGenerator::ClrInitState(..)", errstr.str(), 90);
1490  }
1491 #endif
1492  ClrInitState(index);
1493 }
1494 
1495 // ClrInitState(pos)
1496 StateSet::Iterator vGenerator::ClrInitState(StateSet::Iterator pos) {
1497  FD_DG("vGenerator(" << this << ")::ClrInitState(" << *pos << ")");
1498  return mInitStates.Erase(pos);
1499 }
1500 
1501 // ClearInitStates()
1503  mInitStates.Clear();
1504 }
1505 
1506 // SetMarkedState(index)
1508  FD_DG("vGenerator(" << this << ")::SetMarkedState(" << index << ")");
1509 #ifdef FAUDES_CHECKED
1510  if (! mpStates->Exists(index)) {
1511  std::stringstream errstr;
1512  errstr << "vGenerator::SetMarkedState: index " << index
1513  << " not in stateset";
1514  throw Exception("vGenerator::SetMarkedState(..)", errstr.str(), 91);
1515  }
1516 #endif
1517  mMarkedStates.Insert(index);
1518 }
1519 
1520 // SetMarkedState(rName)
1521 void vGenerator::SetMarkedState(const std::string& rName) {
1522  FD_DG("vGenerator(" << this << ")::SetMarkedState(\"" << rName << "\")");
1523  Idx index = StateIndex(rName);
1524 #ifdef FAUDES_CHECKED
1525  if (index == 0) {
1526  std::stringstream errstr;
1527  errstr << "State name \"" << rName << "\" not known in Generator";
1528  throw Exception("vGenerator::SetMarkedState(..)", errstr.str(), 90);
1529  }
1530 #endif
1531  SetMarkedState(index);
1532 }
1533 
1534 // InjectMarkedStates(rNewMarkedStates)
1535 void vGenerator::InjectMarkedStates(const StateSet& rNewMarkedStates) {
1536  FD_DG("vGenerator(" << this << ")::InjectMarkedStates("
1537  << rNewMarkedStates.ToString() << ")");
1538  mMarkedStates = rNewMarkedStates;
1539  mMarkedStates.Name("MarkedStates");
1540 }
1541 
1542 // ClrMarkedState(index)
1544  FD_DG("vGenerator(" << this << ")::ClrMarkedState(" << index << ")");
1545 #ifdef FAUDES_CHECKED
1546  if (! mpStates->Exists(index)) {
1547  std::stringstream errstr;
1548  errstr << "vGenerator::ClrMarkedState: index " << index
1549  << " not in stateset";
1550  throw Exception("vGenerator::ClrMarkedState(..)", errstr.str(), 91);
1551  }
1552 #endif
1553  mMarkedStates.Erase(index);
1554 }
1555 
1556 // ClrMarkedState(rName)
1557 void vGenerator::ClrMarkedState(const std::string& rName) {
1558  FD_DG("vGenerator(" << this << ")::ClrMarkedState(\"" << rName << "\")");
1559  Idx index = StateIndex(rName);
1560 #ifdef FAUDES_CHECKED
1561  if (index == 0) {
1562  std::stringstream errstr;
1563  errstr << "State name \"" << rName << "\" not known in Generator";
1564  throw Exception("vGenerator::ClrMarkedState(..)", errstr.str(), 90);
1565  }
1566 #endif
1567  ClrMarkedState(index);
1568 }
1569 
1570 // ClrMarkedState(pos)
1571 StateSet::Iterator vGenerator::ClrMarkedState(StateSet::Iterator pos) {
1572  FD_DG("vGenerator(" << this << ")::ClrMarkedState(" << *pos << ")");
1573  return mMarkedStates.Erase(pos);
1574 }
1575 
1576 // ClearMarkedStates()
1578  mMarkedStates.Clear();
1579 }
1580 
1581 // InjectTransition(newtrans)
1583  FD_DG("vGenerator::InjectTransition(" << TStr(rTrans) << ")");
1584  mpTransRel->Inject(rTrans);
1585 }
1586 
1587 // InjectTransRel(newtransrel)
1588 void vGenerator::InjectTransRel(const TransSet& rNewTransrel) {
1589  FD_DG("vGenerator::InjectTransRel(...)");
1590  *mpTransRel=rNewTransrel;
1591  mpTransRel->Name("TransRel");
1592 }
1593 
1594 // SetTransition(rX1, rEv, rX2)
1595 bool vGenerator::SetTransition(const std::string& rX1, const std::string& rEv, const std::string& rX2) {
1596  FD_DG("vGenerator(" << this << ")::SetTransition(\""
1597  << rX1 << "\", \"" << rEv << "\", \"" << rX2 << "\")");
1598  Idx x1 = StateIndex(rX1);
1599  Idx x2 = StateIndex(rX2);
1600 #ifdef FAUDES_CHECKED
1601  if (x1 == 0) {
1602  FD_ERR("vGenerator::SetTransition: state " << rX1
1603  << " not in stateset");
1604  std::stringstream errstr;
1605  errstr << "State name " << rX1 << " not found in Generator";
1606  throw Exception("vGenerator::SetTransition(..)", errstr.str(), 90);
1607  }
1608  if (! mpAlphabet->Exists(rEv)) {
1609  FD_ERR("vGenerator::SetTransition: event " << rEv << " not in alphabet");
1610  std::stringstream errstr;
1611  errstr << "Event name " << rEv << " not found in event domain of Generator";
1612  throw Exception("vGenerator::SetTransition(..)", errstr.str(), 95);
1613  }
1614  if (x2 == 0) {
1615  FD_ERR("vGenerator::SetTransition: state " << rX2 << " not in stateset");
1616  std::stringstream errstr;
1617  errstr << "State name " << rX2 << " not found in Generator";
1618  throw Exception("vGenerator::SetTransition(..)", errstr.str(), 90);
1619  }
1620 #endif
1621  return SetTransition(Transition(x1, EventIndex(rEv), x2));
1622 }
1623 
1624 
1625 // SetTransition(x1, ev, x2)
1627  return SetTransition(Transition(x1,ev,x2));
1628 }
1629 
1630 // SetTransition(rTransition)
1631 bool vGenerator::SetTransition(const Transition& rTransition) {
1632  FD_DG("vGenerator(" << this << ")::SetTransition(" << rTransition.X1 << ","
1633  << rTransition.Ev << "," << rTransition.X2 << ")");
1634 #ifdef FAUDES_CHECKED
1635  if (! mpStates->Exists(rTransition.X1)) {
1636  std::stringstream errstr;
1637  errstr << "vGenerator::SetTransition: state " << SStr(rTransition.X1)
1638  << " not in stateset";
1639  throw Exception("vGenerator::SetTransition(..)", errstr.str(), 95);
1640  }
1641  if (! mpAlphabet->Exists(rTransition.Ev)) {
1642  std::stringstream errstr;
1643  errstr << "vGenerator::SetTransition: event " << EStr(rTransition.Ev)
1644  << " not in alphabet ";
1645  throw Exception("vGenerator::SetTransition(..)", errstr.str(), 95);
1646  }
1647  if (! mpStates->Exists(rTransition.X2)) {
1648  std::stringstream errstr;
1649  errstr << "vGenerator::SetTransition: state " << SStr(rTransition.X2)
1650  << " not in stateset";
1651  throw Exception("vGenerator::SetTransition(..)", errstr.str(), 95);
1652  }
1653 #endif
1654  return mpTransRel->Insert(rTransition);
1655 }
1656 
1657 
1658 
1659 // ClrTransition.X1, ev, x2)
1661  FD_DG("vGenerator(" << this << ")::ClrTransition("
1662  << x1 << "," << ev << "," << x2 << ")");
1663  mpTransRel->Erase(x1, ev, x2);
1664 }
1665 
1666 // ClrTransition(rTransition)
1667 void vGenerator::ClrTransition(const Transition& rTransition) {
1668  FD_DG("vGenerator(" << this << ")::ClrTransition(" << TStr(rTransition) << ")");
1669  mpTransRel->Erase(rTransition);
1670 }
1671 
1672 // ClrTransition(it)
1674  FD_DG("vGenerator(" << this << ")::ClrTransition(" << TStr(*it)<< ")" );
1675  return mpTransRel->Erase(it);
1676 }
1677 
1678 // ClrTransitions(X1, ev)
1680  FD_DG("vGenerator(" << this << ")::ClrTransition("
1681  << x1 << "," << ev << ")");
1682  mpTransRel->EraseByX1Ev(x1, ev);
1683 }
1684 
1685 // ClrTransitions(X1)
1687  FD_DG("vGenerator(" << this << ")::ClrTransition("
1688  << x1 << ")");
1689  mpTransRel->EraseByX1(x1);
1690 }
1691 
1692 // TransAttribute(trans, attr)
1693 void vGenerator::TransAttribute(const Transition& rTrans, const Type& rAttr) {
1694  FD_DG("vGenerator(" << this << ")::TransAttribute("
1695  << TStr(rTrans) << ",\"" << rAttr.ToString() << "\")");
1696  mpTransRel->Attribute(rTrans, rAttr);
1697 }
1698 
1699 // TransAttributep(trans)
1701  return mpTransRel->Attributep(rTrans);
1702 }
1703 
1704 
1705 // TransAttribute(trans)
1707  return mpTransRel->Attribute(rTrans);
1708 }
1709 
1710 // ClrTransAttribute(trans)
1712  mpTransRel->ClrAttribute(rTrans);
1713 }
1714 
1715 
1716 // ClearTransRel()
1718  mpTransRel->Clear();
1719 }
1720 
1721 // EventAttribute(index, attr)
1722 void vGenerator::EventAttribute(Idx index, const Type& rAttr) {
1723  FD_DG("vGenerator(" << this << ")::EventAttribute("
1724  << EStr(index) << ",\"" << rAttr.ToString() << "\")");
1725  mpAlphabet->Attribute(index, rAttr);
1726 }
1727 
1728 
1729 // EventAttributes(set)
1730 void vGenerator::EventAttributes(const EventSet& rEventSet) {
1731  FD_DG("vGenerator(" << this << ")::EventAttributes("
1732  << rEventSet.ToString() << "\")");
1733  mpAlphabet->Attributes(rEventSet);
1734 }
1735 
1736 // ClrEventAttribute(index)
1738  FD_DG("vGenerator(" << this << ")::ClrEventAttribute(\"" << EStr(index) << "\")");
1739  mpAlphabet->ClrAttribute(index);
1740 }
1741 
1742 // StateAttribute(index, attr)
1743 void vGenerator::StateAttribute(Idx index, const Type& rAttr) {
1744  FD_DG("vGenerator(" << this << ")::StateAttribute("
1745  << SStr(index) << ",\"" << rAttr.ToString() << "\")");
1746  mpStates->Attribute(index, rAttr);
1747 }
1748 
1749 // ClrStateAttribute(index)
1751  FD_DG("vGenerator(" << this << ")::ClrStateAttribute(\"" << index << "\")");
1752  mpStates->ClrAttribute(index);
1753 }
1754 
1755 // ExistsEvent(index)
1756 bool vGenerator::ExistsEvent(Idx index) const {
1757  return mpAlphabet->Exists(index);
1758 }
1759 
1760 // ExistsEvent(rName)
1761 bool vGenerator::ExistsEvent(const std::string& rName) const {
1762  return mpAlphabet->Exists(rName);
1763 }
1764 
1765 // FindEvent(index) const
1766 EventSet::Iterator vGenerator::FindEvent(Idx index) const {
1767  return mpAlphabet->Find(index);
1768 }
1769 
1770 // FindEvent(rName)
1771 EventSet::Iterator vGenerator::FindEvent(const std::string& rName) const {
1772  return mpAlphabet->Find(rName);
1773 }
1774 
1775 // ExistsState(index)
1776 bool vGenerator::ExistsState(Idx index) const {
1777  return mpStates->Exists(index);
1778 }
1779 
1780 // ExistsName(name)
1781 bool vGenerator::ExistsState(const std::string& rName) const {
1782  return ExistsState(StateIndex(rName));
1783 }
1784 
1785 // FindState(rName) const
1786 StateSet::Iterator vGenerator::FindState(const std::string& rName) const {
1787  return mpStates->Find(mpStateSymbolTable->Index(rName));
1788 }
1789 
1790 // FindState(index) const
1791 StateSet::Iterator vGenerator::FindState(Idx index) const {
1792  return mpStates->Find(index);
1793 }
1794 
1795 // ExistsInitState(index)
1797  return mInitStates.Exists(index);
1798 }
1799 
1800 // FindInitState(index)
1801 StateSet::Iterator vGenerator::FindInitState(Idx index) const {
1802  return mInitStates.Find(index);
1803 }
1804 
1805 // ExistsMarkedState(index)
1807  return mMarkedStates.Exists(index);
1808 }
1809 
1810 // FindMarkedState(index)
1811 StateSet::Iterator vGenerator::FindMarkedState(Idx index) const {
1812  return mMarkedStates.Find(index);
1813 }
1814 
1815 // EventAttribute(index)
1817  return mpAlphabet->Attribute(index);
1818 }
1819 
1820 // EventAttributep(index)
1822  return mpAlphabet->Attributep(index);
1823 }
1824 
1825 // EventAttribute(rName)
1826 const AttributeVoid& vGenerator::EventAttribute(const std::string& rName) const {
1827  return EventAttribute(EventIndex(rName));
1828 }
1829 
1830 // EventAttributep(rName)
1831 AttributeVoid* vGenerator::EventAttributep(const std::string& rName) {
1832  return EventAttributep(EventIndex(rName));
1833 }
1834 
1835 // StateAttribute(index)
1837  return mpStates->Attribute(index);
1838 }
1839 
1840 // StateAttributep(index)
1842  return mpStates->Attributep(index);
1843 }
1844 
1845 // GlobalAttribute(attr)
1846 void vGenerator::GlobalAttribute(const Type& rAttr) {
1847  FD_DG("vGenerator(" << this << ")::GlobalAttribute("
1848  << rAttr.ToString() << "\")");
1849  // set to void is ok for silient ignore
1850  if(typeid(rAttr)==typeid(AttributeVoid)) return;
1851  // error:
1852  std::stringstream errstr;
1853  errstr << "cannot cast global attribute " << rAttr.ToString() << " for generator " << Name();
1854  throw Exception("vGenerator::GlobalAttribute", errstr.str(), 63);
1855 }
1856 
1857 // GlobalAttributeTry(attr)
1859  FD_DG("vGenerator(" << this << ")::GlobalAttributeTry("
1860  << rAttr.ToString() << "\")");
1861  // ignore
1862 }
1863 
1864 // GlobalAttribute()
1866  FD_DG("vGenerator(" << this << ")::GlobalAttribute()");
1867  return *mpGlobalAttribute;
1868 }
1869 
1870 // GlobalAttributep()
1872  FD_DG("vGenerator(" << this << ")::GlobalAttributep()");
1873  return mpGlobalAttribute;
1874 }
1875 
1876 
1877 // Alphabet()
1878 const EventSet& vGenerator::Alphabet(void) const {
1879  return *mpAlphabet;
1880 }
1881 
1882 // States()
1883 const StateSet& vGenerator::States(void) const {
1884  return *mpStates;
1885 }
1886 
1887 // TransRel()
1888 const TransSet& vGenerator::TransRel(void) const {
1889  return *mpTransRel;
1890 }
1891 
1892 
1893 // TransRel(res)
1896 void vGenerator::TransRel(TransSetEvX2X1& res) const { mpTransRel->ReSort(res); }
1897 void vGenerator::TransRel(TransSetX2EvX1& res) const { mpTransRel->ReSort(res); }
1898 void vGenerator::TransRel(TransSetX2X1Ev& res) const { mpTransRel->ReSort(res); }
1899 void vGenerator::TransRel(TransSetX1X2Ev& res) const { mpTransRel->ReSort(res); }
1900 
1901 
1903  const std::string& rX1, const std::string& rEv, const std::string& rX2) const {
1904  return Transition(StateIndex(rX1),EventIndex(rEv),StateIndex(rX2));
1905 }
1906 
1907 // InitStates()
1908 const StateSet& vGenerator::InitStates(void) const {
1909  return mInitStates;
1910 }
1911 
1912 // MarkedStates()
1914  return mMarkedStates;
1915 }
1916 
1917 // MinimizeAlphabet()
1919  mpAlphabet->NameSet::EraseSet(UnusedEvents());
1920 }
1921 
1922 // UsedEvents()
1924  EventSet resultset = NewEventSet();
1925  TransSet::Iterator it;
1926  for (it = mpTransRel->Begin(); it != mpTransRel->End(); ++it) {
1927  resultset.Insert(it->Ev);
1928  }
1929  return resultset;
1930 }
1931 
1932 // UnusedEvents()
1934  return *mpAlphabet - UsedEvents();
1935 }
1936 
1937 // ActiveEventSet(x1)
1939  EventSet result = NewEventSet();
1940  TransSet::Iterator it;
1941  for (it = TransRelBegin(x1); it != TransRelEnd(x1); ++it) {
1942  result.Insert(it->Ev);
1943  }
1944  return result;
1945 }
1946 
1947 // ActiveTransSet(x1)
1949  TransSet result;
1950  TransSet::Iterator it;
1951  for (it = TransRelBegin(x1); it != TransRelEnd(x1); ++it) {
1952  result.Insert(*it);
1953  }
1954  return result;
1955 }
1956 
1957 // TransRelStates()
1959  StateSet states;
1960  TransSet::Iterator it;
1961  for (it=mpTransRel->Begin(); it != mpTransRel->End(); ++it) {
1962  states.Insert(it->X1);
1963  states.Insert(it->X2);
1964  }
1965  return states;
1966 }
1967 
1968 // SuccessorStates(x1)
1970  return mpTransRel->SuccessorStates(x1);
1971 }
1972 
1973 // SuccessorStates(x1,ev)
1975  return mpTransRel->SuccessorStates(x1,ev);
1976 }
1977 
1978 
1979 // idx SuccessorState() const
1981  TransSet::Iterator it = mpTransRel->Begin(x1,ev);
1982  TransSet::Iterator it_end = mpTransRel->End(x1,ev);
1983  if(it==it_end) return 0;
1984  Idx res=(*it).X2;
1985 #ifdef FAUDES_CHECKED
1986  it++;
1987  if(it!=it_end) {
1988  std::stringstream errstr;
1989  errstr << "successor state does not exist uniquely" << std::endl;
1990  throw Exception("vGenerator::SuccessorState", errstr.str(), 92);
1991  }
1992 #endif
1993  return res;
1994 }
1995 
1996 
1997 // AccessibleSet()
1999  // initialize todo stack
2000  std::stack<Idx> todo;
2001  StateSet::Iterator sit;
2002  for(sit = InitStatesBegin(); sit != InitStatesEnd(); ++sit)
2003  todo.push(*sit);
2004  // loop variables
2005  StateSet accessibleset;
2006  TransSet::Iterator tit;
2007  TransSet::Iterator tit_end;
2008  // loop
2009  while(!todo.empty()) {
2010  // pop
2011  Idx x1=todo.top();
2012  todo.pop();
2013  // sense known
2014  if(accessibleset.Exists(x1)) continue;
2015  // record
2016  accessibleset.Insert(x1);
2017  // iterate/push
2018  tit=TransRelBegin(x1);
2019  tit_end=TransRelEnd(x1);
2020  for(; tit != tit_end; ++tit)
2021  if(tit->X2 != x1)
2022  todo.push(tit->X2);
2023  }
2024  // done
2025  accessibleset.Name("AccessibleSet");
2026  return accessibleset;
2027 }
2028 
2029 // Accessible()
2031  StateSet accessibleset = AccessibleSet();
2032  StateSet not_accessible = *mpStates - accessibleset;
2033  DelStates(not_accessible);
2034  // return true if there is an initial state
2035  if (!mInitStates.Empty()) {
2036  FD_DF("vGenerator::accessible: generator is accessible");
2037  return true;
2038  }
2039  FD_DF("vGenerator::accessible: generator is accessible but empty");
2040  return false;
2041 }
2042 
2043 // IsAccessible()
2044 bool vGenerator::IsAccessible(void) const {
2045  if(AccessibleSet() == *mpStates) {
2046  FD_DF("vGenerator::accessible: generator is accessible");
2047  return true;
2048  }
2049  FD_DF("vGenerator::accessible: generator is not accessible");
2050  return false;
2051 }
2052 
2053 // CoaccessibleSet()
2055  // build reverse transition relation
2056  TransSetX2EvX1 rtrel;
2057  TransRel(rtrel);
2058  // initialize todo stack
2059  StateSet::Iterator sit;
2060  std::stack<Idx> todo;
2061  for(sit = MarkedStatesBegin(); sit != MarkedStatesEnd(); ++sit)
2062  todo.push(*sit);
2063  // loop variables
2064  StateSet coaccessibleset;
2066  TransSetX2EvX1::Iterator tit_end;
2067  // loop
2068  while(!todo.empty()) {
2069  // pop
2070  Idx x2=todo.top();
2071  todo.pop();
2072  // sense known
2073  if(coaccessibleset.Exists(x2)) continue;
2074  // record
2075  coaccessibleset.Insert(x2);
2076  // iterate/push
2077  tit=rtrel.BeginByX2(x2);
2078  tit_end=rtrel.EndByX2(x2);
2079  for(; tit != tit_end; ++tit)
2080  if(tit->X1 != x2)
2081  todo.push(tit->X1);
2082  }
2083  // done
2084  coaccessibleset.Name("CoaccessibleSet");
2085  return coaccessibleset;
2086 }
2087 
2088 // Coaccessible()
2090  StateSet coaccessibleset = CoaccessibleSet();
2091  StateSet not_coaccessible = *mpStates - coaccessibleset;
2092  DelStates(not_coaccessible);
2093  // return true if there is a marked state
2094  if (! mMarkedStates.Empty()) {
2095  FD_DF("vGenerator::coaccessible: generator is coaccessible");
2096  return true;
2097  }
2098  FD_DF("vGenerator::coaccessible: generator is not coaccessible");
2099  return false;
2100 }
2101 
2102 // IsCoaccessible()
2103 bool vGenerator::IsCoaccessible(void) const {
2104  if(CoaccessibleSet() == *mpStates) {
2105  FD_DF("vGenerator::coaccessible: generator is coaccessible");
2106  return true;
2107  }
2108  FD_DF("vGenerator::coaccessible: generator is not coaccessible");
2109  return false;
2110 }
2111 
2112 // TrimSet()
2114  FD_DF("vGenerator::trimset: trim states: "
2117  res.Name("TrimSet");
2118  return res;
2119 }
2120 
2121 // Trim()
2122 bool vGenerator::Trim(void) {
2123  FD_DF("vGenerator::trim: generator states: " << mpStates->ToString());
2124  // better: compute sets and do one state delete
2125  bool accessiblebool = Accessible();
2126  bool coaccessiblebool = Coaccessible();
2127  FD_DF("vGenerator::trim: trim states: " << mpStates->ToString());
2128  if(accessiblebool && coaccessiblebool) {
2129  FD_DF("vGenerator::Trim(): generator is nontrivial");
2130  return true;
2131  }
2132  FD_DF("vGenerator::Trim(): generator is trivial");
2133  return false;
2134 }
2135 
2136 
2137 // IsTrim()
2138 bool vGenerator::IsTrim(void) const {
2139  bool res=true;
2140  if(!IsAccessible()) res=false;
2141  else if(!IsCoaccessible()) res=false;
2142  FD_DF("vGenerator::IsTrim(): result " << res);
2143  return res;
2144 }
2145 
2146 
2147 // BlockingStates()
2149  FD_DF("vGenerator::BlockingSet: blocking states: "
2151  return AccessibleSet() - CoaccessibleSet();
2152 }
2153 
2154 
2155 
2156 // IsComplete
2157 bool vGenerator::IsComplete(const StateSet& rStates) const {
2158  FD_DG("IsComplete(" << Name() << ")");
2159 
2160  // loop over provided states
2161  StateSet::Iterator sit=rStates.Begin();
2162  StateSet::Iterator sit_end=rStates.End();
2163  for(;sit!=sit_end;sit++){
2165  TransSet::Iterator tit_end=TransRelEnd(*sit);
2166  if(tit==tit_end) break;
2167  }
2168  // return true if no terminal state has been found
2169  return sit==sit_end;
2170 }
2171 
2172 
2173 // IsComplete w.r.t. rSigmaO
2174 bool vGenerator::IsComplete(const EventSet& rSigmaO) const {
2175  FD_DC("IsComplete(" << Name() << ")");
2176  // find good states: where some rEvent is enabled
2177  std::stack<Idx> todo;
2179  TransSet::Iterator tit_end=TransRelEnd();
2180  while(tit!=tit_end){
2181  if(!rSigmaO.Exists(tit->Ev)) { ++tit; continue; }
2182  todo.push(tit->X1);
2183  tit=TransRelEnd(tit->X1);
2184  }
2185  // build reverse transition relation
2186  TransSetX2EvX1 rtrel;
2187  TransRel(rtrel);
2188  // reverse reachability analysis for more good states
2189  StateSet good;
2190  while(!todo.empty()) {
2191  // pop
2192  Idx x2=todo.top();
2193  todo.pop();
2194  // sense known
2195  if(good.Exists(x2)) continue;
2196  // record
2197  good.Insert(x2);
2198  // iterate/push
2199  TransSetX2EvX1::Iterator tit=rtrel.BeginByX2(x2);
2200  TransSetX2EvX1::Iterator tit_end=rtrel.EndByX2(x2);
2201  for(; tit != tit_end; ++tit)
2202  if(tit->X1 != x2) todo.push(tit->X1);
2203  }
2204  FD_DG("IsComplete(" << Name() << "): done");
2205  // done
2206  return good == States();
2207 }
2208 
2209 
2210 // IsComplete
2211 bool vGenerator::IsComplete(void) const {
2212  return IsComplete(States());
2213 }
2214 
2215 // Complete
2217  // states to remove
2218  StateSet termset = TerminalStates();
2219  // iterative search
2220  bool done;
2221  do {
2222  // over all states (could make use of reverse transrel here)
2223  StateSet::Iterator sit = States().Begin();
2224  StateSet::Iterator sit_end = States().End();
2225  done=true;
2226  for(; sit!=sit_end; ++sit) {
2227  if(termset.Exists(*sit)) continue;
2228  TransSet::Iterator tit = TransRelBegin(*sit);
2229  TransSet::Iterator tit_end = TransRelEnd(*sit);
2230  for (; tit != tit_end; ++tit) {
2231  if(!termset.Exists(tit->X2)) break;
2232  }
2233  if(tit==tit_end) {
2234  termset.Insert(*sit);
2235  done=false;
2236  }
2237  }
2238  } while(!done);
2239  // remove those states
2240  DelStates(termset);
2241  // done
2242  return !InitStates().Empty();
2243 }
2244 
2245 // Complete w.r.t. rSigmaO
2246 bool vGenerator::Complete(const EventSet& rSigmaO) {
2247 
2248  // prepare reverse transition relation
2249  TransSetX2EvX1 rtrel;
2250  TransRel(rtrel);
2251 
2252  // initialize nu-iteration
2253  StateSet domain=States();
2254 
2255  // nu-loop
2256  while(true){
2257 
2258  // initialize mu-iteration
2259  StateSet target;
2261  TransSet::Iterator tit_end=TransRelEnd();
2262  while(tit!=tit_end) {
2263  if(!rSigmaO.Exists(tit->Ev)) { ++tit; continue; }
2264  if(!domain.Exists(tit->X2)) { ++tit; continue; }
2265  target.Insert(tit->X1);
2266  tit=TransRelEnd(tit->X1);
2267  }
2268 
2269  // mu-loop: find good states by reverse reachability
2270  StateSet good;
2271  StateSet::Iterator sit;
2272  std::stack<Idx> todo;
2273  for(sit = target.Begin(); sit != target.End(); ++sit)
2274  todo.push(*sit);
2275  while(!todo.empty()) {
2276  // pop
2277  Idx x2=todo.top();
2278  todo.pop();
2279  // sense known
2280  if(good.Exists(x2)) continue;
2281  // record
2282  good.Insert(x2);
2283  // iterate/push
2284  TransSetX2EvX1::Iterator tit=rtrel.BeginByX2(x2);
2285  TransSetX2EvX1::Iterator tit_end=rtrel.EndByX2(x2);
2286  for(; tit != tit_end; ++tit)
2287  if(tit->X1 != x2) todo.push(tit->X1);
2288  }
2289 
2290  // nu-break: target will not change on update
2291  if(domain <= good) break;
2292 
2293  // nu-update: restrict target to have a successor within domain
2294  domain = domain * good;
2295 
2296  }
2297 
2298  // remove other states
2299  RestrictStates(domain);
2300 
2301  // done
2302  return !InitStates().Empty();
2303 }
2304 
2305 
2306 
2307 // TerminalStates()
2309  FD_DG("Generator::TerminalStates(" << Name() << ")");
2310 
2311  // prepare result
2312  StateSet res;
2313 
2314  // loop states
2315  StateSet::Iterator sit=rStates.Begin();
2316  StateSet::Iterator sit_end=rStates.End();
2317  for(;sit!=sit_end;sit++){
2319  TransSet::Iterator tit_end=TransRelEnd(*sit);
2320  if(tit==tit_end) res.Insert(*sit);
2321  }
2322  // return terminal states
2323  res.Name("TerminalStates");
2324  return res;
2325 }
2326 
2327 // TerminalStates()
2329  return TerminalStates(States());
2330 }
2331 
2332 
2333 // OmegaTrim
2335 
2336  // note: this really is inefficient; at least we should
2337  // record the inverse transition relation for the coaccessile
2338  // iteration
2339 
2340  // first we make the generator accessible
2341  Accessible();
2342  // iterate coaccessible and complete until convergence in oserved
2343  while(1) {
2344  Idx osize=States().Size();
2345  Coaccessible();
2346  Complete();
2347  if(States().Size()==osize) break;
2348  }
2349  // done
2350  return !InitStates().Empty() && !MarkedStates().Empty();
2351 }
2352 
2353 
2354 // IsOmegaTrim()
2355 bool vGenerator::IsOmegaTrim(void) const {
2356  bool res=true;
2357  if(!IsAccessible()) res=false;
2358  else if(!IsCoaccessible()) res=false;
2359  else if(!IsComplete()) res=false;
2360  FD_DF("vGenerator::IsOmegaTrim(): result " << res);
2361  return res;
2362 }
2363 
2364 
2365 
2366 // IsDeterministic()
2368  // if there is more than one initial state ... nondet
2369  if (InitStatesSize() > 1) {
2370  FD_DG("vGenerator::IsDeterministic: more than one initial state");
2371  return false;
2372  }
2373  // if there is a state/event pair with non-unique successor ... nondet
2374  if (TransRelSize() < 2) return true;
2375  TransSet::Iterator it1;
2376  TransSet::Iterator it2;
2377  for (it1 = TransRelBegin(), it2 = it1++; it1 != TransRelEnd(); it2 = it1++) {
2378  if ((it1->X1 == it2->X1) && (it1->Ev == it2->Ev)) {
2379  FD_DG("IsDeterministic(): at least one state "
2380  << "contains more than on transition with same event: "
2381  << TStr(*it1));
2382  return false;
2383  }
2384  }
2385  // in all other cases generator is deterministic
2386  return true;
2387 }
2388 
2389 
2390 // ReindexOnWrite()
2391 bool vGenerator::ReindexOnWrite(void) const {
2392  return mReindexOnWrite;
2393 }
2394 
2395 // ReindexOnWrite(flag)
2397  mReindexOnWrite = flag;
2398 }
2399 
2400 // ReindexOnWrite(flag)
2402  msReindexOnWriteDefault = flag;
2403 }
2404 
2405 // ReindexOnWrite(flag)
2407  return msReindexOnWriteDefault;
2408 }
2409 
2410 
2411 
2412 // DoWrite()
2413 void vGenerator::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
2414  (void) pContext;
2415  // pre 2.20 behaviour: re-index on file output
2416  /*
2417  if(rTw.FileMode())
2418  SetMinStateIndexMap();
2419  */
2420  // post 2.20 beaviour: re-index by configuration
2421  if(ReindexOnWrite())
2423  // figure section
2424  std::string label=rLabel;
2425  if(label=="") label="Generator";
2426  FD_DG("vGenerator(" << this << ")::DoWrite(): section " << label);
2427  // write generator
2428  Token btag;
2429  btag.SetBegin(label);
2430  if(mMyName!=label) btag.InsAttributeString("name",mMyName);
2431  rTw.Write(btag);
2432  rTw << "\n";
2433  SWrite(rTw);
2434  rTw << "\n";
2435  mpAlphabet->Write(rTw);
2436  rTw << "\n";
2437  WriteStates(rTw);
2438  rTw << "\n";
2439  WriteTransRel(rTw);
2440  rTw << "\n";
2441  WriteStateSet(rTw, mInitStates);
2442  rTw << "\n";
2444  rTw << "\n";
2445  mpGlobalAttribute->Write(rTw);
2446  rTw << "\n";
2447  rTw.WriteEnd(label);
2448  // end of reindex
2450 }
2451 
2452 // DoDWrite()
2453 void vGenerator::DoDWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
2454  (void) pContext;
2455  // figure section
2456  std::string label=rLabel;
2457  if(label=="") label="Generator";
2458  FD_DG("vGenerator(" << this << ")::DoDWrite(): section " << label);
2459  // write generator
2460  rTw.WriteBegin(label);
2461  rTw << mMyName;
2462  rTw << "\n";
2463  rTw << "\n";
2464  SWrite(rTw);
2465  rTw << "\n";
2466  mpAlphabet->DWrite(rTw);
2467  rTw << "\n";
2468  DWriteStateSet(rTw, *mpStates);
2469  rTw << "\n";
2470  DWriteTransRel(rTw);
2471  rTw << "\n";
2473  rTw << "\n";
2475  rTw << "\n";
2476  mpGlobalAttribute->Write(rTw);
2477  rTw << "\n";
2478  rTw.WriteEnd(label);
2479  rTw << "\n";
2480 }
2481 
2482 // DoXWrite()
2483 void vGenerator::DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
2484  (void) pContext;
2485  // Set up outer tag
2486  std::string label=rLabel;
2487  std::string ftype=TypeName();
2488  if(label=="") label="Generator";
2489  Token btag;
2490  btag.SetBegin(label);
2491  if(Name()!=label && Name()!="") btag.InsAttributeString("name",Name());
2492  //2.24e: make ftype mandatory for XML format to allow for more flexible faudes/plain format
2493  //if(ftype!=label && ftype!="") btag.InsAttributeString("ftype",ftype); // pre 2.22e
2494  btag.InsAttributeString("ftype",ftype); // 2.24e
2495  FD_DG("vGenerator(" << this << ")::DoXWrite(..): section " << btag.StringValue() << " #" << Size());
2496  rTw.Write(btag);
2497  // Optional re-indexing
2499  // Write comcponents
2500  rTw << "\n";
2501  mpAlphabet->XWrite(rTw,"Alphabet");
2502  rTw << "\n";
2503  XWriteStateSet(rTw, *mpStates,"StateSet");
2504  rTw << "\n";
2505  XWriteTransRel(rTw);
2506  rTw << "\n";
2507  mpGlobalAttribute->XWrite(rTw);
2509  rTw << "\n";
2510  // Write end
2511  rTw.WriteEnd(btag.StringValue());
2512  // End of re-index
2514 }
2515 
2516 // WriteAlphabet()
2517 void vGenerator::WriteAlphabet(void) const {
2519  WriteAlphabet(tw);
2520 }
2521 
2522 // AlphabetToString()
2523 std::string vGenerator::AlphabetToString(void) const {
2525  WriteAlphabet(tw);
2526  return tw.Str();
2527 }
2528 
2529 // WriteAlphabet(rTw&)
2531  mpAlphabet->Write(rTw);
2532 }
2533 
2534 // WriteStateSet(rStateSet&)
2535 void vGenerator::WriteStateSet(const StateSet& rStateSet) const {
2537  WriteStateSet(tw,rStateSet);
2538 }
2539 
2540 // StateSetToString()
2541 std::string vGenerator::StateSetToString(const StateSet& rStateSet) const {
2543  WriteStateSet(tw,rStateSet);
2544  return tw.Str();
2545 }
2546 
2547 // StateSetToText()
2548 std::string vGenerator::StateSetToText(const StateSet& rStateSet) const {
2550  tw.Endl(true);
2551  WriteStateSet(tw,rStateSet);
2552  return tw.Str();
2553 }
2554 
2555 
2556 // WriteStateSet(rTw&, rStateSet&)
2558  // have my section
2559  rTw.WriteBegin("States");
2560  // test whether we reindex
2561  bool reindex=mMinStateIndexMap.size()>0;
2562  // if we reindex, setup reverse map to write in strategic order
2563  // to allow for consisten read (i.e. states with symbolic name first, starting
2564  // with index 1); this is the plain faudes file format from 2005
2565  if(reindex) {
2566  // reverse map
2567  std::map<Idx,Idx> reversemap;
2568  std::map<Idx,Idx>::const_iterator minit;
2569  StateSet::Iterator sit;
2570  for (sit = StatesBegin(); sit != StatesEnd(); ++sit)
2571  reversemap[MinStateIndex(*sit)] = *sit;
2572  // iterate states to write
2573  for(minit = reversemap.begin(); minit != reversemap.end(); ++minit) {
2574  // identify anonymous block (consecutive state indices)
2575  std::map<Idx,Idx>::const_iterator conit=minit;
2576  Idx start = conit->first;
2577  Idx anoncount = 0;
2578  for(; conit != reversemap.end(); ++conit) {
2579  if(StateName(conit->second) != "") break;
2580  if(!StateAttribute(conit->second).IsDefault()) break;
2581  if(conit->first != start+anoncount) break;
2582  ++anoncount;
2583  }
2584  // write anonymous block
2585  if(anoncount > FD_CONSECUTIVE) {
2586  rTw.WriteBegin("Consecutive");
2587  rTw << start;
2588  rTw << start+anoncount-1;
2589  rTw.WriteEnd("Consecutive");
2590  minit=conit;
2591  }
2592  // break loop
2593  if(minit == reversemap.end()) break;
2594  // write non anonymous state name/idx
2595  std::string statename = StateName(minit->second);
2596  if (statename != "") rTw << statename;
2597  else rTw << minit->first;
2598  // write state attribute
2599  const AttributeVoid& attr=StateAttribute(minit->second);
2600  attr.Write(rTw);
2601  }
2602  }
2603  // if we dont reindex, write symbolic names with index suffix to
2604  // enable a consistent read; this was introduced with libfaudes 2.20j
2605  if(!reindex) {
2606  // iterate states to write
2607  bool symexpl = (States().MaxIndex() != States().Size());
2608  StateSet::Iterator sit;
2609  for(sit = StatesBegin(); sit != StatesEnd(); ++sit) {
2610  // identify anonymous block (consecutive state indices)
2611  StateSet::Iterator conit=sit;
2612  Idx start = *conit;
2613  Idx anoncount = 0;
2614  for(; conit != StatesEnd(); ++conit) {
2615  if(StateName(*conit) != "") break;
2616  if(!StateAttribute(*conit).IsDefault()) break;
2617  if(*conit != start+anoncount) break;
2618  ++anoncount;
2619  }
2620  // write anonymous block
2621  if(anoncount > FD_CONSECUTIVE) {
2622  rTw.WriteBegin("Consecutive");
2623  rTw << start;
2624  rTw << start+anoncount-1;
2625  rTw.WriteEnd("Consecutive");
2626  sit=conit;
2627  }
2628  // break loop
2629  if(sit == StatesEnd()) break;
2630  // write index or name with index suffix
2631  std::string statename = StateName(*sit);
2632  if((statename != "") && symexpl) {
2633  rTw << (statename + "#"+ToStringInteger(*sit)) ;
2634  } else if(statename != "") {
2635  rTw << statename;
2636  } else {
2637  rTw << *sit;
2638  }
2639  // write attribute
2640  const AttributeVoid& attr=StateAttribute(*sit);
2641  attr.Write(rTw);
2642  }
2643  }
2644  // write end tag
2645  rTw.WriteEnd("States");
2646 }
2647 
2648 
2649 // WriteStateSet(rTw&, rStateSet&)
2650 void vGenerator::WriteStateSet(TokenWriter& rTw, const StateSet& rStateSet) const {
2651  rTw.WriteBegin(rStateSet.Name());
2652  // test whether we reindex
2653  bool reindex=mMinStateIndexMap.size()>0;
2654  // if we reindex, setup reverse map to write in strategic order;
2655  // reading back is no issue for external states, however, we would like
2656  // to provoke large consecutive blocks as a benefit from re-indexing
2657  if(reindex) {
2658  // reverse map
2659  std::map<Idx,Idx> reversemap;
2660  std::map<Idx,Idx>::const_iterator minit;
2661  StateSet::Iterator sit;
2662  for (sit = rStateSet.Begin(); sit != rStateSet.End(); ++sit)
2663  reversemap[MinStateIndex(*sit)] = *sit;
2664  // iterate states to write
2665  for(minit = reversemap.begin(); minit != reversemap.end(); ++minit) {
2666  // identify anonymous block (consecutive state indices)
2667  std::map<Idx,Idx>::const_iterator conit=minit;
2668  Idx start = conit->first;
2669  Idx anoncount = 0;
2670  for(; conit != reversemap.end(); ++conit) {
2671  if(StateName(conit->second) != "") break;
2672  if(!StateAttribute(conit->second).IsDefault()) break;
2673  if(conit->first != start+anoncount) break;
2674  ++anoncount;
2675  }
2676  // write anonymous block
2677  if(anoncount > FD_CONSECUTIVE) {
2678  rTw.WriteBegin("Consecutive");
2679  rTw << start;
2680  rTw << start+anoncount-1;
2681  rTw.WriteEnd("Consecutive");
2682  minit=conit;
2683  }
2684  // break loop
2685  if(minit == reversemap.end()) break;
2686  // write non anonymous state name/idx
2687  std::string statename = StateName(minit->second);
2688  if (statename != "") rTw << statename;
2689  else rTw << minit->first;
2690  // write state attribute
2691  const AttributeVoid& attr=rStateSet.Attribute(minit->second);
2692  attr.Write(rTw);
2693  }
2694  }
2695  // if we dont reindex, we dont need the reverse map; note that
2696  // external stateset will never have an explicit symbol table
2697  if(!reindex) {
2698  // iterate states to write
2699  StateSet::Iterator sit;
2700  for(sit = rStateSet.Begin(); sit != rStateSet.End(); ++sit) {
2701  // identify anonymous block (consecutive state indices)
2702  StateSet::Iterator conit=sit;
2703  Idx start = *conit;
2704  Idx anoncount = 0;
2705  for(; conit != rStateSet.End(); ++conit) {
2706  if(StateName(*conit) != "") break;
2707  if(!StateAttribute(*conit).IsDefault()) break;
2708  if(*conit != start+anoncount) break;
2709  ++anoncount;
2710  }
2711  // write anonymous block
2712  if(anoncount > FD_CONSECUTIVE) {
2713  rTw.WriteBegin("Consecutive");
2714  rTw << start;
2715  rTw << start+anoncount-1;
2716  rTw.WriteEnd("Consecutive");
2717  sit=conit;
2718  }
2719  // break loop
2720  if(sit == rStateSet.End()) break;
2721  // write non anonymous state name/idx
2722  std::string statename = StateName(*sit);
2723  if (statename != "") rTw << statename;
2724  else rTw << *sit;
2725  // write attribute
2726  const AttributeVoid& attr=rStateSet.Attribute(*sit);
2727  attr.Write(rTw);
2728  }
2729  }
2730  // write end tag
2731  rTw.WriteEnd(rStateSet.Name());
2732 }
2733 
2734 
2735 // DWriteStateSet(rTw&, rStateSet&)
2736 void vGenerator::DWriteStateSet(TokenWriter& rTw, const StateSet& rStateSet) const {
2737  rTw.WriteBegin(rStateSet.Name());
2738  StateSet::Iterator sit;
2739  for(sit = rStateSet.Begin(); sit != rStateSet.End(); ++sit) {
2740  rTw << SStr(*sit);
2741  const AttributeVoid& attr=rStateSet.Attribute(*sit);
2742  attr.Write(rTw);
2743  }
2744  rTw.WriteEnd(rStateSet.Name());
2745 }
2746 
2747 
2748 // XWriteStateSet(rTw&, rStateSet&)
2749 void vGenerator::XWriteStateSet(TokenWriter& rTw, const StateSet& rStateSet, const std::string& rLabel) const {
2750  // figure label
2751  std::string label=rLabel;
2752  if(label=="") label=rStateSet.Name();
2753  if(label=="") label="StateSet";
2754  rTw.WriteBegin(label);
2755  // build reverse index map of states to write ( fileidx->idx )
2756  // -- this ensures named states to be written first; see SetMinStateIndexMap()
2757  // -- this is required to figure consecutive blocks
2758  std::map<Idx,Idx> reversemap;
2759  std::map<Idx,Idx>::const_iterator minit;
2760  StateSet::Iterator sit;
2761  for (sit = rStateSet.Begin(); sit != rStateSet.End(); ++sit) {
2762  reversemap[MinStateIndex(*sit)] = *sit;
2763  }
2764  // iterate states to write
2765  for(minit = reversemap.begin(); minit != reversemap.end(); ++minit) {
2766  // identify anonymous block (consecutive state indices, no names, no attributes)
2767  std::map<Idx,Idx>::const_iterator conit=minit;
2768  Idx start = conit->first;
2769  Idx anoncount = 0;
2770  for(; conit != reversemap.end(); ++conit) {
2771  if(StateName(conit->second) != "") break;
2772  if(!StateAttribute(conit->second).IsDefault()) break;
2773  if(ExistsInitState(conit->second)) break;
2774  if(ExistsMarkedState(conit->second)) break;
2775  if(conit->first != start+anoncount) break;
2776  ++anoncount;
2777  }
2778  // write anonymous block
2779  if(anoncount > FD_CONSECUTIVE) {
2780  Token contag;
2781  contag.SetEmpty("Consecutive");
2782  contag.InsAttributeInteger("from",start);
2783  contag.InsAttributeInteger("to",start+anoncount-1);
2784  rTw.Write(contag);
2785  minit=conit;
2786  }
2787  // break loop
2788  if(minit == reversemap.end() )
2789  break;
2790  // prepare state token
2791  Token sttag;
2792  std::string statename = StateName(minit->second);
2793  Idx index=minit->first;
2794  sttag.SetBegin("State");
2795  sttag.InsAttributeInteger("id",index);
2796  if(statename!="")
2797  if(&rStateSet==mpStates)
2798  sttag.InsAttributeString("name",statename);
2799  rTw.Write(sttag);
2800  // marking
2801  if(ExistsInitState(minit->second)) { sttag.SetEmpty("Initial"); rTw.Write(sttag);};
2802  if(ExistsMarkedState(minit->second)) { sttag.SetEmpty("Marked"); rTw.Write(sttag);};
2803  // attribute
2804  const AttributeVoid& attr=rStateSet.Attribute(minit->second);
2805  if(!attr.IsDefault()) attr.XWrite(rTw);
2806  // done
2807  rTw.WriteEnd("State");
2808  }
2809  rTw.WriteEnd(label);
2810 }
2811 
2812 
2813 // StatesToString()
2814 std::string vGenerator::StatesToString(void) const {
2815  return StateSetToString(*mpStates);
2816 }
2817 
2818 // StatesToText()
2819 std::string vGenerator::StatesToText(void) const {
2820  return StateSetToText(*mpStates);
2821 }
2822 
2823 // MarkedStatesToString()
2824 std::string vGenerator::MarkedStatesToString(void) const {
2826 }
2827 
2828 // InitStatesToString()
2829 std::string vGenerator::InitStatesToString(void) const {
2830  return StateSetToString(mInitStates);
2831 }
2832 
2833 
2834 // WriteTransRel()
2835 void vGenerator::WriteTransRel(void) const {
2837  WriteTransRel(tw);
2838 }
2839 
2840 // TransRelToString()
2841 std::string vGenerator::TransRelToString(void) const {
2843  WriteTransRel(tw);
2844  return tw.Str();
2845 }
2846 
2847 // TransRelToText()
2848 std::string vGenerator::TransRelToText(void) const {
2850  tw.Endl(true);
2851  WriteTransRel(tw);
2852  return tw.Str();
2853 }
2854 
2855 // WriteTransRel(rTw&)
2857  TransSet::Iterator tit;
2858  int oldcolumns = rTw.Columns();
2859  rTw.Columns(3);
2860  rTw.WriteBegin("TransRel");
2861  bool smalltransrel = (Size() < FD_SMALLTRANSREL);
2862 
2863  // loop all transitions
2864  for(tit = mpTransRel->Begin(); tit != mpTransRel->End(); ++tit) {
2865 
2866  // write x1
2867  Idx x1=MinStateIndex(tit->X1);
2868  if (smalltransrel) {
2869  std::string x1name = StateName(tit->X1);
2870  if (x1name != "") {
2871  rTw << x1name;
2872  } else {
2873  rTw << x1;
2874  }
2875  } else {
2876  rTw << x1;
2877  }
2878 
2879  // write ev
2880  rTw << EventName(tit->Ev);
2881 
2882  // write x2
2883  Idx x2=MinStateIndex(tit->X2);
2884  if (smalltransrel) {
2885  std::string x2name = StateName(tit->X2);
2886  if (x2name != "") {
2887  rTw << x2name;
2888  } else {
2889  rTw << x2;
2890  }
2891  } else {
2892  rTw << x2;
2893  }
2894 
2895  // write attributes
2896  TransAttribute(*tit).Write(rTw);
2897 
2898  }
2899  rTw.WriteEnd("TransRel");
2900  rTw.Columns(oldcolumns);
2901 }
2902 
2903 // DWriteTransRel(rTw&)
2905  TransSet::Iterator tit;
2906  int oldcolumns = rTw.Columns();
2907  rTw.Columns(3);
2908  rTw.WriteBegin("TransRel");
2909  // iterate all transitions
2910  for (tit = mpTransRel->Begin(); tit != mpTransRel->End(); ++tit) {
2911  // write x1
2912  std::ostringstream ox1;
2913  Idx x1= tit->X1;
2914  std::string x1name = StateName(x1);
2915  if (x1name != "") {
2916  ox1 << x1name << "[" << x1 << "]";
2917  } else {
2918  ox1 << x1;
2919  }
2920  rTw << ox1.str();
2921  // write ev
2922  std::ostringstream oev;
2923  Idx ev= tit->Ev;
2924  std::string evname = EventName(ev);
2925  oev << evname << "[" << ev << "]";
2926  rTw << oev.str();
2927  // write x2
2928  std::ostringstream ox2;
2929  Idx x2= tit->X2;
2930  std::string x2name = StateName(x2);
2931  if (x2name != "") {
2932  ox2 << x2name << "[" << x2 << "]";
2933  } else {
2934  ox2 << x2;
2935  }
2936  rTw << ox2.str();
2937  // attribute
2938  mpTransRel->Attribute(*tit).Write(rTw);
2939  }
2940  rTw.WriteEnd("TransRel");
2941  rTw.Columns(oldcolumns);
2942 }
2943 
2944 
2945 // XWriteTransRel(rTw&)
2947  TransSet::Iterator tit;
2948  rTw.WriteBegin("TransitionRelation");
2949 
2950  // loop all transitions
2951  for(tit = mpTransRel->Begin(); tit != mpTransRel->End(); ++tit) {
2952 
2953  // retrieve values x1
2954  Idx x1=MinStateIndex(tit->X1);
2955  Idx x2=MinStateIndex(tit->X2);
2956  std::string ev=EventName(tit->Ev);
2957 
2958  // prepare tag
2959  Token trtag;
2960  trtag.SetEmpty("Transition");
2961  trtag.InsAttributeInteger("x1",x1);
2962  trtag.InsAttributeString("event",ev);
2963  trtag.InsAttributeInteger("x2",x2);
2964 
2965  // consider attribute
2966  const AttributeVoid& attr=TransAttribute(*tit);
2967  // case a: indeed no attribute value
2968  if(attr.IsDefault()) {
2969  rTw.Write(trtag);
2970  }
2971  // calse b: with attribute
2972  else {
2973  trtag.ClrEnd();
2974  rTw.Write(trtag);
2975  attr.XWrite(rTw);
2976  rTw.WriteEnd(trtag.StringValue());
2977  }
2978 
2979  }
2980  rTw.WriteEnd("TransitionRelation");
2981 }
2982 
2983 // DoSWrite(rTw&)
2985 {
2986  Type::DoSWrite(rTw);
2987  rTw.WriteComment(" States: " + ToStringInteger(Size()) );
2988  rTw.WriteComment(" Init/Marked: " + ToStringInteger(mInitStates.Size())
2989  + "/" + ToStringInteger(mMarkedStates.Size()));
2990  rTw.WriteComment(" Events: " + ToStringInteger(mpAlphabet->Size()) );
2991  rTw.WriteComment(" Transitions: " + ToStringInteger(mpTransRel->Size()) );
2992  rTw.WriteComment(" StateSymbols: " + ToStringInteger(mpStateSymbolTable->Size()) );
2993  rTw.WriteComment(" Attrib. E/S/T: " + ToStringInteger(mpAlphabet->AttributesSize())
2996  rTw.WriteComment("");
2997 }
2998 
2999 // DotWrite(rFileName)
3000 void vGenerator::DotWrite(const std::string& rFileName) const {
3001  FD_DG("vGenerator(" << this << ")::DotWrite(" << rFileName << ")");
3002  if(ReindexOnWrite())
3004  StateSet::Iterator lit;
3005  TransSet::Iterator tit;
3006  try {
3007  std::ofstream stream;
3008  stream.exceptions(std::ios::badbit|std::ios::failbit);
3009  stream.open(rFileName.c_str());
3010  stream << "// dot output generated by libFAUDES vGenerator" << std::endl;
3011  stream << "digraph \"" << Name() << "\" {" << std::endl;
3012  stream << " rankdir=LR" << std::endl;
3013  stream << " node [shape=circle];" << std::endl;
3014  stream << std::endl;
3015  stream << " // initial states" << std::endl;
3016  int i = 1;
3017  for (lit = InitStatesBegin(); lit != InitStatesEnd(); ++lit) {
3018  std::string xname= StateName(*lit);
3019  if(xname=="") xname=ToStringInteger(MinStateIndex(*lit));
3020  stream << " dot_dummyinit_" << i << " [shape=none, label=\"\", width=\"0.0\", height=\"0.0\" ];" << std::endl;
3021  stream << " dot_dummyinit_" << i << " -> \"" << xname << "\";" << std::endl;
3022  i++;
3023  }
3024  stream << std::endl;
3025  stream << " // mstates" << std::endl;
3026  for (lit = MarkedStatesBegin(); lit != MarkedStatesEnd(); ++lit) {
3027  std::string xname= StateName(*lit);
3028  if(xname=="") xname=ToStringInteger(MinStateIndex(*lit));
3029  stream << " \"" << xname << "\" [shape=doublecircle];" << std::endl;
3030  }
3031  stream << std::endl;
3032  stream << " // rest of stateset" << std::endl;
3033  for (lit = StatesBegin(); lit != StatesEnd(); ++lit) {
3034  if (! (ExistsInitState(*lit) || ExistsMarkedState(*lit)) ) {
3035  std::string xname= StateName(*lit);
3036  if(xname=="") xname=ToStringInteger(MinStateIndex(*lit));
3037  stream << " \"" << xname << "\";" << std::endl;
3038  }
3039  }
3040  stream << std::endl;
3041  stream << " // transition relation" << std::endl;
3042  for(tit = TransRelBegin(); tit != TransRelEnd(); ++tit) {
3043  std::string x1name= StateName(tit->X1);
3044  if(x1name=="") x1name=ToStringInteger(MinStateIndex(tit->X1));
3045  std::string x2name= StateName(tit->X2);
3046  if(x2name=="") x2name=ToStringInteger(MinStateIndex(tit->X2));
3047  stream << " \"" << x1name << "\" -> \"" << x2name
3048  << "\" [label=\"" << EventName(tit->Ev) << "\"];" << std::endl;
3049  }
3050  stream << "}" << std::endl;
3051  stream.close();
3052  }
3053  catch (std::ios::failure&) {
3054  throw Exception("vGenerator::DotWrite",
3055  "Exception opening/writing dotfile \""+rFileName+"\"", 2);
3056  }
3058 }
3059 
3060 // DDotWrite(rFileName)
3061 void vGenerator::DDotWrite(const std::string& rFileName) const {
3062  FD_DG("vGenerator(" << this << ")::DDotWrite(" << rFileName << ")");
3063  StateSet::Iterator lit;
3064  TransSet::Iterator tit;
3065  try {
3066  std::ofstream stream;
3067  stream.exceptions(std::ios::badbit|std::ios::failbit);
3068  stream.open(rFileName.c_str());
3069  stream << "digraph \"" << Name() << "\" {" << std::endl;
3070  stream << " rankdir=LR" << std::endl;
3071  stream << " node [shape=circle];" << std::endl;
3072  stream << std::endl;
3073  stream << " // istates" << std::endl;
3074  int i = 1;
3075  for (lit = InitStatesBegin(); lit != InitStatesEnd(); ++lit) {
3076  stream << " dot_dummyinit_" << i << " [shape=none, label=\"\" ];" << std::endl;
3077  stream << " dot_dummyinit_" << i << " -> \""
3078  << SStr(*lit) << "\";" << std::endl;
3079  i++;
3080  }
3081  stream << std::endl;
3082  stream << " // mstates" << std::endl;
3083  for (lit = MarkedStatesBegin(); lit != MarkedStatesEnd(); ++lit) {
3084  stream << " \"" << SStr(*lit) << "\" [shape=doublecircle];" << std::endl;
3085  }
3086  stream << std::endl;
3087  stream << " // rest of stateset" << std::endl;
3088  for (lit = StatesBegin(); lit != StatesEnd(); ++lit) {
3089  // if not in mInitStates or mMarkedStates
3090  if (! (ExistsInitState(*lit) || ExistsMarkedState(*lit)) ) {
3091  stream << " \"" << SStr(*lit) << "\";" << std::endl;
3092  }
3093  }
3094  stream << std::endl;
3095  stream << " // transition relation" << std::endl;
3096  for (tit = TransRelBegin(); tit != TransRelEnd(); ++tit) {
3097  stream << " \"" << SStr(tit->X1)
3098  << "\" -> \"" << SStr(tit->X2)
3099  << "\" [label=\"" << EventName(tit->Ev) << "\"];" << std::endl;
3100  }
3101  stream << "}" << std::endl;
3102  stream.close();
3103  }
3104  catch (std::ios::failure&) {
3105  throw Exception("vGenerator::DDotWrite",
3106  "Exception opening/writing dotfile \""+rFileName+"\"", 2);
3107  }
3108 }
3109 
3110 
3111 // XDotWrite(rFileName)
3112 void vGenerator::XDotWrite(const std::string& rFileName) const {
3113  FD_DG("vGenerator(" << this << ")::XDotWrite(" << rFileName << ")");
3114  StateSet::Iterator lit;
3115  TransSet::Iterator tit;
3116  try {
3117  std::ofstream stream;
3118  stream.exceptions(std::ios::badbit|std::ios::failbit);
3119  stream.open(rFileName.c_str());
3120  stream << "digraph \"___" << Name() << "___\" {" << std::endl;
3121  stream << " rankdir=LR" << std::endl;
3122  stream << " node [shape=circle];" << std::endl;
3123  stream << std::endl;
3124  stream << " // stateset" << std::endl;
3125  for (lit = InitStatesBegin(); lit != InitStatesEnd(); ++lit) {
3126  stream << " \"s" << *lit << "\";" << std::endl;
3127  }
3128  for (lit = MarkedStatesBegin(); lit != MarkedStatesEnd(); ++lit) {
3129  stream << " \"s" << *lit << "\";" << std::endl;
3130  }
3131  for (lit = StatesBegin(); lit != StatesEnd(); ++lit) {
3132  if(ExistsInitState(*lit)) continue;
3133  if(ExistsMarkedState(*lit)) continue;
3134  stream << " \"s" << *lit << "\";" << std::endl;
3135  }
3136  stream << std::endl;
3137  stream << " // transition relation" << std::endl;
3138  for (tit = TransRelBegin(); tit != TransRelEnd(); ++tit) {
3139  stream << " \"s" << tit->X1
3140  << "\" -> \"s" << tit->X2
3141  << "\" [label=\"e" << tit->Ev << "\" " << "polyline" << "];" << std::endl;
3142  }
3143  stream << "}" << std::endl;
3144  stream.close();
3145  }
3146  catch (std::ios::failure&) {
3147  throw Exception("vGenerator::XDotWrite",
3148  "Exception opening/writing dotfile \""+rFileName+"\"", 2);
3149  }
3150 }
3151 
3152 // DoRead(tr)
3153 void vGenerator::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
3154  (void) pContext;
3155  std::string label=rLabel;
3156  if(label=="") label="Generator";
3157  FD_DG("vGenerator(" << this << ")::DoRead(): file " << rTr.FileName() << " section " << label);
3158  // clear old stuff
3159  Clear();
3160  // find Generator tag
3161  Token btag;
3162  rTr.ReadBegin(label, btag);
3163  int seclev=rTr.Level();
3164  // hypothesis: format is either "relaxed native 2.24e" or "xml"
3165  bool native=true;
3166  bool xml= true;
3167  // the ftype attribute is mandatory to indicate xml format (as of 2.24e)
3168  if(btag.ExistsAttributeString("ftype")) { native=false;}
3169  // try name by relaxed native 2.24e
3170  if(native) {
3171  // get name (optional)
3172  std::string name="generator";
3173  // figure name: as attribute
3174  if(btag.ExistsAttributeString("name"))
3175  name=btag.AttributeStringValue("name");
3176  // firgure name: as string token
3177  Token token;
3178  rTr.Peek(token);
3179  if(token.IsString()) { name=rTr.ReadString(); xml=false; }
3180  Name(name);
3181  }
3182  // try core sets by relaxed native 2.24e
3183  if(native) {
3184  // read alphabet (optional)
3185  ReadAlphabet(rTr);
3186  // read stateset (optional)
3187  ReadStates(rTr);
3188  // read transrel (required --- if not present, we might have mis-sensed pre 2.24e xml)
3189  Token token;
3190  rTr.Peek(token);
3191  if(token.IsBegin("TransRel") || token.IsBegin("T")) {
3192  ReadTransRel(rTr);
3193  } else {
3194  native=false;
3195  rTr.Reset(seclev);
3196  Clear();
3197  }
3198  }
3199  // try extra sets by relaxed native 2.24e
3200  if(native) {
3201  // read istates (optional)
3202  Token token;
3203  rTr.Peek(token);
3204  if(token.IsBegin("InitStates"))
3205  {ReadStateSet(rTr, "InitStates", mInitStates); xml=false;}
3206  if(token.IsBegin("I"))
3207  {ReadStateSet(rTr, "I", mInitStates); xml=false;}
3208  // read mstates (optional)
3209  rTr.Peek(token);
3210  if(token.IsBegin("MarkedStates"))
3211  {ReadStateSet(rTr, "MarkedStates", mMarkedStates); xml=false;}
3212  if(token.IsBegin("M"))
3213  {ReadStateSet(rTr, "M", mMarkedStates); xml=false;}
3214  // read attribute
3215  mpGlobalAttribute->Read(rTr);
3216  }
3217  // if we survived, its not xml
3218  if(native) xml=false;
3219  // read strict xml format
3220  if(xml) {
3221  // figure generator name
3222  std::string name="generator";
3223  if(btag.ExistsAttributeString("name"))
3224  name=btag.AttributeStringValue("name");
3225  Name(name);
3226  // read alphabet
3227  mpAlphabet->Read(rTr,"Alphabet");
3228  // read state set, incl. init/marked attribute
3229  XReadStateSet(rTr, *mpStates, "StateSet");
3230  mpStates->Name("States");
3231  // read trans rel
3232  XReadTransRel(rTr);
3233  // read attribute
3234  mpGlobalAttribute->Read(rTr);
3235  // fix labels
3236  mInitStates.Name("InitStates");
3237  mMarkedStates.Name("MarkedStates");
3238  }
3239  // read end
3240  rTr.ReadEnd(label);
3241  FD_DG("vGenerator(" << this << ")::DoRead(): done");
3242 }
3243 
3244 // ReadAlphabet(rTr)
3246  FD_DG("vGenerator(" << this << ")::ReadAlphabet(\""
3247  << rTr.FileName() << "\")");
3248  Token token;
3249  rTr.Peek(token);
3250  if(token.IsBegin("Alphabet"))
3251  mpAlphabet->Read(rTr,"Alphabet");
3252  if(token.IsBegin("A"))
3253  mpAlphabet->Read(rTr,"A");
3254 }
3255 
3256 // ReadStates(tr)
3258  FD_DG("vGenerator(" << this << ")::ReadStates(\"" << rTr.FileName() << "\")");
3259  // HELPERS:
3260  Token token;
3261  std::string label="";
3262  rTr.Peek(token);
3263  if(token.IsBegin("States")) label=token.StringValue();
3264  if(token.IsBegin("S")) label=token.StringValue();
3265  if(label=="") return;
3266  AttributeVoid* attrp = mpStates->AttributeType()->New();
3267  FD_DG("vGenerator(" << this << ")::ReadStates(..): attribute type " << typeid(*attrp).name());
3268  // ALGORITHM:
3269  mpStates->Clear();
3270  mpStates->Name("States");
3272  // track occurence of explicit symboltable
3273  bool symimpl=false;
3274  bool symexpl=false;
3275  Idx symnext=1;
3276  // loop section
3277  rTr.ReadBegin(label);
3278  while(!rTr.Eos(label)) {
3279  // peek
3280  rTr.Peek(token);
3281  // read state by index
3282  if(token.IsInteger()) {
3283  rTr.Get(token);
3284  Idx index = token.IntegerValue();
3285  FD_DG("vGenerator(" << this << ")::ReadStates(\"" << rTr.FileName() << "\"): by index " << index);
3286  if(mpStates->Exists(index)) {
3287  delete attrp;
3288  std::stringstream errstr;
3289  errstr << "Token " << token.IntegerValue() << " appears twice in stateset"
3290  << rTr.FileLine();
3291  throw Exception("vGenerator::ReadStates", errstr.str(), 80);
3292  }
3293  // read attribute
3294  attrp->Read(rTr,"",this);
3295  // skip unknown attributes
3296  AttributeVoid::Skip(rTr);
3297  // insert element with attribute
3298  InsState(index);
3299  StateAttribute(index,*attrp);
3300  symnext++;
3301  continue;
3302  }
3303  // read state by name
3304  if(token.IsString()) {
3305  rTr.Get(token);
3306  FD_DG("vGenerator(" << this << ")::ReadStates(\"" << rTr.FileName() << "\"): by name " << token.StringValue());
3307  // interpret name, sense index suffx if present
3308  std::string statename=token.StringValue();
3309  Idx index=symnext;
3310  std::size_t pos= statename.find_first_of('#');
3311  if(pos==std::string::npos) symimpl=true;
3312  if(pos!=std::string::npos) symexpl=true;
3313  if(pos!=std::string::npos && pos < statename.size()-1) {
3314  std::string suffix=statename.substr(pos+1);
3315  index=ToIdx(suffix);
3316  statename=statename.substr(0,pos);
3317  FD_DG("vGenerator(" << this << ")::ReadStates(\"" << rTr.FileName() << "\"): extracted suffix from " << token.StringValue() << ": " << statename << " idx " << index);
3318  }
3319  // no doublets
3320  if(ExistsState(statename) || ExistsState(index)) {
3321  delete attrp;
3322  std::stringstream errstr;
3323  errstr << "State " << statename << "(idx " << index <<") appears twice in stateset"
3324  << rTr.FileLine();
3325  throw Exception("vGenerator::ReadStates", errstr.str(), 80);
3326  }
3327  // read attribute
3328  attrp->Read(rTr,"",this);
3329  // skip unknown attributes
3330  AttributeVoid::Skip(rTr);
3331  // insert element with attribute
3332  InsState(index);
3333  StateName(index,statename);
3334  StateAttribute(index,*attrp);
3335  symnext++;
3336  continue;
3337  }
3338  // read consecutive block of anonymous states
3339  if(token.IsBegin("Consecutive")) {
3340  rTr.ReadBegin("Consecutive");
3341  Token token1,token2;
3342  rTr.Get(token1);
3343  rTr.Get(token2);
3344  FD_DG("vGenerator(" << this << ")::ReadStates(\"" << rTr.FileName() << "\"): consecutive range");
3345  if ((!token1.IsInteger()) || (!token2.IsInteger())) {
3346  delete attrp;
3347  std::stringstream errstr;
3348  errstr << "Invalid range of consecutive states" << rTr.FileLine();
3349  throw Exception("vGenerator::ReadStates", errstr.str(), 80);
3350  }
3351  for(Idx index = (Idx) token1.IntegerValue(); index <= (Idx) token2.IntegerValue(); ++index) {
3352  if(mpStates->Exists(index)) {
3353  delete attrp;
3354  std::stringstream errstr;
3355  errstr << "Index " << index << " appears twice in stateset"
3356  << rTr.FileLine();
3357  throw Exception("vGenerator::ReadStates", errstr.str(), 80);
3358  }
3359  InsState(index);
3360  symnext++;
3361  }
3362  rTr.ReadEnd("Consecutive");
3363  continue;
3364  }
3365  // cannot process token
3366  delete attrp;
3367  std::stringstream errstr;
3368  errstr << "Invalid token" << rTr.FileLine();
3369  throw Exception("vGenerator::ReadStates", errstr.str(), 80);
3370  }
3371  rTr.ReadEnd(label);
3372  // test consistent explicit symboltable
3373  if(symimpl && symexpl) {
3374  delete attrp;
3375  std::stringstream errstr;
3376  errstr << "StateSet with inconsitent explicit symboltable" << rTr.FileLine();
3377  throw Exception("vGenerator::ReadStates", errstr.str(), 80);
3378  }
3379  // dispose attribute
3380  delete attrp;
3381  FD_DG("vGenerator(" << this << ")::ReadStates(\"" << rTr.FileName() << "\"): done");
3382 }
3383 
3384 
3385 // ReadStateSet(tr, rLabel, rStateSet)
3386 void vGenerator::ReadStateSet(TokenReader& rTr, const std::string& rLabel, StateSet& rStateSet) const {
3387  FD_DG("vGenerator(" << this << ")::ReadStateSet(\"" << rLabel<< "\")");
3388  // HELPERS:
3389  Token token;
3390  AttributeVoid* attrp = rStateSet.AttributeType()->New();
3391  FD_DG("vGenerator(" << this << ")::ReadStateSet(..): attribute type " << typeid(*attrp).name());
3392  // ALGORITHM:
3393  rStateSet.Clear();
3394  rTr.ReadBegin(rLabel);
3395  rStateSet.Name(rLabel);
3396  // loop section
3397  while(!rTr.Eos(rLabel)) {
3398  // peek
3399  rTr.Peek(token);
3400  // read state by index
3401  if(token.IsInteger()) {
3402  rTr.Get(token);
3403  Idx index = token.IntegerValue();
3404  if(!ExistsState(index)) {
3405  delete attrp;
3406  std::stringstream errstr;
3407  errstr << "Token " << token.IntegerValue() << " not in stateset"
3408  << rTr.FileLine();
3409  throw Exception("vGenerator::ReadStateSet", errstr.str(), 80);
3410  }
3411  // read attribute
3412  attrp->Read(rTr,"",this);
3413  // skip unknown attributes
3414  AttributeVoid::Skip(rTr);
3415  // insert element with attribute
3416  rStateSet.Insert(index);
3417  rStateSet.Attribute(index,*attrp);
3418  continue;
3419  }
3420  // read state by name
3421  if(token.IsString()) {
3422  rTr.Get(token);
3423  // test validity of symbolic name (no suffixes allowed here ... simply ignore)
3424  std::string statename=token.StringValue();
3425  std::size_t pos= statename.find_first_of('#');
3426  if(pos!=std::string::npos) {
3427  delete attrp;
3428  std::stringstream errstr;
3429  errstr << "invalid symbolic name: " << token.StringValue()
3430  << " (no suffix allowed in external state sets)" << rTr.FileLine();
3431  throw Exception("vGenerator::ReadStateSet", errstr.str(), 80);
3432  }
3433  Idx index =StateIndex(statename);
3434  if(index==0) {
3435  delete attrp;
3436  std::stringstream errstr;
3437  errstr << "Symbolic name " << token.StringValue() << " not in stateset"
3438  << rTr.FileLine();
3439  throw Exception("vGenerator::ReadStateSet", errstr.str(), 80);
3440  }
3441  // read attribute
3442  attrp->Read(rTr,"",this);
3443  // skip unknown attributes
3444  AttributeVoid::Skip(rTr);
3445  // insert element with attribute
3446  rStateSet.Insert(index);
3447  rStateSet.Attribute(index,*attrp);
3448  continue;
3449  }
3450  // read consecutve block of anonymous states
3451  if(token.IsBegin() && token.StringValue() == "Consecutive") {
3452  rTr.ReadBegin("Consecutive");
3453  Token token1,token2;
3454  rTr.Get(token1);
3455  rTr.Get(token2);
3456  if(!token1.IsInteger() || !token2.IsInteger()) {
3457  delete attrp;
3458  std::stringstream errstr;
3459  errstr << "Invalid range of consecutive states" << rTr.FileLine();
3460  throw Exception("vGenerator::ReadStateSet", errstr.str(), 80);
3461  }
3462  for(Idx index = (Idx) token1.IntegerValue(); index <= (Idx) token2.IntegerValue(); ++index) {
3463  if(!ExistsState(index)) {
3464  std::stringstream errstr;
3465  errstr << "Token " << token.IntegerValue() << " not in stateset"
3466  << rTr.FileLine();
3467  throw Exception("vGenerator::ReadStateSet", errstr.str(), 80);
3468  }
3469  rStateSet.Insert(index);
3470  }
3471  rTr.ReadEnd("Consecutive");
3472  continue;
3473  }
3474  // cannot process token
3475  delete attrp;
3476  std::stringstream errstr;
3477  errstr << "Invalid token" << rTr.FileLine();
3478  throw Exception("vGenerator::ReadStateSet", errstr.str(), 50);
3479  }
3480  rTr.ReadEnd(rLabel);
3481  // dispose attribute
3482  delete attrp;
3483 }
3484 
3485 // XReadStateSet(tr, rLabel, rStateSet)
3486 void vGenerator::XReadStateSet(TokenReader& rTr, StateSet& rStateSet, const std::string& rLabel) const {
3487  FD_DG("vGenerator(" << this << ")::XReadStateSet(\"" << rLabel<< "\")");
3488  AttributeVoid* attrp = rStateSet.AttributeType()->New();
3489  FD_DG("vGenerator(" << this << ")::ReadStateSet(..): attribute type " << typeid(*attrp).name());
3490  // Clear my set
3491  rStateSet.Clear();
3492  // Figure section
3493  std::string label=rLabel;
3494  if(label=="") label=rStateSet.Name();
3495  if(label=="") label="StateSet";
3496  // Read begin
3497  Token btag;
3498  rTr.ReadBegin(label,btag);
3499  // Use name if provided (std is no name)
3500  rStateSet.Name("");
3501  if(btag.ExistsAttributeString("name"))
3502  rStateSet.Name(btag.AttributeStringValue("name"));
3503  // Scan my section
3504  while(!rTr.Eos(label)) {
3505  Token sttag;
3506  rTr.Get(sttag);
3507  // Read consecutive block of anonymous states
3508  if(sttag.IsBegin("Consecutive")) {
3509  // Get range
3510  Idx idx1=0;
3511  Idx idx2=0;
3512  if(sttag.ExistsAttributeInteger("from"))
3513  idx1= (Idx) sttag.AttributeIntegerValue("from");
3514  if(sttag.ExistsAttributeInteger("to"))
3515  idx2= (Idx) sttag.AttributeIntegerValue("to");
3516  // Insist in valid range
3517  if(idx1==0 || idx2 < idx1) {
3518  delete attrp;
3519  std::stringstream errstr;
3520  errstr << "Invalid range of consecutive states" << rTr.FileLine();
3521  throw Exception("vGenerator::XReadStates", errstr.str(), 80);
3522  }
3523  FD_DG("vGenerator(" << this << ")::XReadStates(\"" << rTr.FileName() << "\"): consecutive range " << idx1 << " to " << idx2);
3524  for(Idx index = idx1; index <= idx2; ++index) {
3525  if(rStateSet.Exists(index)) {
3526  delete attrp;
3527  std::stringstream errstr;
3528  errstr << "Doublet state index " << index << " " << rTr.FileLine();
3529  throw Exception("vGenerator::XReadStates", errstr.str(), 80);
3530  }
3531  rStateSet.Insert(index);
3532  }
3533  // Done: consecutive
3534  rTr.ReadEnd("Consecutive");
3535  continue;
3536  }
3537  // Ignore other sections
3538  if(!sttag.IsBegin("State")) {
3539  if(sttag.IsBegin())
3540  rTr.ReadEnd(sttag.StringValue());
3541  continue;
3542  }
3543  // Its a state
3544  std::string name="";
3545  if(sttag.ExistsAttributeString("name"))
3546  name=sttag.AttributeStringValue("name");
3547  Idx index=0;
3548  if(sttag.ExistsAttributeInteger("id"))
3549  index=sttag.AttributeIntegerValue("id");
3550  FD_DG("vGenerator::XReadStateSet(): got idx " << index << " " << name);
3551  // reconstruct index from name if possible
3552  if(index==0) {
3553  index=StateIndex(name);
3554  }
3555  // failed to figure index
3556  if(index==0) {
3557  delete attrp;
3558  std::stringstream errstr;
3559  errstr << "Cannot figure index for state token " << sttag.Str() << rTr.FileLine();
3560  throw Exception("vGenerator::XReadStateSet", errstr.str(), 80);
3561  }
3562  // dont allow doublets
3563  if(rStateSet.Exists(index)) {
3564  delete attrp;
3565  std::stringstream errstr;
3566  errstr << "Doublet state from token " << sttag.Str() << rTr.FileLine();
3567  throw Exception("vGenerator::XReadStateSet", errstr.str(), 80);
3568  }
3569  // record state
3570  rStateSet.Insert(index);
3571  // record name if we read the core set
3572  if(&rStateSet==mpStates)
3573  if(name!="") {
3574  mpStateSymbolTable->SetEntry(index, name);
3575  }
3576  // test for attributes and such
3577  while(!rTr.Eos("State")) {
3578  Token token;
3579  rTr.Peek(token);
3580  // marking (if this is the main state set)
3581  Token mtag;
3582  if(token.IsBegin("Initial") && (&rStateSet==mpStates)) {
3583  rTr.ReadBegin("Initial",mtag);
3584  bool v=true;
3585  if(mtag.ExistsAttributeInteger("value"))
3586  v=mtag.AttributeIntegerValue("value");
3587  if(v) const_cast<vGenerator*>(this)->SetInitState(index);
3588  rTr.ReadEnd("Initial");
3589  continue;
3590  }
3591  if(token.IsBegin("Marked") && (&rStateSet==mpStates)) {
3592  rTr.ReadBegin("Marked",mtag);
3593  bool v=true;
3594  if(mtag.ExistsAttributeInteger("value"))
3595  v=mtag.AttributeIntegerValue("value");
3596  if(v) const_cast<vGenerator*>(this)->SetMarkedState(index);
3597  rTr.ReadEnd("Marked");
3598  continue;
3599  }
3600  // read attribute
3601  FD_DG("vGenerator(" << this << ")::XReadStates(\"" << rTr.FileName() << "\"): attribute ?");
3602  attrp->Read(rTr,"",this);
3603  rStateSet.Attribute(index,*attrp);
3604  // break on first unknown/undigested
3605  break;
3606  }
3607  // read end
3608  rTr.ReadEnd("State");
3609  }
3610  rTr.ReadEnd(label);
3611  // dispose attribute
3612  delete attrp;
3613  FD_DG("vGenerator(" << this << ")::XReadStates(\"" << rTr.FileName() << "\"): done");
3614 }
3615 
3616 
3617 
3618 // ReadTransRel(tr)
3620  FD_DG("vGenerator(" << this << ")::ReadTransRel(\"" << rTr.FileName() << "\")");
3621  AttributeVoid* attrp = mpTransRel->AttributeType()->New();
3622  FD_DG("vGenerator(" << this << ")::ReadTransRel(..): attribute type " << typeid(*attrp).name());
3623 
3624  // sense begin
3625  std::string label="";
3626  Token token;
3627  rTr.Peek(token);
3628  if(token.IsBegin("TransRel")) label="TransRel";
3629  if(token.IsBegin("T")) label="T";
3630  if(label=="") {
3631  std::stringstream errstr;
3632  errstr << "Reading TransRel failed in " << rTr.FileLine() << ": no valid begin token";
3633  throw Exception("vGenerator::ReadTransRel", errstr.str(), 50);
3634  }
3635  rTr.ReadBegin(label);
3636 
3637  // 2.24e: allow for new states or new events if not specified so far
3638  bool isx = StateSet().Empty();
3639  bool isn = StateSet().Empty();
3640  bool ien = Alphabet().Empty();
3641 
3642  // read section
3643  try {
3644  while(!rTr.Eos(label)) {
3645 
3646  // local vars
3647  Token x1t;
3648  Token x2t;
3649  Token evt;
3650 
3651  // clear my transition
3652  Idx x1 = 0, ev = 0, x2 = 0;
3653 
3654  // 1: the x1 token
3655  rTr >> x1t;
3656  if(x1t.IsInteger()) {
3657  x1=x1t.IntegerValue();
3658  if((!ExistsState(x1)) && isx) {InsState(x1); isn=false; };
3659  } else if(x1t.IsString()) {
3660  x1=StateIndex(x1t.StringValue());
3661  if(x1==0 && isn) { x1=InsState(x1t.StringValue()); isx=false; };
3662  } else break;
3663 
3664  // 2: the event token
3665  rTr >> evt;
3666  if(evt.IsString()) {
3667  evt.StringValue();
3668  ev=EventIndex(evt.StringValue());
3669  if((!ExistsEvent(ev)) && ien) {ev = InsEvent(evt.StringValue());};
3670  } else break;
3671 
3672  // 3: the x2 token
3673  rTr >> x2t;
3674  if(x2t.IsInteger()) {
3675  x2=x2t.IntegerValue();
3676  if((!ExistsState(x2)) && isx) {InsState(x2); isn=false; };
3677  } else if(x2t.IsString()) {
3678  x2=StateIndex(x2t.StringValue());
3679  if(x2==0 && isn) { x2=InsState(x2t.StringValue()); isx=false; };
3680  } else break;
3681 
3682  // 4: attributes
3683  attrp->Read(rTr,"",this);
3684 
3685  // 5: skip unknown attributes
3686  AttributeVoid::Skip(rTr);
3687 
3688  // check values
3689  if(!ExistsState(x1)){
3690  std::stringstream errstr;
3691  errstr << "invalid state x1 " << x1t.StringValue() << " " << rTr.FileLine();
3692  throw Exception("vGenerator::ReadTransRel", errstr.str(), 85);
3693  }
3694  if(!ExistsState(x2)){
3695  std::stringstream errstr;
3696  errstr << "invalid state x2 " << x2t.StringValue() << " " << rTr.FileLine();
3697  throw Exception("vGenerator::ReadTransRel", errstr.str(), 85);
3698  }
3699  if(!ExistsEvent(ev)) {
3700  std::stringstream errstr;
3701  errstr << "invalid event " << evt.StringValue() << " " << rTr.FileLine();
3702  throw Exception("vGenerator::ReadTransRel", errstr.str(), 85);
3703  }
3704 
3705  // insert transition
3706  Transition trans=Transition(x1,ev,x2);
3707  SetTransition(trans);
3708  TransAttribute(trans,*attrp);
3709 
3710  } // end while
3711  } // end try
3712 
3713  catch (faudes::Exception& oex) {
3714  delete attrp;
3715  std::stringstream errstr;
3716  errstr << "Reading TransRel failed in " << rTr.FileLine() << oex.What();
3717  throw Exception("vGenerator::ReadTransRel", errstr.str(), 50);
3718  }
3719 
3720  // read end token
3721  rTr.ReadEnd(label);
3722 
3723  // done
3724  FD_DG("vGenerator(" << this << ")::ReadTransRel(\"" << rTr.FileName() << "\"): done");
3725 
3726  // dispose attribute
3727  delete attrp;
3728 }
3729 
3730 
3731 // XReadTransRel(tr)
3733  FD_DG("vGenerator(" << this << ")::XReadTransRel()");
3734  AttributeVoid* attrp = mpTransRel->AttributeType()->New();
3735  FD_DG("vGenerator(" << this << ")::ReadTransRel(..): attribute type " << typeid(*attrp).name());
3736  // Clear my set
3737  mpTransRel->Clear();
3738  mpTransRel->Name("TransRel");
3739  // Read begin
3740  Token btag;
3741  rTr.ReadBegin("TransitionRelation",btag);
3742  // Scan my section
3743  while(!rTr.Eos("TransitionRelation")) {
3744  Token trtag;
3745  rTr.Get(trtag);
3746  // Ignore other sections
3747  if(!trtag.IsBegin("Transition")) {
3748  if(trtag.IsBegin())
3749  rTr.ReadEnd(trtag.StringValue());
3750  continue;
3751  }
3752  // Its a transition
3753  Idx x1=0;
3754  Idx x2=0;
3755  Idx ev=0;
3756  std::string evname;
3757  std::string x1name;
3758  std::string x2name;
3759  if(trtag.ExistsAttributeInteger("x1"))
3760  x1=trtag.AttributeIntegerValue("x1");
3761  if(trtag.ExistsAttributeInteger("x2"))
3762  x2=trtag.AttributeIntegerValue("x2");
3763  if(trtag.ExistsAttributeString("x1"))
3764  x1name=trtag.AttributeStringValue("x1");
3765  if(trtag.ExistsAttributeString("x2"))
3766  x2name=trtag.AttributeStringValue("x2");
3767  if(trtag.ExistsAttributeString("event"))
3768  evname=trtag.AttributeStringValue("event");
3769  // Interpret names
3770  ev=EventIndex(evname);
3771  if(x1==0) x1=StateIndex(x1name);
3772  if(x2==0) x2=StateIndex(x2name);
3773  // Report
3774  FD_DG("vGenerator::XReadTransRel(): got transition " << TStr(Transition(x1,ev,x2)));
3775  // test 1: components specified
3776  if(x1==0 || x2==0 || ev==0) {
3777  delete attrp;
3778  std::stringstream errstr;
3779  errstr << "Invalid transition at token " << trtag.Str() << rTr.FileLine();
3780  throw Exception("vGenerator::XReadTransRel", errstr.str(), 80);
3781  }
3782  // test 2: no doublets
3783  if(ExistsTransition(x1,ev,x2)) {
3784  delete attrp;
3785  std::stringstream errstr;
3786  errstr << "Doublet transition at token " << trtag.Str() << rTr.FileLine();
3787  throw Exception("vGenerator::XReadTransRel", errstr.str(), 80);
3788  }
3789  // test 3: components must exist
3790  if(!ExistsState(x1)){
3791  delete attrp;
3792  std::stringstream errstr;
3793  errstr << "Invalid state x1 " << x1 << " " << rTr.FileLine();
3794  throw Exception("vGenerator::XReadTransRel", errstr.str(), 80);
3795  }
3796  if(!ExistsState(x2)){
3797  delete attrp;
3798  std::stringstream errstr;
3799  errstr << "Invalid state x2 " << x2 << " " << rTr.FileLine();
3800  throw Exception("vGenerator::XReadTransRel", errstr.str(), 80);
3801  }
3802  if(!ExistsEvent(ev)){
3803  delete attrp;
3804  std::stringstream errstr;
3805  errstr << "Invalid event " << evname << " " << rTr.FileLine();
3806  throw Exception("vGenerator::XReadTransRel", errstr.str(), 80);
3807  }
3808  // record transition
3809  SetTransition(x1,ev,x2);
3810  // test for attribute
3811  Token token;
3812  rTr.Peek(token);
3813  if(!token.IsEnd("Transition")) {
3814  // read attribute
3815  attrp->Read(rTr,"",this);
3816  TransAttribute(Transition(x1,ev,x2),*attrp);
3817  }
3818  // read end
3819  rTr.ReadEnd("Transition");
3820  }
3821  rTr.ReadEnd("TransitionRelation");
3822  // dispose attribute
3823  delete attrp;
3824  FD_DG("vGenerator(" << this << ")::XReadTransRel(\"" << rTr.FileName() << "\"): done");
3825 }
3826 
3827 // EStr(index)
3828 std::string vGenerator::EStr(Idx index) const {
3829  std::string name = EventName(index);
3830  return name+"#"+faudes::ToStringInteger(index);
3831 }
3832 
3833 // SStr(index)
3834 std::string vGenerator::SStr(Idx index) const {
3835  std::string name = StateName(index);
3836  if(name == "") name=ToStringInteger(index);
3837  return name+"#"+faudes::ToStringInteger(index);
3838 }
3839 
3840 // TStr(index)
3841 std::string vGenerator::TStr(const Transition& trans) const {
3842  return SStr(trans.X1) + "--(" + EStr(trans.Ev) + ")-->" + SStr(trans.X2);
3843 }
3844 
3845 
3846 // GraphWrite(rFileName,rOutFormat)
3847 void vGenerator::GraphWrite(const std::string& rFileName, const std::string& rOutFormat,
3848  const std::string& rDotExec) const {
3849  FD_DG("vGenerator::GraphWrite(...): " << typeid(*this).name());
3850  // generate temp dot input file
3851  std::string dotin = CreateTempFile();
3852  if(dotin == "") {
3853  std::stringstream errstr;
3854  errstr << "Exception opening temp file";
3855  throw Exception("vGenerator::GraphWrite", errstr.str(), 2);
3856  }
3857  try{
3858  DotWrite(dotin);
3859  }
3860  catch (faudes::Exception& exception) {
3861  RemoveFile(dotin);
3862  std::stringstream errstr;
3863  errstr << "Exception writing dot input file";
3864  throw Exception("vGenerator::GraphWrite", errstr.str(), 2);
3865  }
3866  try{
3867  faudes::ProcessDot(dotin,rFileName,rOutFormat,rDotExec);
3868  }
3869  catch (faudes::Exception& exception) {
3870  RemoveFile(dotin);
3871  std::stringstream errstr;
3872  errstr << "Exception processing dot file";
3873  throw Exception("vGenerator::GraphWrite", errstr.str(), 3);
3874  }
3875  RemoveFile(dotin);
3876 }
3877 
3878 // rti wrapper
3879 bool IsAccessible(const vGenerator& rGen) {
3880  return rGen.IsAccessible();
3881 }
3882 
3883 // rti wrapper
3884 bool IsCoaccessible(const vGenerator& rGen) {
3885  return rGen.IsCoaccessible();
3886 }
3887 
3888 // rti wrapper
3889 bool IsTrim(const vGenerator& rGen) {
3890  return rGen.IsTrim();
3891 }
3892 
3893 // rti wrapper
3894 bool IsOmegaTrim(const vGenerator& rGen) {
3895  return rGen.IsOmegaTrim();
3896 }
3897 
3898 // rti wrapper
3899 bool IsComplete(const vGenerator& rGen) {
3900  return rGen.IsComplete();
3901 }
3902 
3903 // rti wrapper
3904 bool IsComplete(const vGenerator& rGen, const StateSet& rStateSet) {
3905  return rGen.IsComplete(rStateSet);
3906 }
3907 
3908 // rti wrapper
3909 bool IsComplete(const vGenerator& rGen, const EventSet& rSigmaO) {
3910  return rGen.IsComplete(rSigmaO);
3911 }
3912 
3913 // rti wrapper
3914 bool IsDeterministic(const vGenerator& rGen) {
3915  return rGen.IsDeterministic();
3916 }
3917 
3918 
3919 // rti wrapper
3920 void Accessible(vGenerator& rGen) {
3921  rGen.Accessible();
3922 }
3923 
3924 // rti wrapper
3925 void Accessible(const vGenerator& rGen, vGenerator& rRes) {
3926  rRes=rGen;
3927  rRes.Accessible();
3928 }
3929 
3930 // rti wrapper
3932  rGen.Coaccessible();
3933 }
3934 
3935 // rti wrapper
3936 void Coaccessible(const vGenerator& rGen, vGenerator& rRes) {
3937  rRes=rGen;
3938  rRes.Coaccessible();
3939 }
3940 
3941 // rti wrapper
3942 void Complete(vGenerator& rGen) {
3943  rGen.Complete();
3944 }
3945 
3946 // rti wrapper
3947 void Complete(const vGenerator& rGen, vGenerator& rRes) {
3948  rRes=rGen;
3949  rRes.Complete();
3950 }
3951 
3952 // rti wrapper
3953 void Complete(vGenerator& rGen, const EventSet& rSigmaO) {
3954  rGen.Complete(rSigmaO);
3955 }
3956 
3957 // rti wrapper
3958 void Complete(const vGenerator& rGen, const EventSet& rSigmaO, vGenerator& rRes) {
3959  rRes=rGen;
3960  rRes.Complete(rSigmaO);
3961 }
3962 
3963 // rti wrapper
3964 void Trim(vGenerator& rGen) {
3965  rGen.Trim();
3966 }
3967 
3968 // rti wrapper
3969 void Trim(const vGenerator& rGen, vGenerator& rRes) {
3970  rRes=rGen;
3971  rRes.Trim();
3972 }
3973 
3974 // rti wrapper
3975 void OmegaTrim(vGenerator& rGen) {
3976  rGen.OmegaTrim();
3977 }
3978 
3979 // rti wrapper
3980 void OmegaTrim(const vGenerator& rGen, vGenerator& rRes) {
3981  rRes=rGen;
3982  rRes.OmegaTrim();
3983 }
3984 
3985 // rti wrapper
3987  rGen.InjectMarkedStates(rGen.States());
3988 }
3989 
3990 
3991 // rti wrapper
3992 void AlphabetExtract(const vGenerator& rGen, EventSet& rRes) {
3993  // This function is an ideal debugging case for lbp_function.cpp.
3994  // FD_WARN("AlphabetExtract(): gen at " << &rGen << " sig at " << &rRes);
3995  // FD_WARN("AlphabetExtract(): gen id " << typeid(rGen).name() << " sig id " << typeid(rRes).name());
3996  rRes = rGen.Alphabet();
3997  // rRes.Write();
3998 }
3999 
4000 // rti convenience function
4001 void SetIntersection(const GeneratorVector& rGenVec, EventSet& rRes) {
4002  // prepare result
4003  rRes.Clear();
4004  // ignore empty
4005  if(rGenVec.Size()==0) return;
4006  // copy first
4007  rRes.Assign(rGenVec.At(0).Alphabet());
4008  // perform intersecttion
4009  for(GeneratorVector::Position i=1; i<rGenVec.Size(); i++)
4010  SetIntersection(rGenVec.At(i).Alphabet(),rRes,rRes);
4011 }
4012 
4013 
4014 // rti convenience function
4015 void SetUnion(const GeneratorVector& rGenVec, EventSet& rRes) {
4016  // prepare result
4017  rRes.Clear();
4018  // ignore empty
4019  if(rGenVec.Size()==0) return;
4020  // copy first
4021  rRes.Assign(rGenVec.At(0).Alphabet());
4022  // perform intersecttion
4023  for(GeneratorVector::Position i=1; i<rGenVec.Size(); i++)
4024  SetUnion(rGenVec.At(i).Alphabet(),rRes,rRes);
4025 }
4026 
4027 // rti convenience function
4028 void SetIntersection(const vGenerator& rGenA, const vGenerator& rGenB, EventSet& rRes) {
4029  SetIntersection(rGenA.Alphabet(),rGenB.Alphabet(),rRes);
4030 }
4031 
4032 // rti convenience function
4033 void SetUnion(const vGenerator& rGenA, const vGenerator& rGenB, EventSet& rRes) {
4034  SetUnion(rGenA.Alphabet(),rGenB.Alphabet(),rRes);
4035 }
4036 
4037 // rti convenience function
4038 void SetDifference(const vGenerator& rGenA, const vGenerator& rGenB, EventSet& rRes) {
4039  SetDifference(rGenA.Alphabet(),rGenB.Alphabet(),rRes);
4040 }
4041 
4042 
4043 } // name space
4044 
4045 
4046 /***** NOTES ****/
4047 
4048 /*
4049 class A {
4050 public:
4051  virtual A& operator=(const A& src) { std::cout << "A=A/"; return *this; };
4052  virtual A& assign(const A& src) { std::cout << "A=A/"; return *this; };
4053  int a;
4054 };
4055 class B : public A {
4056 public:
4057  virtual A& operator=(const A& src) { std::cout<<"B=A/"; return *this;};
4058  virtual A& assign(const A& src) { std::cout<<"B=A/"; return *this; };
4059  int b;
4060 };
4061 
4062 
4063 
4064 int main() {
4065 
4066  B mD1;
4067  B mD2;
4068  mD1=mD2; // << fails here, dont know why
4069  mD1.assign(mD2);
4070  A& rD1 = mD1;
4071  A& rD2 = mD2;
4072  rD1=rD2;
4073 }
4074 
4075 */
#define FD_DC(message)
Debug: optional report on container operations.
#define FD_DG(message)
Debug: optional report on generator operations.
#define FD_DV(message)
Debug: optional low-level report on iterations and token IO.
#define FD_DF(message)
Debug: optional report on user functions.
#define FD_ERR(message)
Debug: report more errors with file/line info.
#define FAUDES_OBJCOUNT_DEC(type)
#define FAUDES_OBJCOUNT_INC(type)
Debug: count objects, report on exit.
#define FD_SMALLTRANSREL
Max size of transrel for state name output.
#define FD_CONSECUTIVE
Min number of states to use consecutive section in file output.
Class vGenerator.
Minimal Attribute.
virtual bool IsDefault(void) const
Test for default value.
static void Skip(TokenReader &rTr)
Skip attribute tokens.
virtual void Clear(void)
Synonym for SetDefault to match std interface.
Faudes exception class.
virtual const char * What() const
Returns error description.
Set of indices.
Definition: cfl_indexset.h:78
Idx Insert(void)
Insert new index to set.
Idx MaxIndex(void) const
Get maximum index used in this set (0 for emptyset)
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
bool Exists(const Idx &rIndex) const
Test existence of index.
NameSet::Iterator Find(const Idx &rIndex) const
Find iterator for index.
virtual void InsertSet(const NameSet &rOtherSet)
Inserts all elements of rOtherSet.
SymbolTable * SymbolTablep(void) const
Get Pointer mpSymbolTable.
bool Insert(const Idx &rIndex)
Add an element by index.
Idx Index(const std::string &rName) const
Index lookup.
void RestrictSet(const NameSet &rOtherSet)
Restrict to elements specified by rOtherSet.
virtual bool Erase(const Idx &rIndex)
Delete element by index.
A SymbolTable associates sybolic names with indices.
void RestrictDomain(const IndexSet &rDomain)
Restrict to specified indicees.
static SymbolTable * GlobalEventSymbolTablep(void)
Get Static Symboltable ref (initialize on first use pattern)
std::string Symbol(Idx index) const
Symbolic name lookup.
void Clear(void)
Clear all entries.
void ClrEntry(Idx index)
Delete entry by index.
std::string UniqueSymbol(const std::string &rName) const
Create unique symbolic name by adding an underscore and extra digits.
void SetEntry(Idx index, const std::string &rName)
Set symbolic name for existing entry.
Idx Size(void) const
Size of symboltabel.
Idx Index(const std::string &rName) const
Index lookup.
Iterator class for high-level api to TBaseSet.
Definition: cfl_baseset.h:387
std::vector< int >::size_type Position
convenience typedef for positions
virtual const T & At(const Position &pos) const
Access element.
Iterator Begin(void) const
Iterator to begin of set.
Iterator End(void) const
Iterator to end of set.
Iterator Find(Idx x1, Idx ev, Idx x2) const
Find transition given by x1, ev, x2.
void EraseByEv(Idx ev)
Remove all transitions containing event ev.
void EraseByX1(Idx x1)
Remove all transitions containing predecessor state x1.
bool Exists(const Transition &t) const
Test existence.
void RestrictStates(const StateSet &rStateSet)
Restrict to transitions with states as specified.
Iterator BeginByX2(Idx x2) const
Iterator to first Transition specified by successor state x2.
void EraseByX1Ev(Idx x1, Idx ev)
Remove all transitions containing predecessor state x1 and event ev.
bool Insert(const Transition &rTransition)
Add a Transition.
Iterator EndByX2(Idx x2) const
Iterator to first Transition after specified successor state x2.
bool ExistsByX1Ev(Idx x1, Idx ev) const
Test existence.
Iterator Inject(const Iterator &pos, const Transition &rTransition)
Add a Transition.
bool Erase(const Transition &t)
Remove a Transition.
StateSet SuccessorStates(Idx x1) const
Get set of successor states for specified current state.
void RestrictEvents(const EventSet &rEventSet)
Restrict to transitions with events as specified.
void EraseByX1OrX2(Idx x)
Remove all transitions containing state x, This function iterates over all transitions to work with a...
TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator
Iterator on transition.
Definition: cfl_transset.h:269
void ReSort(TTransSet< OtherCmp > &res) const
Get copy of trantision relation sorted by other compare operator, e.g.
bool ExistsByX1(Idx x1) const
Test existence.
A TokenReader reads sequential tokens from a file or string.
std::string FileLine(void) const
Return "filename:line".
bool Eos(const std::string &rLabel)
Peek a token and check whether it ends the specified section.
bool Reset(int level=-1)
Reset to the begining of the specified level of section nesting.
int Level(void) const
Return current level of section nesting.
void ReadEnd(const std::string &rLabel)
Close the current section by matching the previous ReadBegin().
std::string ReadString(void)
Read string token.
void ReadBegin(const std::string &rLabel)
Open a section by specified label.
bool Get(Token &token)
Get next token.
bool Peek(Token &token)
Peek next token.
std::string FileName(void) const
Access the filename.
A TokenWriter writes sequential tokens to a file, a string or stdout.
std::string Str(void)
Retrieve output as string (if in String mode)
void WriteComment(const std::string &rComment)
Write comment in faudes format.
void Write(Token &rToken)
Write next token.
void Endl(void)
Write endl separator.
void WriteEnd(const std::string &rLabel)
Write end label.
int Columns(void) const
Get number of columns in a line.
void WriteBegin(const std::string &rLabel)
Write begin label.
Tokens model atomic data for stream IO.
Definition: cfl_token.h:53
std::string Str(void) const
Pretty print string representation.
Definition: cfl_token.cpp:1296
const std::string & StringValue(void) const
Get string value of a name token.
Definition: cfl_token.cpp:177
Int AttributeIntegerValue(const std::string &name)
Access attribute value.
Definition: cfl_token.cpp:396
void ClrEnd(void)
Clear End type (resolve empty section)
Definition: cfl_token.cpp:160
bool IsString(void) const
Test token Type.
Definition: cfl_token.cpp:243
Int IntegerValue(void) const
Get integer value of a numeric token.
Definition: cfl_token.cpp:166
bool IsInteger(void) const
Test token Type.
Definition: cfl_token.cpp:218
bool ExistsAttributeString(const std::string &name)
Test attibute existence.
Definition: cfl_token.cpp:355
bool IsBegin(void) const
Test token Type.
Definition: cfl_token.cpp:258
void SetEmpty(const std::string &rName)
Initialize as empty-tag token.
Definition: cfl_token.cpp:105
void SetBegin(const std::string &rName)
Initialize as Begin token.
Definition: cfl_token.cpp:91
bool ExistsAttributeInteger(const std::string &name)
Test attibute existence.
Definition: cfl_token.cpp:365
void InsAttributeInteger(const std::string &name, Int value)
Insert named attribute with integer value.
Definition: cfl_token.cpp:318
void InsAttributeString(const std::string &name, const std::string &value)
Insert named attribute with string value.
Definition: cfl_token.cpp:309
bool IsEnd(void) const
Test token Type.
Definition: cfl_token.cpp:269
const std::string & AttributeStringValue(const std::string &name)
Access attribute value.
Definition: cfl_token.cpp:385
Triple (X1,Ev,X2) to represent current state, event and next state.
Definition: cfl_transset.h:57
Idx X1
Current state.
Definition: cfl_transset.h:99
Idx X2
Next state.
Definition: cfl_transset.h:108
Base class of all libFAUDES objects that participate in the run-time interface.
Definition: cfl_types.h:239
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
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
Write configuration data to a string.
Definition: cfl_types.cpp:169
virtual void XWrite(const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
Write configuration data to an XML file.
Definition: cfl_types.cpp:200
virtual Type & Assign(const Type &rSrc)
Assign configuration data from other object.
Definition: cfl_types.cpp:77
virtual Type * New(void) const
Construct on heap.
Definition: cfl_types.cpp:54
virtual void DoSWrite(TokenWriter &rTw) const
Write statistical data as a comment to TokenWriter.
Definition: cfl_types.cpp:299
void SWrite(void) const
Write statistics comment to console.
Definition: cfl_types.cpp:250
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
virtual const std::string & TypeName(void) const
Get objects's type name.
Definition: cfl_types.cpp:132
Idx Size(void) const
Get size of vector.
Base class of all FAUDES generators.
static bool ReindexOnWriteDefault(void)
Enable/disable reindexing states for file-i/o.
const EventSet * pAlphabetPrototype
Pointer to alphabet prototype (incl.
virtual void TransAttribute(const Transition &rTrans, const Type &rAttr)
Set attribute for existing transition.
StateSet::Iterator StatesBegin(void) const
Iterator to Begin() of state set.
vGenerator(void)
Default constructor.
StateSet::Iterator InitStatesBegin(void) const
Iterator to Begin() of mInitStates.
virtual bool Valid(void) const
Check if generator is valid.
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.
void ClearInitStates(void)
Clear all mInitStates.
void WriteStates(TokenWriter &rTw) const
Write generators stateset to TokenWriter.
static const StateSet & StatesVoid(void)
Static default state set prototype (incl.
const EventSet & Alphabet(void) const
Return const reference to alphabet.
void ClearTransRel(void)
Clear all transitions.
Idx InsMarkedState(void)
Create new anonymous state and set as marked state.
void XReadStateSet(TokenReader &rTr, StateSet &rStateSet, const std::string &rLabel="") const
Read a stateset from TokenReader in XML format.
std::string TransRelToString(void) const
Write transition relation to string (no re-indexing)
virtual void DDotWrite(const std::string &rFileName) const
Writes generator to dot input format (no re-indexing).
static void StateNamesEnabledDefault(bool flag)
Sets the default for automatic state name generation.
virtual void Move(vGenerator &rGen)
Destructive copy to other vGenerator.
const AttributeVoid * pGlobalPrototype
Pointer to global attribute prototype (configures global attribute type)
std::string MarkedStatesToString(void) const
Write set of marked states to a string (no re-indexing)
virtual vGenerator & Assign(const Type &rSrc)
Copy from other faudes type.
virtual vGenerator * Copy(void) const
Construct copy on heap.
bool InitStatesEmpty(void) const
Check if set of initial states are empty.
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.
virtual ~vGenerator(void)
Destructor.
void DelEvents(const EventSet &rEvents)
Delete a set of events from generator.
const StateSet & InitStates(void) const
Const ref to initial states.
const SymbolTable & StateSymbolTable(void) const
Get StateSymbolTable.
bool mReindexOnWrite
Reindex states on file-i/o.
TransSet::Iterator TransRelBegin(void) const
Iterator to Begin() of transition relation.
void ClrTransition(Idx x1, Idx ev, Idx x2)
Remove a transition by indices.
EventSet * mpAlphabet
Pointer to alphabet (actual type depends on attributes)
EventSet * NewEventSetp(void) const
Create EventSet with generator's EventSymbolTable (on heap).
bool Accessible(void)
Make generator accessible.
EventSet NewEventSet(void) const
Create EventSet with generator's EventSymbolTable (on stack).
SymbolTable * EventSymbolTablep(void) const
Get Pointer to EventSymbolTable currently used by this vGenerator.
void WriteAlphabet(void) const
Write generators alphabet to console.
AttributeVoid * mpGlobalAttribute
Pointer to lobal attribute (actual type depends on attributes)
Idx StateIndex(const std::string &rName) const
State index lookup.
virtual void ClearEventAttributes(void)
Clear event attributes.
bool DelEvent(Idx index)
Delete event from generator by index.
void InjectState(Idx index)
Inject an existing state index into generators mStates Use with care! For use in performance optimize...
static const AttributeVoid & GlobalVoid(void)
Static default global attribute prototype (configures global attribute type)
virtual void EventAttribute(Idx index, const Type &rAttr)
Set attribute for existing event.
void SetMinStateIndexMap(void) const
Set minimal index map for file io of generator states.
bool Trim(void)
Make generator trim.
virtual void StateAttribute(Idx index, const Type &rAttr)
Set attribute for existing state.
virtual vGenerator & AssignWithoutAttributes(const vGenerator &rGen)
Copy from other vGenerator, ignore attributes.
StateSet::Iterator FindInitState(Idx index) const
Iterator to state index in mInitStates.
void ReadAlphabet(TokenReader &rTr)
Read the generator's alphabet from a TokenReader.
void ClrTransitions(Idx x1, Idx ev)
Remove a transitions by state and event.
void RestrictStates(const StateSet &rStates)
Restrict states Cleans mpStates, mInitStates, mMarkedStates, mpTransrel, and mpStateSymboltable.
EventSet::Iterator FindEvent(Idx index) const
Returns a iterator to event index in alphabet.
Idx InitStatesSize(void) const
Get number of initial states.
static bool msReindexOnWriteDefault
Default for automatic statenames.
void ClearStates(void)
Clear all states and transitions, maintain alphabet.
virtual void ClearTransAttributes(void)
Clear transition attributes.
bool IsAccessible(void) const
Check if generator is accessible.
void ReadStates(TokenReader &rTr)
Read the generator's stateset from a TokenReader.
void InsEvents(const EventSet &events)
Add new named events to generator.
void ClrMarkedState(Idx index)
Unset an existing state as marked state by index.
void InjectStates(const StateSet &rNewStates)
Inject a complete state set without consistency checks (without attributes)
static SymbolTable * GlobalEventSymbolTablep(void)
Get Pointer to global EventSymbolTable.
virtual AttributeVoid * GlobalAttributep(void)
Get attribute pointer The global attribute allways exits.
bool EventRename(Idx event, const std::string &rNewName)
Rename event in this generator.
StateSet mMarkedStates
Marked states.
virtual void GlobalAttribute(const Type &rAttr)
Set global attribute.
virtual AttributeVoid * TransAttributep(const Transition &rTrans)
Transition attribute pointer to access Attribute methods.
EventSet::Iterator AlphabetBegin(void) const
Iterator to Begin() of alphabet.
SymbolTable mStateSymbolTable
State symbol table (local per Generator)
void WriteStateSet(const StateSet &rStateSet) const
Write a stateset to console (no re-indexing).
virtual void DeleteCore(void)
Free my heap members (attribute dependent types)
SymbolTable * mpEventSymbolTable
Pointer to Event symbol table.
StateSet TransRelStates(void) const
Return the states covered by transitions.
static const EventSet & AlphabetVoid(void)
Static default alphabet prototype (incl.
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Write generator to TokenWriter, see Type::Write for public wrappers.
StateSet BlockingStates(void) const
Compute set of blocking states.
bool IsComplete(void) const
Check if generator is complete.
bool MarkedStatesEmpty(void) const
Check if set of marked states are empty.
StateSet::Iterator FindMarkedState(Idx index) const
Returns a iterator to state index in mMarkedStates.
virtual AttributeVoid * EventAttributep(Idx index)
Event attribute pointer to access Attribute methods.
const std::map< Idx, Idx > & MinStateIndexMap(void) const
Get state index translation map.
StateSet * mpStates
Pointer to state set (actual type depends on attributes)
void DWriteStateSet(TokenWriter &rTw, const StateSet &rStateSet) const
Write a stateset to TokenWriter (debug version, no re-indexing)
Idx MaxStateIndex(void) const
Get maximum state index used in this generator.
TransSet * mpTransRel
Pointer to ransition relation (actual type depends on attributes)
void ClrStateName(Idx index)
Clear name for individual state.
virtual vGenerator * New(void) const
Construct on heap.
void ClearMarkedStates(void)
Clear all marked states.
virtual void UpdateCore(void)
Callback for core update.
virtual void ClearStateAttributes(void)
Clear state attributes.
bool ExistsTransition(const std::string &rX1, const std::string &rEv, const std::string &rX2) const
Test for transition given by x1, ev, x2.
void MinStateIndex(void)
Re-enumerate states.
void EnforceStateNames(const std::string &rTemplate)
For all states without a symbolic name, assign a name based on suggested template and the index.
void InjectMarkedStates(const StateSet &rNewMarkedStates)
Replace mMarkedStates with StateSet given as parameter without consistency checks.
virtual void ClearGlobalAttribute(void)
Clear global attribute.
virtual void DoDWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Write generator in debugging format to TokenWriter, see Type::DWrite for public wrappers.
bool IsOmegaTrim(void) const
Check if generator is omega-trim.
Idx MarkedStatesSize(void) const
Get number of marked states.
void SetInitState(Idx index)
Set an existing state as initial state by index.
virtual void DoSWrite(TokenWriter &rTw) const
Write generator statistics as comment to TokenWriter, see Type::SWrite for public wrappers.
void InsStates(const StateSet &rStates)
Add anonymous states to generator.
virtual void GlobalAttributeTry(const Type &rAttr)
Set global attribute.
void ClearStateNames(void)
Remove all names from generator's StateSymbolTable.
TransSet ActiveTransSet(Idx x1) const
Return active transition set at state x1.
void WriteTransRel(void) const
Write transition relation to console (no re-indexing)
void XWriteStateSet(TokenWriter &rTw, const StateSet &rStateSet, const std::string &rLabel="") const
Write a stateset to TokenWriter in XML format.
void InsMarkedStates(const StateSet &rStates)
Add (perhaps new) anonymous initial states to generator
bool TransRelEmpty(void) const
Check if transition relation is empty.
StateSet TrimSet(void) const
Compute set of trim states.
std::string InitStatesToString(void) const
Write set of initial states to a string (no re-indexing)
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.
virtual const AttributeVoid & GlobalAttribute(void) const
Global attribute lookup.
bool mStateNamesEnabled
Automatic state names.
virtual AttributeVoid * StateAttributep(Idx index)
State attribute pointer to access Attribute methods.
virtual void ClrTransAttribute(const Transition &rTrans)
Clear attribute for existing transition.
bool IsCoaccessible(void) const
Check if generator is Coaccessible.
void ConfigureAttributeTypes(const AttributeVoid *pNewGlobalPrototype, const StateSet *pNewStatesPrototype, const EventSet *pNewAlphabetPrototype, const TransSet *pNewTransRelPrototype)
Configure attribute types.
StateSet::Iterator MarkedStatesBegin(void) const
Iterator to Begin() of mMarkedStates.
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
Read generator object from TokenReader, see Type::Read for public wrappers.
const TransSet * pTransRelPrototype
Pointer to transition relation prototype (incl.
void XWriteTransRel(TokenWriter &rTw) const
Write transition relation to tokenwriter in XML format.
bool Coaccessible(void)
Make generator Coaccessible.
bool DelEventFromAlphabet(Idx index)
Delete event from alphabet without consistency check.
void InjectTransition(const Transition &rTrans)
Set transition without consistency check.
StateSet::Iterator FindState(Idx index) const
Returns a iterator to state index in state set.
std::string StateSetToString(const StateSet &rStateSet) const
Write a stateset to string (no re-indexing).
std::string UniqueEventName(const std::string &rName) const
Create a new unique symbolic event name.
const std::string & Name(void) const
Get generator's name.
void RestrictAlphabet(const EventSet &rNewalphabet)
Restricts mpAlphabet incl removing resp.
std::string TStr(const Transition &rTrans) const
Return pretty printable transition (eg for debugging)
bool DelStateFromStates(Idx index)
Delete a state from generator without consistency check.
static bool msStateNamesEnabledDefault
Default for automatic statenames.
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.
void XReadTransRel(TokenReader &rTr)
Read the generator's transition relation from a TokenReader.
virtual void XDotWrite(const std::string &rFileName) const
Writes generator to dot input format for export to VioLib.
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.
Idx SuccessorState(Idx x1, Idx ev) const
Return the successor state of state x1 with event ev.
bool IsDeterministic(void) const
Check if generator is deterministic.
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).
std::map< Idx, Idx > mMinStateIndexMap
Map State indices to consecutive indices.
StateSet TerminalStates(void) const
Compute set of terminal states.
StateSet::Iterator MarkedStatesEnd(void) const
Iterator to End() of mMarkedStates.
Idx InsState(void)
Add new anonymous state to generator.
void InjectTransRel(const TransSet &rNewtransrel)
Set transition relation without consistency check (no attributes)
void SetMarkedState(Idx index)
Set an existing state as marked state by index.
bool Empty(void) const
Check if generator is empty (no states)
Transition TransitionByNames(const std::string &rX1, const std::string &rEv, const std::string &rX2) const
Convebience function.
Idx InitState(void) const
Return initial state.
Idx InsInitState(void)
Create new anonymous state and set as initial state.
static Idx msObjectCount
Number of generator objects.
StateSet mInitStates
Initial states.
std::string StateSetToText(const StateSet &rStateSet) const
Write a stateset to formated text (no re-indexing).
void ReadStateSet(TokenReader &rTr, const std::string &rLabel, StateSet &rStateSet) const
Read a state set.
bool ReindexOnWrite(void) const
Test whether file-i/o uses minimal state indicees.
std::string mMyName
Name of generator.
virtual void EventAttributes(const EventSet &rEventSet)
Set attributes for existing events.
void InsInitStates(const StateSet &rStates)
Add (perhaps new) anonymous initial states to generator
void InjectInitStates(const StateSet &rNewInitStates)
Replace mInitStates with StateSet given as parameter without consistency checks.
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.
std::string TransRelToText(void) const
Write transition relation to formated text (no re-indexing)
StateSet::Iterator InitStatesEnd(void) const
Iterator to End() of mInitStates.
virtual void NewCore(void)
Allocate my heap members (attribute dependent types)
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.
static const TransSet & TransRelVoid(void)
Static default transition relation prototype (incl.
virtual void ClrStateAttribute(Idx index)
Clear attribute for existing state.
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.
virtual const Type * Cast(const Type *pOther) const
Type test.
void ClearMinStateIndexMap(void) const
Clear minimal index map for 1:1 file io.
std::string EventName(Idx index) const
Event name lookup.
const StateSet * pStatesPrototype
Pointer to state set prototype (incl.
EventSet::Iterator AlphabetEnd(void) const
Iterator to End() of alphabet.
std::string StatesToText(void) const
Write stateset of this generator to formated text (no re-indexing)
bool IsTrim(void) const
Check if generator is trim.
virtual void ClearAttributes(void)
Clear Attributes.
virtual void DoXWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Write generator to TokenWriter, see Type::XWrite for public wrappers.
StateSet CoaccessibleSet(void) const
Compute set of Coaccessible states.
Idx mId
Number of generator.
void MinimizeAlphabet(void)
Set the alphabet to used events.
virtual vGenerator & operator=(const vGenerator &rOtherGen)
Assignment operator (uses Assign method)
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.
SymbolTable * mpStateSymbolTable
Pointer to State symbol table.
virtual void ClrEventAttribute(Idx index)
Clear attribute for existing event.
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.
TransSet::Iterator FindTransition(const std::string &rX1, const std::string &rEv, const std::string &rX2) const
iterator to transition given by x1, ev, x2
void DoAssign(const vGenerator &rSrc)
Assignment for matching type.
std::string AlphabetToString(void) const
Write generators alphabet to string.
std::string UniqueStateName(const std::string &rName) const
Create a new unique symbolic state name.
bool Complete(void)
Make generator Complete.
void ReadTransRel(const std::string &rFileName)
Read the generator's transition relation from a file.
void DWriteTransRel(TokenWriter &rTw) const
Write transition relation to tokenwriter (debug version)
const StateSet & States(void) const
Return reference to state set.
void InjectAlphabet(const EventSet &rNewalphabet)
Set mpAlphabet without consistency check.
StateSet SuccessorStates(Idx x1) const
Return the successor states of state x1.
bool AlphabetEmpty(void) const
Check if alphabet is Empty.
virtual const AttributeVoid * AttributeType(void) const
Attribute typeinfo.
Definition: cfl_baseset.h:2171
virtual TBaseSet & AssignWithoutAttributes(const TBaseSet &rSourceSet)
Attribute access.
Definition: cfl_baseset.h:2237
bool Empty(void) const
Test whether if the TBaseSet is Empty.
Definition: cfl_baseset.h:1824
void SetDifference(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB, TBaseSet< T, Cmp > &rRes)
Definition: cfl_baseset.h:1078
bool Exists(const T &rElem) const
Test existence of element.
Definition: cfl_baseset.h:2115
virtual void Attributes(const TBaseSet &rOtherSet)
Attributes access.
Definition: cfl_baseset.h:2246
IndexSet StateSet
Definition: cfl_indexset.h:271
virtual void Clear(void)
Clear all set.
Definition: cfl_baseset.h:1902
TTransSet< TransSort::X1EvX2 > TransSet
Type definition for default sorted TTransSet.
Definition: cfl_transset.h:954
Iterator Find(const T &rElem) const
Find element and return iterator.
Definition: cfl_baseset.h:2110
Idx AttributesSize(void) const
Attribute access.
Definition: cfl_baseset.h:2182
TTransSet< TransSort::X2EvX1 > TransSetX2EvX1
Type definition for x2, ev, x1 sorted TTransSet.
Definition: cfl_transset.h:966
Iterator End(void) const
Iterator to the end of set.
Definition: cfl_baseset.h:1896
TTransSet< TransSort::X1X2Ev > TransSetX1X2Ev
Type definition for x1, x2, ev sorted TTransSet.
Definition: cfl_transset.h:972
virtual void RestrictSet(const TBaseSet &rOtherSet)
Restrict elements given by other set.
Definition: cfl_baseset.h:2064
virtual void InsertSet(const TBaseSet &rOtherSet)
Insert elements given by rOtherSet.
Definition: cfl_baseset.h:1987
virtual AttributeVoid * Attributep(const T &rElem)
Attribute access.
Definition: cfl_baseset.h:2279
Iterator Begin(void) const
Iterator to the begin of set.
Definition: cfl_baseset.h:1891
NameSet EventSet
Convenience typedef for plain event sets.
Definition: cfl_nameset.h:531
TTransSet< TransSort::X2X1Ev > TransSetX2X1Ev
Type definition for x2, x1, ev sorted TTransSet.
Definition: cfl_transset.h:969
virtual const AttributeVoid & Attribute(const T &rElem) const
Attribute access.
Definition: cfl_baseset.h:2290
virtual bool Erase(const T &rElem)
Erase element by reference.
Definition: cfl_baseset.h:2019
const std::string & Name(void) const
Return name of TBaseSet.
Definition: cfl_baseset.h:1755
void SetUnion(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB, TBaseSet< T, Cmp > &rRes)
Definition: cfl_baseset.h:1019
void SetIntersection(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB, TBaseSet< T, Cmp > &rRes)
Definition: cfl_baseset.h:1049
virtual void EraseSet(const TBaseSet &rOtherSet)
Erase elements given by other set.
Definition: cfl_baseset.h:2042
Idx Size(void) const
Get Size of TBaseSet.
Definition: cfl_baseset.h:1819
void ClearAttributes(void)
Attribute access.
Definition: cfl_baseset.h:2187
virtual void ClrAttribute(const T &rElem)
Attribute access.
Definition: cfl_baseset.h:2317
bool IsComplete(const vGenerator &rGen)
RTI wrapper function.
void Trim(vGenerator &rGen)
RTI wrapper function.
void OmegaTrim(vGenerator &rGen)
RTI wrapper function.
void Complete(vGenerator &rGen)
RTI wrapper function.
bool IsOmegaTrim(const vGenerator &rGen)
RTI wrapper function.
bool IsAccessible(const vGenerator &rGen)
RTI wrapper function.
bool IsTrim(const vGenerator &rGen)
RTI wrapper function.
void MarkAllStates(vGenerator &rGen)
RTI wrapper function.
bool IsCoaccessible(const vGenerator &rGen)
RTI wrapper function.
void AlphabetExtract(const vGenerator &rGen, EventSet &rRes)
RTI wrapper function.
void Accessible(vGenerator &rGen)
RTI wrapper function.
void Coaccessible(vGenerator &rGen)
RTI wrapper function.
bool IsDeterministic(const vGenerator &rGen)
RTI wrapper function.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
void ProcessDot(const std::string &rDotFile, const std::string &rOutFile, const std::string &rOutFormat, const std::string &rDotExec)
Convenience function: process dot file to graphics output.
Definition: cfl_helper.cpp:148
bool RemoveFile(const std::string &rFileName)
Delete a file.
Definition: cfl_helper.cpp:256
Idx ToIdx(const std::string &rString)
Convert a string to Idx.
Definition: cfl_helper.cpp:100
std::string CreateTempFile(void)
Create a temp file, length 0.
Definition: cfl_helper.cpp:205
std::string ToStringInteger(Int number)
integer to string
Definition: cfl_helper.cpp:43

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