cfl_transset.h
Go to the documentation of this file.
1/** @file cfl_transset.h @brief Classes Transition, TTransSet and TaTransSet */
2
3/* FAU Discrete Event Systems Library (libfaudes)
4
5Copyright (C) 2006 Bernd Opitz
6Copyright (C) 2007,2024 Thomas Moor
7
8Exclusive copyright is granted to Klaus Schmidt
9
10This library is free software; you can redistribute it and/or
11modify it under the terms of the GNU Lesser General Public
12License as published by the Free Software Foundation; either
13version 2.1 of the License, or (at your option) any later version.
14
15This library is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public
21License along with this library; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24
25#ifndef FAUDES_TRANSSET_H
26#define FAUDES_TRANSSET_H
27
28
29#include <sstream>
30#include <map>
31#include <iostream>
32#include <typeinfo>
33
34#include "cfl_definitions.h"
35#include "cfl_baseset.h"
36#include "cfl_attrmap.h"
37#include "cfl_indexset.h"
38#include "cfl_nameset.h"
39#include "cfl_attributes.h"
40#include "cfl_tokenreader.h"
41
42
43namespace faudes {
44
45/** @addtogroup ContainerClasses */
46/** @{*/
47
48/**
49 * Triple (X1,Ev,X2) to represent current state, event and next state.
50 * This class provides the triple in struct like fashion where the components
51 * are of type faudes::Idx. While default order is lexographic, the transition
52 * container TTransSet allows for alternative sorting. Since technically a
53 * Transition is just a triple of indices, it is only the context of a generator
54 * that actually makes it a transition (eg by providing mandatory symbolic event
55 * names).
56 */
58
59 public:
60
61 /** Construct invalid Transition */
62 Transition(void) : X1(0), Ev(0), X2(0) {};
63
64 /**
65 * Construct from values.
66 * @param x1
67 * Index of current state
68 * @param ev
69 * Index of Event
70 * @param x2
71 * Index of next state
72 */
73 Transition(Idx x1, Idx ev,Idx x2) :
74 X1(x1), Ev(ev), X2(x2) {}
75
76 /** Default order for sorting container of Transition (lexographic) */
77 inline bool operator < (const Transition& othertrans) const {
78 if (X1 < othertrans.X1) return true;
79 if (X1 > othertrans.X1) return false;
80 if (Ev < othertrans.Ev) return true;
81 if (Ev > othertrans.Ev) return false;
82 if (X2 < othertrans.X2) return true;
83 return false;
84 }
85
86 /** Equality operator */
87 inline bool operator == (const Transition& othertrans) const {
88 return ((X1 == othertrans.X1) && (Ev == othertrans.Ev) && (X2 == othertrans.X2));
89 };
90
91 /** Inequality operator */
92 inline bool operator != (const Transition& othertrans) const {
93 return ((X1 != othertrans.X1) || (Ev != othertrans.Ev) || (X2 != othertrans.X2));
94 };
95
96 /** Test validity (all indices !=0) */
97 inline bool Valid(void) const {
98 return (X1!=0) && (Ev!=0) && (X2!=0);
99 };
100
101 /** Current state */
103
104 /** Event */
106
107 /** Next state */
109
110 /** Pretty print to string */
111 std::string Str(void) const {
112 return ToStringInteger(X1)+"--("+ToStringInteger(Ev) + ")->" + ToStringInteger(X2);}
113};
114
115
116
117
118/**
119 * Alternative ordering of Transitions. This class provides binary predicates
120 * for sorting transition containers by variant lexographic order.
121 */
122
124
125 public:
126
127 /** Binary predicate for sorting transitions in order Ev, X1, X2 */
128 struct EvX1X2 {
129 inline bool operator () (const Transition& left, const Transition& right) const {
130 if (left.Ev < right.Ev) return true;
131 if (left.Ev > right.Ev) return false;
132 if (left.X1 < right.X1) return true;
133 if (left.X1 > right.X1) return false;
134 if (left.X2 < right.X2) return true;
135 return false;
136 }
137 };
138
139 /** Binary predicate for sorting transitions in order Ev, X2, X1 */
140 struct EvX2X1 {
141 inline bool operator () (const Transition& left, const Transition& right) const {
142 if (left.Ev < right.Ev) return true;
143 if (left.Ev > right.Ev) return false;
144 if (left.X2 < right.X2) return true;
145 if (left.X2 > right.X2) return false;
146 if (left.X1 < right.X1) return true;
147 return false;
148 }
149 };
150
151 /** Binary predicate for sorting transitions in order X2, Ev, X1 */
152 struct X2EvX1 {
153 inline bool operator () (const Transition& left, const Transition& right) const {
154 if (left.X2 < right.X2) return true;
155 if (left.X2 > right.X2) return false;
156 if (left.Ev < right.Ev) return true;
157 if (left.Ev > right.Ev) return false;
158 if (left.X1 < right.X1) return true;
159 return false;
160 }
161 };
162
163 /** Binary predicate for sorting transitions in order X2, X1, Ev */
164 struct X2X1Ev {
165 inline bool operator () (const Transition& left, const Transition& right) const {
166 if (left.X2 < right.X2) return true;
167 if (left.X2 > right.X2) return false;
168 if (left.X1 < right.X1) return true;
169 if (left.X1 > right.X1) return false;
170 if (left.Ev < right.Ev) return true;
171 return false;
172 }
173 };
174
175 /** Binary predicate for sorting transitions in order X1, X2, Ev */
176 struct X1X2Ev {
177 inline bool operator () (const Transition& left, const Transition& right) const {
178 if (left.X1 < right.X1) return true;
179 if (left.X1 > right.X1) return false;
180 if (left.X2 < right.X2) return true;
181 if (left.X2 > right.X2) return false;
182 if (left.Ev < right.Ev) return true;
183 return false;
184 }
185 };
186
187 /** Binary predicate for sorting transitions in order X1, Ev, X2 */
188 struct X1EvX2 {
189 inline bool operator () (const Transition& left, const Transition& right) const {
190 if (left.X1 < right.X1) return true;
191 if (left.X1 > right.X1) return false;
192 if (left.Ev < right.Ev) return true;
193 if (left.Ev > right.Ev) return false;
194 if (left.X2 < right.X2) return true;
195 return false;
196 }
197 };
198
199};
200
201
202
203/**
204 * Set of Transitions.
205 *
206 * This container class provides similar functionality and interface as BaseSet, but
207 * for Transitions rather than indices. The additional feature is a template parameter
208 * that allows to specify alternative sorting. For algorithms that examine a transition
209 * relation by e.g. the successor state X2, it may be worthwhile to copy a given
210 * TTransRel<TransSort::X1EvX2> to a TTransRel<TransSort::X2EvX1>. Example,
211 * assuming some transition relation is given in default order
212 *
213 * \code
214 * TransSet transrel; // transrel default order X1-Ev-X2
215 *
216 * // ... some operation to set up transrel
217 *
218 * TTransSet<TransSort::X2EvX1> transByX2; // alternative order X2-Ev-X1
219 * transrel.ReSort(transByX2); // copy and re-order transrel
220 * Iterator tit =transByX2.BeginByX2(x2) // begin iterator, X2 specified
221 * Iterator tit_end=transByX2.EndByX2(x2) // end iterator, X2 specified
222 * for(; tit!=tit_end; ++tit) { // loop over all transitions with specified x2
223 *
224 * // ... code to examine tramsitions with specified x2
225 *
226 * }
227 *
228 * \endcode
229 *
230 * Note: it is the context of a Generator that
231 * actually allows to interpret a TTransSet as a set of transitions as opposed to
232 * a set of triples of indices. In particular, file IO of transitions is provided
233 * by the generator class (although TTransSet provides basic output functions for debugging)
234 */
235
236// tweak: this appears to be a g++ 4.2 (OsX) issue --- fails at dynamic cast if this symbol is not explicitly exposed
237//#ifdef __GNUC__
238//template <class Cmp=TransSort::X1EvX2>
239//class FAUDES_API TTransSet : public TBaseSet<Transition,Cmp> {
240//#else
241template <class Cmp=TransSort::X1EvX2>
242class FAUDES_TAPI TTransSet : public TBaseSet<Transition,Cmp> {
243//#endif
244
246
247
248 public:
249
250 using TBaseSet<Transition,Cmp>::operator=;
251 using TBaseSet<Transition,Cmp>::operator==;
252 using TBaseSet<Transition,Cmp>::operator!=;
253
254 /** @name Constructors & Destructor */
255 /** @{ doxygen group */
256
257 /** Construct an empty TTransSet object */
258 TTransSet(void);
259
260 /**
261 * Copy-constructor
262 */
263 TTransSet(const TTransSet<Cmp>& rOtherSet);
264
265 /**
266 * Re-Sort Copy-constructor
267 */
268 template<class OtherCmp>
270
271 /** Virtual destructor */
272 virtual ~TTransSet() {};
273
274
275 /** @} doxygen group */
276
277
278 /** Iterator on transition */
280
281
282 /** @name Accessing individual transitions */
283 /** @{ doxygen group */
284
285 /**
286 * Add a Transition.
287 *
288 * @param rTransition
289 * Reference to transition object
290 * @return
291 * True if the transition was new to the set
292 *
293 */
294 bool Insert(const Transition& rTransition);
295
296 /**
297 * Add a Transition by indices
298 *
299 * @param x1
300 * Predecessor state
301 * @param ev
302 * Event
303 * @param x2
304 * Successor state
305 * @return
306 * True if the transition was new to the set
307 *
308 */
309 bool Insert(Idx x1, Idx ev, Idx x2);
310
311 /**
312 * Add a Transition.
313 *
314 * @param pos
315 * Insertion hint passed to STL
316 * @param rTransition
317 * Reference to transition object
318 * @return
319 * Insertion position
320 *
321 */
322 Iterator Inject(const Iterator& pos, const Transition& rTransition);
323
324 /**
325 * Add a Transition.
326 *
327 * @param rTransition
328 * Reference to transition object
329 * @return
330 * Insertion position
331 *
332 */
333 void Inject(const Transition& rTransition);
334
335 /**
336 * Remove a Transition
337 *
338 * @return
339 * True if transition did exist
340 */
341 bool Erase(const Transition& t);
342
343 /**
344 * Remove a Transition by x1, ev, x2
345 *
346 * @return
347 * True if transition did exist
348 */
349 bool Erase(Idx x1, Idx ev, Idx x2);
350
351 /**
352 * Remove a Transition by iterator
353 *
354 * @return
355 * Iterator to next transition
356 */
358
359 /**
360 * Remove all transitions containing predecessor state x1.
361 *
362 * @param x1
363 * State index
364 * @exception Exception
365 * - sorting mismatch (id 68)
366 */
367 void EraseByX1(Idx x1);
368
369 /**
370 * Remove all transitions containing predecessor state x1 and event ev.
371 *
372 * @param x1
373 * State index
374 * @param ev
375 * Event index
376 * @exception Exception
377 * - sorting mismatch (id 68)
378 */
379 void EraseByX1Ev(Idx x1, Idx ev);
380
381 /**
382 * Remove all transitions containing successor state x2.
383 * This function iterates over all transitions to work with any sorting.
384 *
385 * @param x2
386 * State index
387 */
388 void EraseByX2(Idx x2);
389
390 /**
391 * Remove all transitions containing event ev.
392 * This function iterates over all transitions to work with any sorting.
393 *
394 * @param ev
395 * Event index
396 */
397 void EraseByEv(Idx ev);
398
399 /**
400 * Remove all transitions containing state x,
401 * This function iterates over all transitions to work with any sorting.
402 *
403 * @param x
404 * State index
405 */
407
408 /**
409 * Remove all transitions containing a specified state.
410 * This function iterates over all transitions to work with any sorting.
411 *
412 * @param rStates
413 * Set of states to remore
414 */
415 void EraseByX1OrX2(const StateSet& rStates);
416
417 /**
418 * Restrict to transitions with states as specified.
419 * Erases any transition with X1 or X2 not in the specified state set.
420 *
421 * @param rStateSet
422 * Set of states to keep.
423 */
424 void RestrictStates(const StateSet& rStateSet);
425
426 /**
427 * Restrict to transitions with events as specified.
428 * Erases any transition with event not in the specified state set.
429 *
430 * @param rEventSet
431 * Set of events to keep.
432 */
433 void RestrictEvents(const EventSet& rEventSet);
434
435 /**
436 * Find transition given by x1, ev, x2
437 *
438 *
439 * @param x1
440 * Predecessor state
441 * @param ev
442 * Event
443 * @param x2
444 * Successor state
445 *
446 * @return
447 * Iterator to transition or End() if not exists
448 */
449 Iterator Find(Idx x1, Idx ev, Idx x2) const;
450
451 /**
452 * Find specified transition
453 *
454 *
455 * @param t
456 * Transition
457 *
458 * @return
459 * Iterator to transition or End() if not exists
460 */
461 Iterator Find(const Transition& t) const;
462
463
464 /**
465 * Test existence
466 *
467 * @param t
468 * Transition
469 *
470 * @return
471 * bool
472 */
473 bool Exists(const Transition& t) const;
474
475 /**
476 * Test existence
477 *
478 * @param x1
479 * Predecessor state Idx
480 * @param ev
481 * Event Idx
482 * @param x2
483 * Successor state Idx
484 *
485 * @return
486 * bool
487 */
488 bool Exists(Idx x1, Idx ev, Idx x2) const;
489
490 /**
491 * Test existence
492 *
493 * @param x1
494 * Predecessor state Idx
495 * @param ev
496 * Event Idx
497 *
498 * @return
499 * bool
500 */
501 bool ExistsByX1Ev(Idx x1, Idx ev) const;
502
503 /**
504 * Test existence
505 *
506 * @param x1
507 * Predecessor state Idx
508 *
509 * @return
510 * bool
511 */
512 bool ExistsByX1(Idx x1) const;
513
514 /**
515 * Tests if a transition with specified predecessor or successor state
516 * exists.
517 *
518 * @param x
519 * State Idx
520 *
521 * @return
522 * bool
523 */
524 bool ExistsByX1OrX2(Idx x) const;
525
526 /** @} doxygen group */
527
528
529 /** @name Transition iterators
530 *
531 * A variaty of iterators are provided to examine specified
532 * segments of the transition relation, e.g. all transitions starting
533 * from a given state. Note that implemetation of these iterators
534 * requires the transition set to be of sorted accordingly. Eg.
535 * scanning all transitions that are labled with a particular event
536 * requires a sorting TransSOrt::EvX1X2 orT ransSOrt::EvX2X1.
537 *
538 *
539 */
540
541 /** @{ doxygen group: iterators */
542
543 /**
544 * Iterator to begin of set
545 *
546 * @return
547 * TTransSet<Cmp>::Iterator
548 */
549 Iterator Begin(void) const;
550
551 /**
552 * Iterator to end of set
553 *
554 * @return
555 * TTransSet<Cmp>::Iterator
556 */
557 Iterator End(void) const;
558
559
560 /**
561 * Iterator to first Transition specified by current state.
562 *
563 * @param x1
564 * Predecessor state index
565 *
566 * @return
567 * TTransSet<Cmp>::Iterator
568 *
569 * @exception Exception
570 * - Sorting mismatch (id 68)
571 */
572 Iterator Begin(Idx x1) const;
573
574 /**
575 * Iterator to end or Transitions with specified current state.
576 *
577 * @param x1
578 * Predecessor state index
579 *
580 * @return
581 * TTransSet<Cmp>::Iterator
582 *
583 * @exception Exception
584 * - Sorting mismatch (id 68)
585 */
586 Iterator End(Idx x1) const;
587
588 /**
589 * Iterator to first Transitions specified by current state and event.
590 *
591 * @param x1
592 * Predecessor state index
593 * @param ev
594 * Event index
595 *
596 * @return
597 * TTransSet<Cmp>::Iterator
598 *
599 * @exception Exception
600 * - Sorting mismatch (id 68)
601 */
602 Iterator Begin(Idx x1, Idx ev) const;
603
604 /**
605 * Iterator to first Transition after spcified current state and event.
606 *
607 * @param x1
608 * Predecessor state index
609 * @param ev
610 * Event index
611 *
612 * @return
613 * TTransSet<Cmp>::Iterator
614 *
615 * @exception Exception
616 * - sorting mismatch (id 68)
617 */
618 Iterator End(Idx x1, Idx ev) const;
619
620 /**
621 * Iterator to first Transition specified by event.
622 * This function requires sorting TransSort::EvX1X2 or TransSort::EvX2X1.
623 *
624 * @param ev
625 * Event index
626 *
627 * @return
628 * TTransSet<Cmp>::iterator
629 *
630 * @exception Exception
631 * - sorting mismatch (id 68)
632 */
634
635 /**
636 * Iterator to first Transition after specified by event.
637 * This function requires sorting TransSort::EvX1X2 or TransSort::EvX2X1
638 *
639 * @param ev
640 * Predecessor state index
641 *
642 * @return
643 * TTransSet<Cmp>::Iterator
644 *
645 * @exception Exception
646 * - sorting mismatch (id 68)
647 */
649
650 /**
651 * Iterator to first Transition specified by event and current state.
652 * This function requires sorting TransSort::EvX1X2.
653 *
654 * @param ev
655 * Event index
656 * @param x1
657 * Predecessor state index
658 *
659 * @return
660 * TTransSet<Cmp>::iterator
661 *
662 * @exception Exception
663 * - sorting mismatch (id 68)
664 */
666
667 /**
668 * Iterator to first Transition after specified ev and current state.
669 * This function requires sorting TransSort::EvX1X2.
670 *
671 * @param ev
672 * Event index
673 * @param x1
674 * Predecessor state index
675 *
676 * @return
677 * TTransSet<Cmp>::Iterator
678 *
679 * @exception Exception
680 * - sorting mismatch (id 68)
681 */
682 Iterator EndByEvX1(Idx ev, Idx x1) const;
683
684 /**
685 * Iterator to first Transition specified by event and next state.
686 * This function requires sorting TransSort::EvX2X1.
687 *
688 * @param ev
689 * Event index
690 * @param x2
691 * Predecessor state index
692 *
693 * @return
694 * TTransSet<Cmp>::Iterator
695 *
696 * @exception Exception
697 * - sorting mismatch (id 68)
698 */
700
701 /**
702 * Iterator to first Transition after specified event and next state.
703 * This function requires sorting TransSort::EvX2X1.
704 *
705 * @param ev
706 * Event index
707 * @param x2
708 * Predecessor state index
709 *
710 * @return
711 * TTransSet<Cmp>::Iterator
712 *
713 * @exception Exception
714 * - sorting mismatch (id 68)
715 */
716 Iterator EndByEvX2(Idx ev, Idx x2) const;
717
718 /**
719 * Iterator to first Transition specified by successor state x2.
720 * This function requires sorting TransSort::X2EvX1 or TransSort::X2X1Ev.
721 *
722 * @param x2
723 * Predecessor state index
724 *
725 * @return
726 * TTransSet<Cmp>::iterator
727 *
728 * @exception Exception
729 * - sorting mismatch (id 68)
730 */
732
733 /**
734 * Iterator to first Transition after specified successor state x2.
735 * This function requires sorting TransSort::X2EvX1 or TransSort::X2X1Ev
736 *
737 * @param x2
738 * Predecessor state index
739 *
740 * @return
741 * TTransSet<Cmp>::Iterator
742 *
743 * @exception Exception
744 * - sorting mismatch (id 68)
745 */
747
748 /**
749 * Iterator to first Transition specified by successor x2 and ev.
750 * This function requires sorting TransSort::X2EvX1.
751 *
752 * @param x2
753 * Predecessor state index
754 * @param ev
755 * Event index
756 *
757 * @return
758 * TTransSet<Cmp>::Iterator
759 *
760 * @exception Exception
761 * - sorting mismatch (id 68)
762 */
764
765 /**
766 * Iterator to first Transition after specified successor x2 and ev.
767 * This function requires sorting TransSort::X2EvX1.
768 *
769 * @param x2
770 * Predecessor state index
771 * @param ev
772 * Event index
773 *
774 * @return
775 * TTransSet<Cmp>::Iterator
776 *
777 * @exception Exception
778 * - sorting mismatch (id 68)
779 */
780 Iterator EndByX2Ev(Idx x2, Idx ev) const;
781
782 /** @} doxygen group */
783
784 /** @name Set Operators
785 *
786 * Reimplement boolean operators.
787 *
788 */
789
790 /** @{ doxygen group: operators */
791
792
793 /**
794 * Set union operator
795 *
796 * @return
797 * Union Set
798 *
799 */
800 TTransSet<Cmp> operator + (const TTransSet<Cmp>& rOtherSet) const;
801
802 /**
803 * Set difference operator
804 *
805 * @return
806 * Set Difference NameSet
807 *
808 */
809 TTransSet<Cmp> operator - (const TTransSet<Cmp>& rOtherSet) const;
810
811 /**
812 * Set intersection operator
813 *
814 * @return
815 * Set Intersection
816 *
817 */
818 TTransSet<Cmp> operator * (const TTransSet<Cmp>& rOtherSet) const;
819
820 /** @} doxygen group */
821
822 /** @name Misc */
823 /** @{ doxygen group */
824
825 /**
826 * Get copy of trantision relation sorted by other compare
827 * operator, e.g. TSort::X2EvX1
828 *
829 * @return
830 * Transition relation
831 */
832 template<class OtherCmp>
833 void ReSort(TTransSet<OtherCmp>& res) const;
834
835 /**
836 * Get state set covered by transition set
837 *
838 * @return
839 * Set of state indices used by some transition
840 */
841 StateSet States(void) const;
842
843 /**
844 * Get set of successor states for specified current state
845 *
846 * @param x1
847 * Current state
848 *
849 * @return
850 * Set of state indices
851 */
853
854 /**
855 * Get set of successor states for specified current states
856 *
857 * @param rX1Set
858 * Current state
859 *
860 * @return
861 * Set of state indices
862 */
863 StateSet SuccessorStates(const StateSet& rX1Set) const;
864
865 /**
866 * Get set of successor states for specified current state and event
867 *
868 * @param x1
869 * Current state
870 * @param ev
871 * Event
872 *
873 * @return
874 * Set of state indices
875 */
877
878 /**
879 * Get set of successor states for specified current states and events
880 *
881 * @param rX1Set
882 * Current states
883 * @param rEvSet
884 * Events
885 *
886 * @return
887 * Set of state indices
888 */
889 StateSet SuccessorStates(const StateSet& rX1Set, const EventSet& rEvSet) const;
890
891
892 /**
893 * Get set of predecessor states for specified target state
894 * This function requires sorting TransSort::X2EvX1 or TransSort::X2X1Ev
895 *
896 * @param x2
897 * Target state
898 *
899 * @return
900 * Set of state indices
901 */
903
904
905 /**
906 * Get set of predecessor states for specified target states
907 * This function requires sorting TransSort::X2EvX1 or TransSort::X2X1Ev
908 *
909 * @param rX2Set
910 * Sarget states
911 *
912 * @return
913 * Set of state indices
914 */
915 StateSet PredecessorStates(const StateSet& rX2Set) const;
916
917 /**
918 * Get set of predecessor states for specified targetstate and event
919 * This function requires sorting TransSort::X2EvX1 or TransSort::X2X1Ev
920 *
921 * @param x2
922 * Target state
923 * @param ev
924 * Event
925 *
926 * @return
927 * Set of state indices
928 */
930
931 /**
932 * Get set of predecessor states for specified target states and events
933 * This function requires sorting TransSort::X2EvX1 or TransSort::X2X1Ev
934 *
935 * @param rX2Set
936 * Target states
937 * @param rEvSet
938 * Events
939 *
940 * @return
941 * Set of state indices
942 */
943 StateSet PredecessorStates(const StateSet& rX2Set, const EventSet& rEvSet) const;
944
945
946 /**
947 * Get set of events that are active for a specified current state
948 * Since a transition set does not refer to a SymbolTable, this function
949 * returns a set of plain indices. In order to interpret the set as an EventSet,
950 * the relevant SymbolTable must be supplied as second argument. If obmitting the second
951 * argument, the defult SymbolTable is used.
952 *
953 * @param x1
954 * Current state
955 * @param pSymTab
956 * SymbolTable to refer to
957 *
958 * @return
959 * Set of events.
960 */
961 EventSet ActiveEvents(Idx x1, SymbolTable* pSymTab=NULL) const;
962
963 /**
964 * Get set of events by which one can attend the specified successor state.
965 * This function requires sorting TransSort::X2EvX1 or TransSort::X2X1Ev
966 * Since a transition set does not refer to a SymbolTable, this function
967 * returns a set of plain indices. In order to interpret the set as an EventSet,
968 * the relevant SymbolTable must be supplied as second argument. If obmitting the second
969 * argument, the defult SymbolTable is used.
970 *
971 * @param x2
972 * Target state
973 * @param pSymTab
974 * SymbolTable to refer to
975 *
976 * @return
977 * Set of events.
978 */
979 EventSet IncommingEvents(Idx x2, SymbolTable* pSymTab=NULL) const;
980
981 /**
982 * Return pretty printable string representation.
983 * Primary meant for debugging messages.
984 *
985 * @param rTrans
986 * Transition to print
987 *
988 * @return
989 * String
990 */
991 virtual std::string Str(const Transition& rTrans) const;
992
993 /**
994 * Return pretty printable string representation.
995 * Primary meant for debugging messages.
996 *
997 * @return
998 * String
999 */
1000 virtual std::string Str(void) const;
1001
1002
1003 /** @} doxygen group */
1004
1005 protected:
1006
1007
1008 /**
1009 * Copy my members.
1010 *
1011 * @param rSource
1012 * Source to copy from
1013 */
1014 void DoCopy(const TTransSet& rSource);
1015
1016 /**
1017 * Copy my members.
1018 *
1019 * @param rSource
1020 * Source to copy from
1021 */
1022 void DoMove(TTransSet& rSource);
1023
1024 /**
1025 * Write to TokenWriter, see Type::Write for public wrappers.
1026 * This method writes index triplets only. See vGenerator methods
1027 * for symbolic names and attributes etc.
1028 *
1029 * @param rTw
1030 * Reference to TokenWriter
1031 * @param rLabel
1032 * Label of section to write, defaults to name of set
1033 * @param pContext
1034 * Write context eg symboltables
1035 *
1036 * @exception Exception
1037 * - IO errors (id 2)
1038 */
1039 virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
1040
1041 /**
1042 * Read from TokenReader, see Type::Read for public wrappers.
1043 * This method readsindex triplets only. See vGenerator methods
1044 * for symbolic names and attributes etc.
1045 *
1046 * @param rTr
1047 * Reference to TokenReader
1048 * @param rLabel
1049 * Label of section to read from, defaults to name of set
1050 * @param pContext
1051 * Read context eg symboltables (not used)
1052 *
1053 * @exception Exception
1054 * - IO errors (id 2)
1055 */
1056 virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
1057
1058
1059};
1060
1061/** Type definition for default sorted TTransSet */
1063
1064/** Type definition for default sorted TTransSet */
1066
1067/** Type definition for ev, x1, x2 sorted TTransSet */
1069
1070/** Type definition for ev, x2, x1 sorted TTransSet */
1072
1073/** Type definition for x2, ev, x1 sorted TTransSet */
1075
1076/** Type definition for x2, x1, ev sorted TTransSet */
1078
1079/** Type definition for x1, x2, ev sorted TTransSet */
1081
1082
1083/**
1084 * Set of Transitions with attributes.
1085 *
1086 * This container class is derived from TTransSet to provide attributes as an
1087 * additional feature. The template parameter specifies the attribute class,
1088 * which in turn must provide some basic funtionality. In contrast to the TTransSet, the TaTransSet
1089 * is restricted to standard ordering.
1090 *
1091 * Note that it is the context of a Generator that
1092 * actually allows to interpret a TaTransSet as a set of transitions as opposed to
1093 * a set of triples of indices with attributes. In particular, file IO of transitions is provided
1094 * by the generator class (although TaTransSet provides output functions for debugging)
1095 */
1096
1097
1098template <class Attr>
1099class FAUDES_TAPI TaTransSet : public TransSet, public TAttrMap<Transition,Attr,TransSort::X1EvX2> {
1100
1102
1103public:
1104
1105 using TransSet::operator=;
1106 using TransSet::operator==;
1107 using TransSet::operator!=;
1108
1109
1110 /** @name Constructors & Destructor */
1111 /** @{ doxygen group */
1112
1113 /** Construct an empty TaTransSet object */
1114 TaTransSet(void);
1115
1116 /**
1117 * Copy-constructor (incl attributes)
1118 */
1119 TaTransSet(const TaTransSet& rOtherSet);
1120
1121 /**
1122 * Copy-Constructor (set attributes to default)
1123 */
1124 TaTransSet(const TTransSet<TransSort::X1EvX2>& rOtherSet);
1125
1126 /** Virtual destructor */
1127 virtual ~TaTransSet() {}
1128
1129 /** Relaxed assignment method.
1130 *
1131 * Runtime typecheck for TransSet, maintains attributes provided they can be casted.
1132 *
1133 * @param rSrc
1134 * Source from which to assign
1135 * @return
1136 * Ref to this set
1137 */
1138 virtual TaTransSet& Copy(const TBaseSet<Transition,TransSort::X1EvX2>& rSrc);
1139
1140 /** Relaxed assignment operator.
1141 *
1142 * @param rSrc
1143 * Source from which to assign
1144 * @return
1145 * Ref to this set
1146 */
1147 virtual TaTransSet& operator=(const TransSet& rSrc) {return Copy(rSrc);}
1148
1149 /** @} doxygen group */
1150
1151
1152
1153 /** @name Accessing individual transitions */
1154 /** @{ doxygen group */
1155
1156 /** Iterator on transition */
1158
1159 /**
1160 * Add a Transition by indices
1161 *
1162 * @param x1
1163 * Predecessor state
1164 * @param ev
1165 * Event
1166 * @param x2
1167 * Successor state
1168 *
1169 * @return
1170 * True if the transition was new to the set
1171 */
1172 bool Insert(Idx x1, Idx ev, Idx x2);
1173
1174 /**
1175 * Add a Transition directly. If the transition already
1176 * exists, the attribute is maintained. Otherwise, the transition
1177 * is inserted with default attribute.
1178 *
1179 * @param rTransition
1180 * Reference to transition object
1181 *
1182 * @return
1183 * True if the transition was new to the set
1184 */
1185 bool Insert(const Transition& rTransition);
1186
1187 /**
1188 * Add a Transition with attribute.
1189 *
1190 * @param rTransition
1191 * Reference to transition object
1192 * @param rAttr
1193 * Reference to attribute
1194 *
1195 * @return
1196 * True if the transition was new to the set
1197 */
1198 bool Insert(const Transition& rTransition, const Attr& rAttr);
1199
1200 /**
1201 * Inserts elements of rOtherSet.
1202 *
1203 * Attributes of this set are maintained, newly inserted elements attain the
1204 * attribute from rOtherSet if it can be casted appropriately.
1205 *
1206 *
1207 * @param rOtherSet
1208 * Other IndexSet
1209 */
1210 virtual void InsertSet(const TransSet& rOtherSet);
1211
1212 /**
1213 * Inserts elements of rOtherSet.
1214 *
1215 * This variant uses a runtime cast to access attributes.
1216 *
1217 * @param rOtherSet
1218 * Other IndexSet
1219 * @exception Exception
1220 * - cast failed (id 67)
1221 */
1222 virtual void InsertSet(const TBaseSet<Transition,TransSort::X1EvX2>& rOtherSet);
1223
1224 /**
1225 * Remove a Transition
1226 *
1227 * @return
1228 * True if transition did exist
1229 */
1230 bool Erase(const Transition& t);
1231
1232 /**
1233 * Remove a Transition
1234 *
1235 * @return
1236 * True if transition did exist
1237 */
1238 bool Erase(Idx x1, Idx ev, Idx x2);
1239
1240 /**
1241 * Remove a Transition by iterator
1242 *
1243 * @return
1244 * Iterator to next transition
1245 */
1246 Iterator Erase(const Iterator& it);
1247
1248 /**
1249 * Inserts elements of rOtherSet.
1250 *
1251 * Attributes of this set are maintained.
1252 *
1253 *
1254 * @param rOtherSet
1255 * Other IndexSet
1256 */
1257 virtual void EraseSet(const TransSet& rOtherSet);
1258
1259 /**
1260 * Inserts elements of rOtherSet.
1261 *
1262 * This variant uses a runtime cast to access attributes.
1263 *
1264 * @param rOtherSet
1265 * Other IndexSet
1266 * @exception Exception
1267 * - cast failed (id 67)
1268 */
1269 virtual void EraseSet(const TBaseSet<Transition,TransSort::X1EvX2>& rOtherSet);
1270
1271
1272 /**
1273 * Restrict to specified subset.
1274 *
1275 * Erases any elements no in the specified set. This function
1276 * ignores the attributes of the other set and maintains the attributes
1277 * of the remaining elements in this set.
1278 *
1279 * @param rOtherSet
1280 * Elements to erase
1281 */
1282 void RestrictSet(const TransSet& rOtherSet);
1283
1284
1285 /**
1286 * Restrict to specified subset.
1287 *
1288 * This variant uses a runtime cast to access attributes.
1289 *
1290 * @param rOtherSet
1291 * Elements to erase
1292 */
1293 void RestrictSet(const TBaseSet<Transition,TransSort::X1EvX2>& rOtherSet);
1294
1295
1296
1297
1298 /** resolve ambiguities from attribute interface ("using" wont do the job) */
1301 const Attr& Attribute(const Transition& rElem) const { return TAttrMap<Transition,Attr,TransSort::X1EvX2>::Attribute(rElem); };
1302 void Attribute(const Transition& rElem, const Attr& rAttr) { return TAttrMap<Transition,Attr,TransSort::X1EvX2>::Attribute(rElem,rAttr); };
1303 void Attribute(const Transition& rElem, const Type& rAttr) { return TAttrMap<Transition,Attr,TransSort::X1EvX2>::Attribute(rElem,rAttr); };
1304 void AttributeTry(const Transition& rElem, const Type& rAttr) { return TAttrMap<Transition,Attr,TransSort::X1EvX2>::AttributeTry(rElem,rAttr); };
1305
1306
1307 /** @} doxygen group */
1308
1309
1310 protected:
1311
1312 /**
1313 * Copy my members. Maintain attributes.
1314 *
1315 * @param rSource
1316 * Source to copy from
1317 */
1318 void DoCopy(const TaTransSet& rSource);
1319
1320
1321 /**
1322 * Move my members. Maintain attributes.
1323 *
1324 * @param rSource
1325 * Source to copy from
1326 */
1327 void DoMove(TaTransSet& rSource);
1328
1329};
1330
1331
1332
1333/**
1334 * Apply relable map to nameset
1335 *
1336 * This implementation tries to keep the attributes from the
1337 * domain elements.
1338 *
1339 * @param rMap
1340 * map to apply
1341 * @param rSet
1342 * set to apply the map to
1343 * @param rRes
1344 * relabled set
1345 * @exceptions
1346 * - symboltable must match
1347 */
1348extern FAUDES_API void ApplyRelabelMap(const RelabelMap& rMap, const TransSet& rSet, TransSet& rRes);
1349
1350
1351/** @} doxygen group*/
1352
1353
1354/*
1355*************************************************************************************************
1356*************************************************************************************************
1357* Implementation of transset without attributes
1358*************************************************************************************************
1359*************************************************************************************************
1360*/
1361
1362
1363/* convenience access to relevant scopes */
1364#define THIS TTransSet<Cmp>
1365#define TEMP template<class Cmp>
1366#define BASE TBaseSet<Transition,Cmp>
1367
1368// std faudes type
1370
1371// TTransSet(void)
1373{
1374 FD_DC("TTransSet(" << this << ")::TTransSet()");
1375}
1376
1377// TTransSet(othertransrel)
1378//TEMP THIS::TTransSet(const TBaseSet<Transition,Cmp>& rOtherSet) :
1379 TEMP THIS::TTransSet(const TTransSet<Cmp>& rOtherSet) :
1380 BASE()
1381{
1382 FD_DC("TTransSet(" << this << ")::TTransSet(rOtherSet "<< &rOtherSet <<")");
1383 Copy(rOtherSet);
1384}
1385
1386// TTransSet(othertransrel othersort)
1387TEMP template<class OtherCmp>
1388THIS::TTransSet(const TTransSet<OtherCmp>& rOtherSet) :
1389 BASE()
1390{
1391 FD_DC("TTransSet(" << this << ")::TTransSet(rOtherSet/ReSort "<< &rOtherSet <<")");
1392 rOtherSet.ReSort(*this);
1393}
1394
1395// assignment (maintain attributes)
1396TEMP void THIS::DoCopy(const TTransSet& rSourceSet) {
1397 FD_DC("TTransSet(" << this << ")::DoCopy(..)");
1398 // call base (incl attributes if they have identical type)
1399 BASE::DoCopy(rSourceSet);
1400}
1401
1402// assignment (maintain attributes)
1403TEMP void THIS::DoMove(TTransSet& rSourceSet) {
1404 FD_DC("TTransSet(" << this << ")::DoMove(..): not implemented");
1405 // call base (incl attributes if they have identical type)
1406 BASE::DoMove(rSourceSet);
1407}
1408
1409// iterator Begin() const
1410TEMP typename THIS::Iterator THIS::Begin(void) const {
1411 return BASE::Begin();
1412}
1413
1414// iterator End() const
1415TEMP typename THIS::Iterator THIS::End(void) const {
1416 return BASE::End();
1417}
1418
1419
1420// Convenience macro for order typecheck
1421#define SORT_EXCEPTION { std::stringstream errstr; \
1422 errstr << "Transition set order mismatch " << std::endl; \
1423 throw Exception("TransSet::Iterator()", errstr.str(), 68); }
1424
1425
1426// iterator Begin(x1) const
1427TEMP typename THIS::Iterator THIS::Begin(Idx x1) const {
1428#ifdef FAUDES_CHECKED
1429 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1430 if(typeid(Cmp)!=typeid(TransSort::X1X2Ev))
1432#endif
1433 Transition tlx(x1,0,0);
1434 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1435}
1436
1437// iterator End(x1) const
1438TEMP typename THIS::Iterator THIS::End(Idx x1) const {
1439#ifdef FAUDES_CHECKED
1440 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1441 if(typeid(Cmp)!=typeid(TransSort::X1X2Ev))
1443#endif
1444 Transition tlx(x1+1,0,0);
1445 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1446}
1447
1448// iterator Begin(x1,ev) const
1449TEMP typename THIS::Iterator THIS::Begin(Idx x1, Idx ev) const {
1450#ifdef FAUDES_CHECKED
1451 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1453#endif
1454 Transition tlx(x1,ev,0);
1455 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1456}
1457
1458// iterator End(x1,ev) const
1459TEMP typename THIS::Iterator THIS::End(Idx x1, Idx ev) const {
1460#ifdef FAUDES_CHECKED
1461 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1463#endif
1464 Transition tlx(x1,ev+1, 0);
1465 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1466}
1467
1468// iterator BeginByEv(ev) const
1469TEMP typename THIS::Iterator THIS::BeginByEv(Idx ev) const {
1470#ifdef FAUDES_CHECKED
1471 if(typeid(Cmp)!=typeid(TransSort::EvX1X2))
1472 if(typeid(Cmp)!=typeid(TransSort::EvX2X1))
1474#endif
1475 Transition tlx(0,ev,0);
1476 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1477}
1478
1479// iterator EndByEv(ev) const
1480TEMP typename THIS::Iterator THIS::EndByEv(Idx ev) const {
1481#ifdef FAUDES_CHECKED
1482 if(typeid(Cmp)!=typeid(TransSort::EvX1X2))
1483 if(typeid(Cmp)!=typeid(TransSort::EvX2X1))
1485#endif
1486 Transition tlx(0,ev+1,0);
1487 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1488}
1489
1490// iterator BeginByEvX1(ev,x1) const
1491TEMP typename THIS::Iterator THIS::BeginByEvX1(Idx ev, Idx x1) const {
1492#ifdef FAUDES_CHECKED
1493 if(typeid(Cmp)!=typeid(TransSort::EvX1X2))
1495#endif
1496 Transition tlx(x1,ev,0);
1497 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1498}
1499
1500// iterator EndByEvX1(ev,x1) const
1501TEMP typename THIS::Iterator THIS::EndByEvX1(Idx ev, Idx x1) const {
1502#ifdef FAUDES_CHECKED
1503 if(typeid(Cmp)!=typeid(TransSort::EvX1X2))
1505#endif
1506 Transition tlx(x1+1,ev,0);
1507 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1508}
1509
1510// iterator BeginByEvX2(ev,x2) const
1511TEMP typename THIS::Iterator THIS::BeginByEvX2(Idx ev, Idx x2) const {
1512#ifdef FAUDES_CHECKED
1513 if(typeid(Cmp)!=typeid(TransSort::EvX2X1))
1515#endif
1516 Transition tlx(0,ev,x2);
1517 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1518}
1519
1520// iterator EndByEvX2(ev,x2) const
1521TEMP typename THIS::Iterator THIS::EndByEvX2(Idx ev, Idx x2) const {
1522#ifdef FAUDES_CHECKED
1523 if(typeid(Cmp)!=typeid(TransSort::EvX2X1))
1525#endif
1526 Transition tlx(0,ev,x2+1);
1527 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1528}
1529
1530// iterator BeginByX2(x2) const
1531TEMP typename THIS::Iterator THIS::BeginByX2(Idx x2) const {
1532#ifdef FAUDES_CHECKED
1533 if(typeid(Cmp)!=typeid(TransSort::X2EvX1))
1534 if(typeid(Cmp)!=typeid(TransSort::X2X1Ev))
1536#endif
1537 Transition tlx(0,0,x2);
1538 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1539}
1540
1541// iterator EndByX2(x2) const
1542TEMP typename THIS::Iterator THIS::EndByX2(Idx x2) const {
1543#ifdef FAUDES_CHECKED
1544 if(typeid(Cmp)!=typeid(TransSort::X2EvX1))
1545 if(typeid(Cmp)!=typeid(TransSort::X2X1Ev))
1547#endif
1548 Transition tlx(0,0,x2+1);
1549 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1550}
1551
1552// iterator BeginByX2Ev(x2,ev) const
1553TEMP typename THIS::Iterator THIS::BeginByX2Ev(Idx x2, Idx ev) const {
1554#ifdef FAUDES_CHECKED
1555 if(typeid(Cmp)!=typeid(TransSort::X2EvX1))
1557#endif
1558 Transition tlx(0,ev,x2);
1559 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1560}
1561
1562// iterator EndByX2Ev(x2,ev) const
1563TEMP typename THIS::Iterator THIS::EndByX2Ev(Idx x2, Idx ev) const {
1564#ifdef FAUDES_CHECKED
1565 if(typeid(Cmp)!=typeid(TransSort::X2EvX1))
1567#endif
1568 Transition tlx(0,ev+1,x2);
1569 return THIS::ThisIterator(BASE::pSet->lower_bound(tlx));
1570}
1571
1572// operator+
1573TEMP THIS THIS::operator+ (const TTransSet<Cmp>& rOtherSet) const {
1574 TTransSet<Cmp> res(*this);
1575 res.InsertSet(rOtherSet);
1576 return res;
1577}
1578
1579// operator-
1580TEMP THIS THIS::operator- (const TTransSet<Cmp>& rOtherSet) const {
1581 TTransSet<Cmp> res(*this);
1582 res.EraseSet(rOtherSet);
1583 return res;
1584}
1585
1586
1587// operator*
1588TEMP TTransSet<Cmp> THIS::operator* (const TTransSet<Cmp>& rOtherSet) const {
1589 TTransSet<Cmp> res(*this);
1590 res.RestrictSet(rOtherSet);
1591 return res;
1592}
1593
1594
1595// DoWrite(rw,label)
1596TEMP void THIS::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const
1597{
1598 (void) pContext;
1599 std::string label=rLabel;
1600 if(label=="") label=BASE::Name();
1601 rTw.WriteBegin(label);
1602 int oldcolumns = rTw.Columns();
1603 rTw.Columns(3);
1604
1605 Iterator tit;
1606 for (tit = Begin(); tit != End(); ++tit) {
1607 rTw << tit->X1; rTw << tit->Ev; rTw << tit->X2;
1608 }
1609
1610 rTw.WriteEnd(label);
1611 rTw.Columns(oldcolumns);
1612}
1613
1614
1615// DoRead(rw,label)
1616TEMP void THIS::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
1617 (void) pContext;
1618 // set up defaults
1619 std::string label=rLabel;
1620 std::string ftype=BASE::TypeName();
1621 // figure section
1622 Token token;
1623 if(label=="") {
1624 rTr.Peek(token);
1625 if(token.Type()==Token::Begin) label=token.StringValue();
1626 }
1627 if(label=="") label=ftype;
1628 BASE::Name(label);
1629 // read begin
1630 rTr.ReadBegin(label,token);
1631 if(token.ExistsAttributeString("name"))
1632 BASE::Name(token.AttributeStringValue("name"));
1633 FD_DC("TransSet(" << typeid(*this).name() << ")::DoRead(..): section " << label << " elements " << etstr);
1634 // loop tokens
1635 while(!rTr.Eos(label)) {
1636 // peek to skip
1637 Token token;
1638 rTr.Peek(token);
1639 if(token.Type()==Token::Begin) {
1640 std::string skip=token.StringValue();
1641 rTr.ReadBegin(skip);
1642 rTr.ReadEnd(skip);
1643 continue;
1644 }
1645 // error on non idx
1646 if(token.Type()!=Token::Integer) {
1647 std::stringstream errstr;
1648 errstr << "Reading TransRel failed in " << rTr.FileLine() << ": invalid token " << token.Str();
1649 throw Exception("TransRel::DoRead", errstr.str(), 50);
1650 }
1651 // read index triplets
1652 Idx x1=rTr.ReadInteger();
1653 Idx ev=rTr.ReadInteger();
1654 Idx x2=rTr.ReadInteger();
1655 // set transition
1656 Insert(x1,ev,x2);
1657 }
1658 // read end token
1659 rTr.ReadEnd(label);
1660
1661 // done
1662 FD_DC("TransRel(" << this << ")::DoRead(\"" << rTr.FileName() << "\"): done");
1663}
1664
1665
1666// Insert(transition)
1667TEMP bool THIS::Insert(const Transition& t) {
1668 return BASE::Insert(t);
1669}
1670
1671// Insert(x1,ev,x2)
1672TEMP bool THIS::Insert(Idx x1, Idx ev, Idx x2) {
1673 FD_DC("TTransSet(" << this << ")::Insert(" << x1 << "-" << ev << "-" << x2 << ")");
1674 return BASE::Insert(Transition(x1, ev, x2));
1675}
1676
1677// Inject(transition)
1678TEMP typename THIS::Iterator THIS::Inject(const Iterator& pos, const Transition& t) {
1679 return BASE::Inject(pos,t);
1680}
1681
1682// Inject(transition)
1683TEMP void THIS::Inject(const Transition& t) {
1684 BASE::Inject(t);
1685}
1686
1687
1688// Erase(transition)
1689TEMP bool THIS::Erase(const Transition& t) {
1690 FD_DC("TTransSet(" << this << ")::Erase(" << t.Str() << " [t])");
1691 return BASE::Erase(t);
1692}
1693
1694// Erase(x1,ev,x2)
1695TEMP bool THIS::Erase(Idx x1, Idx ev, Idx x2) {
1696 FD_DC("TTransSet(" << this << ")::Erase(" << x1 << "-" << ev << "-" << x2 << ")");
1697 return BASE::Erase(Transition(x1, ev, x2));
1698}
1699
1700// Erase(it)
1701TEMP typename THIS::Iterator THIS::Erase(const Iterator& it) {
1702 FD_DC("TTransSet(" << this << ")::Erase(" << this->EStr(*it) << " [it])");
1703 return BASE::Erase(it);
1704}
1705
1706// EraseByX1(x)
1707TEMP void THIS::EraseByX1(Idx x1) {
1708 FD_DC("TTransSet(" << this << ")::EraseByX1(" << x1 << ")");
1709#ifdef FAUDES_CHECKED
1710 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1711 if(typeid(Cmp)!=typeid(TransSort::X1X2Ev))
1713#endif
1714 this->Detach();
1715 typename BASE::iterator lower, upper, it;
1716 Transition tl(x1,0,0);
1717 Transition tu(x1+1,0,0);
1718 lower = BASE::pSet->lower_bound(tl);
1719 upper = BASE::pSet->upper_bound(tu);
1720 if(this->AttributesSize()!=0)
1721 for(it=lower; it!=upper; ++it)
1722 BASE::ClrAttribute(*it);
1723 BASE::pSet->erase(lower, upper);
1724}
1725
1726// EraseByX1Ev(x,e)
1727TEMP void THIS::EraseByX1Ev(Idx x1, Idx ev) {
1728 FD_DC("TTransSet(" << this << ")::EraseByX1Ev(" << x1 << "," << ev << ")");
1729#ifdef FAUDES_CHECKED
1730 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1732#endif
1733 this->Detach();
1734 typename BASE::iterator lower, upper, it;
1735 Transition tl(x1,ev,0);
1736 Transition tu(x1,ev+1,0);
1737 lower = BASE::pSet->lower_bound(tl);
1738 upper = BASE::pSet->upper_bound(tu);
1739 if(this->AttributesSize()!=0)
1740 for(it=lower; it!=upper; ++it)
1741 BASE::ClrAttribute(*it);
1742 BASE::pSet->erase(lower, upper);
1743}
1744
1745// EraseByX2(x)
1746TEMP void THIS::EraseByX2(Idx x2) {
1747 FD_DC("TTransSet(" << this << ")::EraseByX2(" << x2 << ")");
1748 this->Detach();
1749 bool doattr = (this->AttributesSize()!=0);
1750 typename BASE::iterator it;
1751 for(it = BASE::pSet->begin(); it != BASE::pSet->end();) {
1752 if(it->X2 == x2) {
1753 if(doattr) BASE::ClrAttribute(*it);
1754 BASE::pSet->erase(it++);
1755 continue;
1756 }
1757 it++;
1758 }
1759}
1760
1761// EraseByEv(ev)
1762TEMP void THIS::EraseByEv(Idx ev) {
1763 FD_DC("TTransSet(" << this << ")::EraseByEv(" << ev << ")");
1764 this->Detach();
1765 bool doattr = (this->AttributesSize()!=0);
1766 typename BASE::iterator it;
1767 for(it = BASE::pSet->begin(); it != BASE::pSet->end();) {
1768 if (it->Ev == ev) {
1769 if(doattr) BASE::ClrAttribute(*it);
1770 BASE::pSet->erase(it++);
1771 continue;
1772 }
1773 it++;
1774 }
1775}
1776
1777
1778// EraseByX1OrX2(x)
1779TEMP void THIS::EraseByX1OrX2(Idx x) {
1780 FD_DC("TTransSet(" << this << ")::EraseByX1OrX2(" << x << ")");
1781 this->Detach();
1782 bool doattr = (this->AttributesSize()!=0);
1783 typename BASE::iterator it;
1784 for(it = BASE::pSet->begin(); it != BASE::pSet->end();) {
1785 if ((it->X1 == x) || (it->X2 == x)) {
1786 if(doattr) BASE::ClrAttribute(*it);
1787 BASE::pSet->erase(it++);
1788 continue;
1789 }
1790 it++;
1791 }
1792 FD_DC("TTransSet(" << this << ")::EraseByX1OrX2(" << x << "): done");
1793}
1794
1795
1796// EraseByX1OrX2(xset)
1797TEMP void THIS::EraseByX1OrX2(const StateSet& rStates) {
1798 FD_DC("TTransSet(" << this << ")::EraseByX1OrX2(#" << rStates.Size() <<")");
1799 this->Detach();
1800 bool doattr = (this->AttributesSize()!=0);
1801 typename BASE::iterator it=BASE::pSet->begin();
1802 while(it != BASE::pSet->end()) {
1803 if(!rStates.Exists(it->X1) && !rStates.Exists(it->X2)) { ++it; continue;}
1804 if(doattr) BASE::ClrAttribute(*it);
1805 BASE::pSet->erase(it++);
1806 }
1807 FD_DC("TTransSet(" << this << ")::EraseByX1OrX2(): done");
1808}
1809
1810
1811// RestrictStates(xset)
1812TEMP void THIS::RestrictStates(const StateSet& rStates) {
1813 FD_DC("TTransSet(" << this << ")::RestrictByX1AndX2(#" << rStates.Size() <<")");
1814 this->Detach();
1815 bool doattr = (this->AttributesSize()!=0);
1816 typename BASE::iterator it;
1817 it = BASE::pSet->begin();
1818 while(it != BASE::pSet->end()) {
1819 if(rStates.Exists(it->X1) && rStates.Exists(it->X2)) { ++it; continue;}
1820 if(doattr) BASE::ClrAttribute(*it);
1821 BASE::pSet->erase(it++);
1822 }
1823 FD_DC("TTransSet(" << this << ")::EraseByX1OrX2(): done");
1824}
1825
1826
1827// RestrictEvents(eset)
1828TEMP void THIS::RestrictEvents(const EventSet& rEvents) {
1829 FD_DC("TTransSet(" << this << ")::RestrictEvents(#" << rEvents.Size() <<")");
1830 this->Detach();
1831 bool doattr = (this->AttributesSize()!=0);
1832 typename BASE::iterator it;
1833 it = BASE::pSet->begin();
1834 while(it != BASE::pSet->end()) {
1835 if(rEvents.Exists(it->Ev)) { ++it; continue;}
1836 if(doattr) BASE::ClrAttribute(*it);
1837 BASE::pSet->erase(it++);
1838 }
1839 FD_DC("TTransSet(" << this << ")::RestrictEvents(): done");
1840}
1841
1842
1843// iterator Find(x1,ev,x2)
1844TEMP typename THIS::Iterator THIS::Find(Idx x1, Idx ev, Idx x2) const {
1845 return BASE::Find(Transition(x1,ev,x2));
1846}
1847
1848
1849// iterator Find(t)
1850TEMP typename THIS::Iterator THIS::Find(const Transition& t) const{
1851 return BASE::Find(t);
1852}
1853
1854// Exists(t)
1855TEMP bool THIS::Exists(const Transition& t) const {
1856 return BASE::Exists(t);
1857}
1858
1859// Exists(x1, ev, x2)
1860TEMP bool THIS::Exists(Idx x1, Idx ev, Idx x2) const {
1861 return BASE::Exists(Transition(x1,ev,x2));
1862}
1863
1864// Exists(x)
1865TEMP bool THIS::ExistsByX1OrX2(Idx x) const {
1866 typename BASE::iterator it;
1867 for(it = BASE::pSet->begin(); it != BASE::pSet->end(); ++it) {
1868 if ((it->X1 == x) || (it->X2 == x)) {
1869 return true;
1870 }
1871 }
1872 return false;
1873}
1874
1875// ExistsByX1Ev(x,e)
1876TEMP bool THIS::ExistsByX1Ev(Idx x1, Idx ev) const {
1877 FD_DC("TTransSet(" << this << ")::ExistsByX1Ev(" << x1 << "," << ev << ")");
1878#ifdef FAUDES_CHECKED
1879 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1881#endif
1882 this->Detach();
1883 typename BASE::iterator lower, upper, it;
1884 Transition tl(x1,ev,0);
1885 Transition tu(x1,ev+1,0);
1886 lower = BASE::pSet->lower_bound(tl);
1887 upper = BASE::pSet->upper_bound(tu);
1888 return lower != upper;
1889}
1890
1891// ExistsByX1(x)
1892TEMP bool THIS::ExistsByX1(Idx x1) const {
1893 FD_DC("TTransSet(" << this << ")::ExistsByX1(" << x1 << ")");
1894#ifdef FAUDES_CHECKED
1895 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1896 if(typeid(Cmp)!=typeid(TransSort::X1X2Ev))
1898#endif
1899 this->Detach();
1900 typename BASE::iterator lower, upper, it;
1901 Transition tl(x1,0,0);
1902 Transition tu(x1+1,0,0);
1903 lower = BASE::pSet->lower_bound(tl);
1904 upper = BASE::pSet->upper_bound(tu);
1905 return lower != upper;
1906}
1907
1908
1909// ReSort(res)
1910TEMP template<class OtherCmp>
1911void THIS::ReSort(TTransSet<OtherCmp>& res) const {
1912 Iterator it;
1913 res.Clear();
1914 for (it = Begin(); it != End(); ++it) {
1915 res.Insert(*it);
1916 }
1917}
1918
1919// States()
1920TEMP StateSet THIS::States(void) const {
1921 StateSet states;
1922 Iterator it;
1923 for (it=Begin(); it!=End(); ++it) {
1924 states.Insert(it->X1);
1925 states.Insert(it->X2);
1926 }
1927 return states;
1928}
1929
1930// SuccessorStates(x1)
1931TEMP StateSet THIS::SuccessorStates(Idx x1) const {
1932#ifdef FAUDES_CHECKED
1933 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1934 if(typeid(Cmp)!=typeid(TransSort::X1X2Ev))
1936#endif
1937 StateSet states;
1938 Iterator it = Begin(x1);
1939 Iterator it_end = End(x1);
1940 while (it != it_end) {
1941 states.Insert(it->X2);
1942 ++it;
1943 }
1944 return states;
1945}
1946
1947// SuccessorStates(x1set)
1948TEMP StateSet THIS::SuccessorStates(const StateSet& rX1Set) const {
1949#ifdef FAUDES_CHECKED
1950 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1951 if(typeid(Cmp)!=typeid(TransSort::X1X2Ev))
1953#endif
1954 StateSet states;
1955 StateSet::Iterator sit= rX1Set.Begin();
1956 StateSet::Iterator sit_end= rX1Set.End();
1957 for(;sit!=sit_end; ++sit) {
1958 Iterator tit = Begin(*sit);
1959 Iterator tit_end = End(*sit);
1960 while(tit!=tit_end) {
1961 states.Insert(tit->X2);
1962 ++tit;
1963 }
1964 }
1965 return states;
1966}
1967
1968// SuccessorStates(x1, ev)
1969TEMP StateSet THIS::SuccessorStates(Idx x1, Idx ev) const {
1970#ifdef FAUDES_CHECKED
1971 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1973#endif
1974 StateSet states;
1975 Iterator it = Begin(x1, ev);
1976 Iterator it_end = End(x1, ev);
1977 while (it != it_end) {
1978 states.Insert(it->X2);
1979 ++it;
1980 }
1981 return states;
1982}
1983
1984// SuccessorStates(x1set, evset)
1985TEMP StateSet THIS::SuccessorStates(const StateSet& rX1Set, const EventSet& rEvSet) const {
1986#ifdef FAUDES_CHECKED
1987 if(typeid(Cmp)!=typeid(TransSort::X1EvX2))
1989#endif
1990 StateSet states;
1991 if(rEvSet.Empty()) return states;
1992 StateSet::Iterator sit= rX1Set.Begin();
1993 StateSet::Iterator sit_end= rX1Set.End();
1994 for(;sit!=sit_end; ++sit) {
1995 EventSet::Iterator eit= rEvSet.Begin();
1996 EventSet::Iterator eit_end= rEvSet.End();
1997 Iterator tit = Begin(*sit,*eit);
1998 Iterator tit_end = End(*sit);
1999 while(tit!=tit_end) {
2000 // match
2001 if(tit->Ev == *eit) {
2002 states.Insert(tit->X2);
2003 ++tit;
2004 continue;
2005 }
2006 // tit behind
2007 if(tit->Ev < *eit) {
2008 ++tit;
2009 continue;
2010 }
2011 // tit upfront
2012 ++eit;
2013 if(eit==eit_end) break;
2014 }
2015 }
2016 return states;
2017}
2018
2019// PredecessorStates(x2)
2020TEMP StateSet THIS::PredecessorStates(Idx x2) const {
2021#ifdef FAUDES_CHECKED
2022 if(typeid(Cmp)!=typeid(TransSort::X2EvX1))
2023 if(typeid(Cmp)!=typeid(TransSort::X2X1Ev))
2025#endif
2026 StateSet states;
2027 Iterator it = BeginByX2(x2);
2028 Iterator it_end = EndByX2(x2);
2029 while (it != it_end) {
2030 states.Insert(it->X1);
2031 ++it;
2032 }
2033 return states;
2034}
2035
2036
2037// PredecessorStates(x2set)
2038TEMP StateSet THIS::PredecessorStates(const StateSet& rX2Set) const {
2039#ifdef FAUDES_CHECKED
2040 if(typeid(Cmp)!=typeid(TransSort::X2EvX1))
2041 if(typeid(Cmp)!=typeid(TransSort::X2X1Ev))
2043#endif
2044 StateSet states;
2045 StateSet::Iterator sit= rX2Set.Begin();
2046 StateSet::Iterator sit_end= rX2Set.End();
2047 for(;sit!=sit_end; ++sit) {
2048 Iterator tit = BeginByX2(*sit);
2049 Iterator tit_end = EndByX2(*sit);
2050 while(tit!=tit_end) {
2051 states.Insert(tit->X1);
2052 ++tit;
2053 }
2054 }
2055 return states;
2056}
2057
2058// PredecessorStates(x2, ev)
2059TEMP StateSet THIS::PredecessorStates(Idx x2, Idx ev) const {
2060#ifdef FAUDES_CHECKED
2061 if(typeid(Cmp)!=typeid(TransSort::X2EvX1))
2063#endif
2064 StateSet states;
2065 Iterator it = BeginByX2Ev(x2, ev);
2066 Iterator it_end = EndByX2Ev(x2, ev);
2067 while (it != it_end) {
2068 states.Insert(it->X1);
2069 ++it;
2070 }
2071 return states;
2072}
2073
2074// PredecessorStates(x2set, evset)
2075TEMP StateSet THIS::PredecessorStates(const StateSet& rX2Set, const EventSet& rEvSet) const {
2076#ifdef FAUDES_CHECKED
2077 if(typeid(Cmp)!=typeid(TransSort::X2EvX1))
2079#endif
2080 StateSet states;
2081 if(rEvSet.Empty()) return states;
2082 StateSet::Iterator sit= rX2Set.Begin();
2083 StateSet::Iterator sit_end= rX2Set.End();
2084 for(;sit!=sit_end; ++sit) {
2085 EventSet::Iterator eit= rEvSet.Begin();
2086 EventSet::Iterator eit_end= rEvSet.End();
2087 Iterator tit = BeginByX2Ev(*sit,*eit);
2088 Iterator tit_end = EndByX2(*sit);
2089 while(tit!=tit_end) {
2090 // match
2091 if(tit->Ev == *eit) {
2092 states.Insert(tit->X1);
2093 ++tit;
2094 continue;
2095 }
2096 // tit behind
2097 if(tit->Ev < *eit) {
2098 ++tit;
2099 continue;
2100 }
2101 // tit upfront
2102 ++eit;
2103 if(eit==eit_end) break;
2104 }
2105 }
2106 return states;
2107}
2108
2109
2110// ActiveEvents(x1,pSymTab)
2111TEMP EventSet THIS::ActiveEvents(Idx x1, SymbolTable* pSymTab) const {
2112 Iterator it = Begin(x1);
2113 Iterator it_end = End(x1);
2114 EventSet result;
2115 if(pSymTab!=NULL) result.SymbolTablep(pSymTab);
2116 for (; it != it_end; ++it) {
2117 result.Insert(it->Ev);
2118 }
2119 return result;
2120}
2121
2122// IncommingEvents(x2,pSymTab)
2123TEMP EventSet THIS::IncommingEvents(Idx x2, SymbolTable* pSymTab) const {
2124 Iterator it = BeginByX2(x2);
2125 Iterator it_end = EndByX2(x2);
2126 EventSet result;
2127 if(pSymTab!=NULL) result.SymbolTablep(pSymTab);
2128 for (; it != it_end; ++it) {
2129 result.Insert(it->Ev);
2130 }
2131 return result;
2132}
2133
2134// Pretty printable string
2135TEMP std::string THIS::Str(const Transition& rTrans) const {
2136 return rTrans.Str();
2137}
2138
2139// Pretty printable string
2140TEMP std::string THIS::Str(void) const {
2141 std::stringstream str;
2142 str << "[" << THIS::Name() << "]" << std::endl;
2143 Iterator eit=Begin();
2144 Iterator eit_end=End();
2145 if(THIS::Size()>0) while(true) {
2146 str << Str(*(eit++));
2147 if(eit==eit_end) break;
2148 str << std::endl;
2149 }
2150 return str.str();
2151}
2152
2153
2154
2155#undef THIS
2156#undef TEMP
2157#undef BASE
2158
2159/*
2160*************************************************************************************************
2161*************************************************************************************************
2162* Implementation of transset with attributes
2163*************************************************************************************************
2164*************************************************************************************************
2165*/
2166
2167
2168/* convenience access to relevant scopes */
2169#define THIS TaTransSet<Attr>
2170#define TEMP template <class Attr>
2171#define BASE TTransSet<TransSort::X1EvX2>
2172#define ABASE TAttrMap<Transition,Attr,TransSort::X1EvX2>
2173
2174// std faudes type
2176
2177// TaTransSet(void)
2179 BASE(),
2180 ABASE(this)
2181{
2182 FD_DC("TaTransSet(" << this << ")::TaTransSet()");
2183}
2184
2185// TaTransSet(othertransrel)
2186TEMP THIS::TaTransSet(const TaTransSet& rOtherSet) :
2187 BASE(),
2188 ABASE(this)
2189{
2190 FD_DC("TaTransSet(" << this << ")::TaTransSet(rOtherSet "<< &rOtherSet <<")");
2191 DoCopy(rOtherSet);
2192}
2193
2194
2195// TaTransSet(othertransrel)
2196TEMP THIS::TaTransSet(const BASE& rOtherSet) :
2197 BASE(),
2198 ABASE(this)
2199{
2200 FD_DC("TaTransSet(" << this << ")::TaTransSet(rOtherSet "<< &rOtherSet <<")");
2201 Copy(rOtherSet);
2202}
2203
2204
2205// copy to known same attributes
2206TEMP void THIS::DoCopy(const THIS& rSourceSet) {
2207 // call base incl attributes
2208 BASE::DoCopy(rSourceSet);
2209}
2210
2211// move to known same attributes
2212TEMP void THIS::DoMove(THIS& rSourceSet) {
2213 FD_WARN("TaTransSet(" << this << ")::DoMove(" << &rSourceSet<<"): fallback to DoCopy");
2214 // call base incl attributes
2215 BASE::DoCopy(rSourceSet);
2216}
2217
2218// Relaxed Copy()
2219TEMP THIS& THIS::Copy(const TBaseSet<Transition,TransSort::X1EvX2>& rSourceSet) {
2220 FD_DC("TaTransSet(" << this << ")::Copy([v] " << &rSourceSet<<")");
2221#ifdef FAUDES_CHECKED
2222 FD_DC("TaTransSet(" << this << ")::Copy(): src at " << &rSourceSet);
2223 FD_DC("TaTransSet(" << this << ")::Copy(): src type " << typeid(rSourceSet).name());
2224 FD_DC("TaTransSet(" << this << ")::Copy(): dst type " << typeid(*this).name());
2225 const TransSet* tset = dynamic_cast<const TransSet*>(&rSourceSet);
2226 if(!tset) {
2227 std::stringstream errstr;
2228 errstr << "cannot cast " << typeid(rSourceSet).name() << " to TransSet" << std::endl;
2229 throw Exception("TaTransSet::Copy", errstr.str(), 67);
2230 }
2231#endif
2232 // call attribute smart base
2233 ABASE::CopyWithAttributes(rSourceSet);
2234 // done
2235 return *this;
2236}
2237
2238
2239// Insert(transition)
2240TEMP bool THIS::Insert(const Transition& t) {
2241 FD_DC("TaTransSet(" << this << ")::Insert(" << t.Str() << ")");
2242 return ABASE::Insert(t);
2243}
2244
2245// Insert(x1,ev,x2)
2246TEMP bool THIS::Insert(Idx x1, Idx ev, Idx x2) {
2247 FD_DC("TaTransSet(" << this << ")::Insert(" << x1 << "-" << ev << "-" << x2 << ")");
2248 Transition t(x1, ev, x2);
2249 return ABASE::Insert(t);
2250}
2251
2252// Insert(transition,attr)
2253TEMP bool THIS::Insert(const Transition& t, const Attr& attr) {
2254 return ABASE::Insert(t,attr);
2255}
2256
2257
2258// InsertSet(set)
2259TEMP void THIS::InsertSet(const TransSet& rOtherSet) {
2260 FD_DC("TaTransSet(" << this << ")::InsertSet( [a] " << &rOtherSet << ")");
2261 ABASE::InsertSet(rOtherSet);
2262}
2263
2264// InsertSet(set)
2265TEMP void THIS::InsertSet(const TBaseSet<Transition,TransSort::X1EvX2>& rOtherSet) {
2266#ifdef FAUDES_CHECKED
2267 FD_DC("TaTransSet(" << this << ")::InsertSet(" << rOtherSet.ToString() << ")");
2268 const TransSet* tset = dynamic_cast<const TransSet*>(&rOtherSet);
2269 if(!tset) {
2270 std::stringstream errstr;
2271 errstr << "cannot cast " << typeid(rOtherSet).name() << " to TransSet" << std::endl;
2272 throw Exception("TaTransSet::InsertSet", errstr.str(), 67);
2273 }
2274#endif
2275 ABASE::InsertSet(rOtherSet);
2276}
2277
2278
2279// Erase(transition)
2280TEMP bool THIS::Erase(const Transition& t) {
2281 return ABASE::Erase(t);
2282}
2283
2284// Erase(x1,ev,x2)
2285TEMP bool THIS::Erase(Idx x1, Idx ev, Idx x2) {
2286 FD_DC("TaTransSet(" << this << ")::Erase(" << x1 << "-" << ev << "-" << x2 << ")");
2287 Transition t(x1, ev, x2);
2288 return ABASE::Erase(t);
2289}
2290
2291// Erase(it)
2292TEMP typename THIS::Iterator THIS::Erase(const Iterator& it) {
2293#ifdef FAUDES_CHECKED
2294 if (it == End()) {
2295 std::stringstream errstr;
2296 errstr << "iterator out of range " << std::endl;
2297 throw Exception("TTransSet::Erase", errstr.str(), 69);
2298 }
2299#endif
2300 return ABASE::Erase(it);
2301}
2302
2303// EraseSet(set)
2304TEMP void THIS::EraseSet(const TransSet& rOtherSet) {
2305 FD_DC("TaTransSet(" << this << ")::RestrictSet( [a] " << &rOtherSet << ")");
2306 ABASE::EraseSet(rOtherSet);
2307}
2308
2309// EraseSet(set)
2310TEMP void THIS::EraseSet(const TBaseSet<Transition,TransSort::X1EvX2>& rOtherSet) {
2311#ifdef FAUDES_CHECKED
2312 FD_DC("TaTransSet(" << this << ")::EraseSet(" << rOtherSet.ToString() << ")");
2313 const TransSet* tset = dynamic_cast<const TransSet*>(&rOtherSet);
2314 if(!tset) {
2315 std::stringstream errstr;
2316 errstr << "cannot cast " << typeid(rOtherSet).name() << " to TransSet" << std::endl;
2317 throw Exception("TaTransSet::EraseSet", errstr.str(), 67);
2318 }
2319#endif
2320 ABASE::EraseSet(rOtherSet);
2321}
2322
2323// RestrictSet(set)
2324TEMP void THIS::RestrictSet(const TransSet& rOtherSet) {
2325 FD_DC("TaTransSet(" << this << ")::RestrictSet( [a] " << &rOtherSet << ")");
2326 ABASE::RestrictSet(rOtherSet);
2327}
2328
2329
2330// RestrictSet(set)
2331TEMP void THIS::RestrictSet(const TBaseSet<Transition,TransSort::X1EvX2>& rOtherSet) {
2332#ifdef FAUDES_CHECKED
2333 FD_DC("TaTransSet(" << this << ")::RestrictSet(" << rOtherSet.ToString() << ")");
2334 const TransSet* tset = dynamic_cast<const TransSet*>(&rOtherSet);
2335 if(!tset) {
2336 std::stringstream errstr;
2337 errstr << "cannot cast " << typeid(rOtherSet).name() << " to TransSet" << std::endl;
2338 throw Exception("TaTransSet::RestrictSet", errstr.str(), 67);
2339 }
2340#endif
2341 ABASE::RestrictSet(rOtherSet);
2342}
2343
2344
2345
2346#undef THIS
2347#undef TEMP
2348#undef BASE
2349#undef ABASE
2350
2351#undef SORT_EXECPTION
2352
2353} // namespace faudes
2354
2355
2356
2357
2358#endif
2359
#define TEMP
#define BASE
#define THIS
Class TAttrMap.
Class TBaseSet.
#define FD_DC(message)
#define FD_WARN(message)
Classes IndexSet, TaIndexSet.
Classes NameSet, TaNameSet.
#define FAUDES_API
#define FAUDES_TAPI
Class TokenReader.
#define SORT_EXCEPTION
#define ABASE
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
Definition cfl_types.h:918
#define FAUDES_TYPE_TIMPLEMENTATION(ftype, ctype, cbase, ctemp)
Definition cfl_types.h:1050
bool Exists(const Idx &rIndex) const
SymbolTable * SymbolTablep(void) const
bool Insert(const Idx &rIndex)
StateSet PredecessorStates(Idx x2) const
Iterator EndByEvX2(Idx ev, Idx x2) const
void DoMove(TTransSet &rSource)
Iterator Begin(void) const
Iterator End(void) const
bool ExistsByX1OrX2(Idx x) const
bool Insert(Idx x1, Idx ev, Idx x2)
Iterator Find(Idx x1, Idx ev, Idx x2) const
void EraseByEv(Idx ev)
bool Erase(Idx x1, Idx ev, Idx x2)
Iterator Find(const Transition &t) const
Iterator BeginByX2Ev(Idx x2, Idx ev) const
TBaseSet< Transition, Cmp >::Iterator Iterator
Iterator Begin(Idx x1) const
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
void EraseByX1(Idx x1)
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
EventSet ActiveEvents(Idx x1, SymbolTable *pSymTab=NULL) const
Iterator Begin(Idx x1, Idx ev) const
StateSet SuccessorStates(const StateSet &rX1Set) const
TTransSet(const TTransSet< Cmp > &rOtherSet)
virtual std::string Str(void) const
StateSet PredecessorStates(const StateSet &rX2Set) const
bool Exists(const Transition &t) const
void EraseByX2(Idx x2)
Iterator BeginByEvX1(Idx ev, Idx x1) const
Iterator End(Idx x1, Idx ev) const
StateSet SuccessorStates(Idx x1, Idx ev) const
void RestrictStates(const StateSet &rStateSet)
Iterator EndByEv(Idx ev) const
Iterator EndByEvX1(Idx ev, Idx x1) const
Iterator EndByX2Ev(Idx x2, Idx ev) const
StateSet States(void) const
Iterator BeginByX2(Idx x2) const
TTransSet(const TTransSet< OtherCmp > &res)
void EraseByX1Ev(Idx x1, Idx ev)
Iterator BeginByEv(Idx ev) const
bool Insert(const Transition &rTransition)
Iterator EndByX2(Idx x2) const
bool ExistsByX1Ev(Idx x1, Idx ev) const
Iterator Inject(const Iterator &pos, const Transition &rTransition)
bool Exists(Idx x1, Idx ev, Idx x2) const
Iterator Erase(const Iterator &it)
EventSet IncommingEvents(Idx x2, SymbolTable *pSymTab=NULL) const
void Inject(const Transition &rTransition)
bool Erase(const Transition &t)
StateSet SuccessorStates(Idx x1) const
void DoCopy(const TTransSet &rSource)
void EraseByX1OrX2(const StateSet &rStates)
void RestrictEvents(const EventSet &rEventSet)
void EraseByX1OrX2(Idx x)
StateSet PredecessorStates(Idx x2, Idx ev) const
Iterator End(Idx x1) const
StateSet SuccessorStates(const StateSet &rX1Set, const EventSet &rEvSet) const
virtual std::string Str(const Transition &rTrans) const
void ReSort(TTransSet< OtherCmp > &res) const
StateSet PredecessorStates(const StateSet &rX2Set, const EventSet &rEvSet) const
bool ExistsByX1(Idx x1) const
Iterator BeginByEvX2(Idx ev, Idx x2) const
virtual TaTransSet & Copy(const TBaseSet< Transition, TransSort::X1EvX2 > &rSrc)
TTransSet< TransSort::X1EvX2 >::Iterator Iterator
const Attr * AttributeType(void) const
void AttributeTry(const Transition &rElem, const Type &rAttr)
void Attribute(const Transition &rElem, const Attr &rAttr)
virtual TaTransSet & operator=(const TransSet &rSrc)
Attr * Attributep(const Transition &rElem)
const Attr & Attribute(const Transition &rElem) const
void Attribute(const Transition &rElem, const Type &rAttr)
void DoCopy(const TaTransSet &rSource)
long int ReadInteger(void)
std::string FileLine(void) const
bool Eos(const std::string &rLabel)
void ReadEnd(const std::string &rLabel)
void ReadBegin(const std::string &rLabel)
bool Peek(Token &token)
std::string FileName(void) const
void WriteEnd(const std::string &rLabel)
int Columns(void) const
void WriteBegin(const std::string &rLabel)
std::string Str(void) const
const std::string & StringValue(void) const
@ Integer
1234 (non-negative integer)
Definition cfl_token.h:88
@ Begin
<label> (begin of section)
Definition cfl_token.h:84
bool ExistsAttributeString(const std::string &name)
const std::string & AttributeStringValue(const std::string &name)
TokenType Type(void) const
Transition(Idx x1, Idx ev, Idx x2)
bool Valid(void) const
std::string Str(void) const
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
virtual Type & Copy(const Type &rSrc)
Definition cfl_types.cpp:82
TTransSet< TransSort::EvX2X1 > TransSetEvX2X1
TTransSet< TransSort::X1EvX2 > TransSetX1EvX2
bool Empty(void) const
bool Exists(const T &rElem) const
virtual void Clear(void)
TTransSet< TransSort::X1EvX2 > TransSet
TTransSet< TransSort::X2EvX1 > TransSetX2EvX1
Iterator End(void) const
TTransSet< TransSort::X1X2Ev > TransSetX1X2Ev
virtual void RestrictSet(const TBaseSet &rOtherSet)
virtual void InsertSet(const TBaseSet &rOtherSet)
Iterator Begin(void) const
TTransSet< TransSort::EvX1X2 > TransSetEvX1X2
TTransSet< TransSort::X2X1Ev > TransSetX2X1Ev
virtual void EraseSet(const TBaseSet &rOtherSet)
Idx Size(void) const
uint32_t Idx
void ApplyRelabelMap(const RelabelMap &rMap, const vGenerator &rGen, vGenerator &rRes)
std::string ToStringInteger(Int number)
Definition cfl_utils.cpp:44

libFAUDES 2.34g --- 2026.03.30 --- c++ api documentaion by doxygen