hio_constraint.h
Go to the documentation of this file.
1/** @file hio_constraint.h Generator with I/O-constraint attributes */
2
3/* Hierarchical IO Systems Plug-In for FAU Discrete Event Systems Library (libfaudes)
4
5 Copyright (C) 2006 Sebastian Perk
6 Copyright (C) 2006 Thomas Moor
7 Copyright (C) 2006 Klaus Schmidt
8
9*/
10
11#ifndef FAUDES_HIO_CONSTRAINT_H
12#define FAUDES_HIO_CONSTRAINT_H
13
14#include "corefaudes.h"
15#include "hio_attributes.h"
16
17namespace faudes {
18
19
20/**
21 * Generator with I/O-constraint attributes. The HioConstraint is a variant of the
22 * Generator to add an interface for events and states with I/O-constraint attributes,
23 * built from HioEvent- and HioStateFlags
24 * - event attributes: Y,U
25 *
26 * - state attributes: QY,QU
27 *
28 * Technically, the construct is based on the specialized attribute classes
29 * faudes::HioEventFlags and faudes::HioStateFlags that provide attributes with
30 * semantics for hierarchical I/O properties. The THioConstraint expects attribute template
31 * parameters with the minimum interface defined in HioEventFlags and HioStateFlags.
32 * Thus, you can add further semantics by deriving a class HioEventFlagsAndMore from
33 * HioEventFlags (same for HioStateFlags) and use this as event attribute parameter for
34 * THioConstraint. To model a plain finite state machine plus I/O-constraint properties, use THioConstraint
35 * with HioEventFlags and HioStateFlags for the event and state attribute parameters
36 * and AttributeVoid for the other parameters.
37 * For convenience, this has been typedefed as HioConstraint.
38 *
39 * @ingroup hiosysplugin
40 */
41
42template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
43class FAUDES_TAPI THioConstraint : public TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> {
44public:
45 /**
46 * Creates an empty HioConstraint object
47 */
49
50 /**
51 * HioConstraint from a std Generator. Copy constructor
52 *
53 * @param rOtherGen
54 */
55 THioConstraint(const Generator& rOtherGen);
56
57 /**
58 * HioConstraint from a std Generator and event sets. Copy constructor
59 *
60 * @param rOtherGen
61 * Generator
62 * @param rY
63 * Output alphabet
64 * @param rU
65 * Input alphabet
66 */
68 const Generator& rOtherGen,
69 const EventSet& rY,
70 const EventSet& rU
71 );
72
73 /**
74 * HioConstraint from a HioConstraint. Copy constructor
75 *
76 * @param rOtherGen
77 */
78 THioConstraint(const THioConstraint& rOtherGen);
79
80 /**
81 * construct a HioConstraint from file
82 *
83 * @param rFileName
84 * Filename
85 *
86 * @exception Exception
87 * If opening/reading fails an Exception object is thrown (id 1, 50, 51)
88 */
89 THioConstraint(const std::string& rFileName);
90
91 /**
92 * Construct on heap
93 *
94 * @return
95 * new Generator
96 */
97 THioConstraint* New(void) const;
98
99 /**
100 * Construct copy on heap
101 *
102 * @return
103 * new Generator
104 */
105 virtual THioConstraint* Copy(void) const;
106
107 /**
108 * Create empty HioConstraint with same symboltable as this
109 *
110 * @return
111 * New Generator
112 */
114
115 /**
116 * Assignment operator (uses copy)
117 *
118 * @param rOtherGen
119 * Other generator
120 */
121 virtual THioConstraint& operator= (const THioConstraint& rOtherGen) {this->Assign(rOtherGen); return *this;};
122
123
124//**************** I/O constraint event attributes ********************/
125
126 /**
127 * Add an existing Y-event to generator.
128 * An entry in the global event table will be made.
129 *
130 * @param index
131 * Event index
132 */
133 void InsYEvent(Idx index);
134
135 /**
136 * Add new named Y-event to generator.
137 * An entry in the global event table will be made if event is new.
138 *
139 * @param rName
140 * Name of the event to add
141 *
142 * @return
143 * New global unique index
144 */
145 Idx InsYEvent(const std::string& rName);
146
147 /**
148 * Add an existing U-event to generator.
149 * An entry in the global event table will be made.
150 *
151 * @param index
152 * Event index
153 */
154 void InsUEvent(Idx index);
155
156 /**
157 * Add new named U-event to generator.
158 * An entry in the global event table will be made if event is new.
159 *
160 * @param rName
161 * Name of the event to add
162 *
163 * @return
164 * New global unique index
165 */
166 Idx InsUEvent(const std::string& rName);
167
168 /**
169 * Mark event as Y-event (by index)
170 *
171 * @param index
172 * Event index
173 */
174 void SetY(Idx index);
175
176 /**
177 * Mark event as Y-event(by name)
178 *
179 * @param rName
180 * Event name
181 */
182 void SetY(const std::string& rName);
183
184 /**
185 * Mark set of events as Y-events
186 *
187 * @param rEvents
188 * EventSet
189 */
190 void SetY(const EventSet& rEvents);
191
192 /**
193 * Mark event U-event(by index)
194 *
195 * @param index
196 * Event index
197 */
198 void SetU(Idx index);
199
200 /**
201 * Mark event U-event(by name)
202 *
203 * @param rName
204 * Event name
205 */
206 void SetU(const std::string& rName);
207
208 /**
209 * Mark set of events as U-events
210 *
211 * @param rEvents
212 * EventSet
213 */
214 void SetU(const EventSet& rEvents);
215
216 /**
217 * Is event Y-event(by index)
218 *
219 * @param index
220 * Event index
221 *
222 * @return
223 * True / false
224 */
225 bool IsY(Idx index) const;
226
227 /**
228 * Is event Y-event(by name)
229 *
230 * @param rName
231 * Event name
232 *
233 * @return
234 * True / false
235 */
236 bool IsY(const std::string& rName) const;
237
238 /**
239 * Is event U-event(by index)
240 *
241 * @param index
242 * Event index
243 *
244 * @return
245 * True / false
246 */
247 bool IsU(Idx index) const;
248
249 /**
250 * Is event U-event(by name)
251 *
252 * @param rName
253 * Event name
254 *
255 * @return
256 * True / false
257 */
258 bool IsU(const std::string& rName) const;
259
260 /**
261 * Get EventSet with Y-events
262 *
263 * @return
264 * EventSet of Y-events
265 */
266 EventSet YEvents(void) const;
267
268 /**
269 * Get EventSet with U-events
270 *
271 * @return
272 * EventSet of U-events
273 */
274 EventSet UEvents(void) const;
275
276/*************** I/O constraint state attributes **********************/
277
278 /**
279 * Mark event as QY-state (by index)
280 *
281 * @param index
282 * State index
283 */
284 void SetQY(Idx index);
285
286 /**
287 * Mark state as QY-state (by name)
288 *
289 * @param rName
290 * State name
291 */
292 void SetQY(const std::string& rName);
293
294 /**
295 * Mark set of states as QY-states
296 *
297 * @param rStates
298 * StateSet
299 */
300 void SetQY(const StateSet& rStates);
301
302 /** Mark state as NOT QY-state (by index)
303 *
304 * @param index
305 * State index
306 */
307 void ClrQY(Idx index);
308
309 /**
310 * Mark state as NOT QY-state (by name)
311 *
312 * @param rName
313 * State name
314 */
315 void ClrQY(const std::string& rName);
316
317 /**
318 * Mark set of states as NOT QY-states (by index)
319 *
320 * @param rStates
321 * StateSet
322 */
323 void ClrQY(const StateSet& rStates);
324
325 /** Is state QY-state (by index)
326 *
327 * @param index
328 * State index
329 *
330 * @return
331 * True / false
332 */
333 bool IsQY(Idx index) const;
334
335 /**
336 * Is state QY-state (by name)
337 *
338 * @param rName
339 * State name
340 *
341 * @return
342 * True / false
343 */
344 bool IsQY(const std::string& rName) const;
345
346 /**
347 * Get StateSet with QY-states
348 *
349 * @return
350 * StateSet of QY-states
351 */
352 StateSet QYStates(void) const;
353
354 /**
355 * Mark event as QU-state (by index)
356 *
357 * @param index
358 * State index
359 */
360 void SetQU(Idx index);
361
362 /**
363 * Mark state as QU-state (by name)
364 *
365 * @param rName
366 * State name
367 */
368 void SetQU(const std::string& rName);
369
370 /**
371 * Mark set of states as QU-states
372 *
373 * @param rStates
374 * StateSet
375 */
376 void SetQU(const StateSet& rStates);
377
378 /** Mark state as NOT QU-state (by index)
379 *
380 * @param index
381 * State index
382 */
383 void ClrQU(Idx index);
384
385 /**
386 * Mark state as NOT QU-state (by name)
387 *
388 * @param rName
389 * State name
390 */
391 void ClrQU(const std::string& rName);
392
393 /**
394 * Mark set of states as NOT QU-states (by index)
395 *
396 * @param rStates
397 * StateSet
398 */
399 void ClrQU(const StateSet& rStates);
400
401 /** Is state QU-state (by index)
402 *
403 * @param index
404 * State index
405 *
406 * @return
407 * True / false
408 */
409 bool IsQU(Idx index) const;
410
411 /**
412 * Is state QU-state (by name)
413 *
414 * @param rName
415 * State name
416 *
417 * @return
418 * True / false
419 */
420 bool IsQU(const std::string& rName) const;
421
422 /**
423 * Get StateSet with QU-states
424 *
425 * @return
426 * StateSet of QU-states
427 */
428 StateSet QUStates(void) const;
429
430 /**
431 * Mark state as Err-state (by index)
432 *
433 * @param index
434 * State index
435 */
436 void SetErr(Idx index);
437
438 /**
439 * Mark state as Err-state (by name)
440 *
441 * @param rName
442 * State name
443 */
444 void SetErr(const std::string& rName);
445
446 /**
447 * Mark set of states as Err-states
448 *
449 * @param rStates
450 * StateSet
451 */
452 void SetErr(const StateSet& rStates);
453
454 /** Mark state as NOT Err-state (by index)
455 *
456 * @param index
457 * State index
458 */
459 void ClrErr(Idx index);
460
461 /**
462 * Mark state as NOT Err-state (by name)
463 *
464 * @param rName
465 * State name
466 */
467 void ClrErr(const std::string& rName);
468
469 /**
470 * Mark set of states as NOT Err-states (by index)
471 *
472 * @param rStates
473 * StateSet
474 */
475 void ClrErr(const StateSet& rStates);
476
477 /** Is state Err-state (by index)
478 *
479 * @param index
480 * State index
481 *
482 * @return
483 * True / false
484 */
485 bool IsErr(Idx index) const;
486
487 /**
488 * Is state Err-state (by name)
489 *
490 * @param rName
491 * State name
492 *
493 * @return
494 * True / false
495 */
496 bool IsErr(const std::string& rName) const;
497
498 /**
499 * Get StateSet with Err-states
500 *
501 * @return
502 * StateSet of Err-states
503 */
504 StateSet ErrStates(void) const;
505
506 /**
507 * Updates internal attributes.
508 * This method sets the state partition attributes.
509 *
510 * @return True if value changed
511 */
512 virtual bool UpdateAttributes(void) {IsHioConstraintForm(*this); return true;};
513
514 private:
515
516 protected:
517
518}; // end class THioConstraint
519
520
521// convenience typedef for std HioConstraint
523
524/* convenience access to relevant scopes */
525#define THIS THioConstraint<GlobalAttr, StateAttr, EventAttr, TransAttr>
526#define BASE TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
527#define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
528
529
530// THioConstraint(void)
531TEMP THIS::THioConstraint(void) : BASE() {
532 FD_DG("HioConstraint(" << this << ")::HioConstraint()");
533}
534
535// THioConstraint(rOtherGen)
536TEMP THIS::THioConstraint(const THioConstraint& rOtherGen) : BASE(rOtherGen) {
537 FD_DG("HioConstraint(" << this << ")::HioConstraint(rOtherGen)");
538}
539
540// THioConstraint(rOtherGen)
541TEMP THIS::THioConstraint(const Generator& rOtherGen) : BASE(rOtherGen) {
542 FD_DG("HioConstraint(" << this << ")::HioConstraint(rOtherGen)");
543}
544
545// THioConstraint(rOtherGen,rY,rU)
546TEMP THIS::THioConstraint(
547const Generator& rOtherGen,
548 const EventSet& rY,
549 const EventSet& rU
550) : BASE(rOtherGen) {
551 FD_DG("HioConstraint(" << this << ")::HioConstraint(rOtherGen)");
552 SetY(rY);
553 SetU(rU);
554}
555
556// THioConstraint(rFileName)
557TEMP THIS::THioConstraint(const std::string& rFileName) : BASE(rFileName) {
558 FD_DG("HioConstraint(" << this << ")::HioConstraint(rFilename) : done");
559}
560
561// New()
562TEMP THIS* THIS::New(void) const {
563 // allocate
564 THIS* res = new THIS;
565 // fix base data
566 res->EventSymbolTablep(BASE::mpEventSymbolTable);
567 res->mStateNamesEnabled=BASE::mStateNamesEnabled;
568 return res;
569}
570
571// Copy()
572TEMP THIS* THIS::Copy(void) const {
573 return new THIS(*this);
574}
575
576// NewHioConstraint()
577TEMP THIS THIS::NewHioConstraint(void) const {
578 // call base (fixes by assignment constructor)
579 THIS res= BASE::NewAGen();
580 return res;
581}
582
583/******************************************************/
584
585 // IsY(index)
586 TEMP bool THIS::IsY(Idx index) const {
587 EventAttr attr=BASE::EventAttribute(index);
588 return attr.IsY();
589 }
590
591 // IsY(rName)
592 TEMP bool THIS::IsY(const std::string& rName) const {
593 EventAttr attr=BASE::EventAttribute(rName);
594 return attr.IsY();
595 }
596
597 // IsU(index)
598 TEMP bool THIS::IsU(Idx index) const {
599 EventAttr attr=BASE::EventAttribute(index);
600 return attr.IsU();
601 }
602
603 // IsU(rName)
604 TEMP bool THIS::IsU(const std::string& rName) const {
605 EventAttr attr=BASE::EventAttribute(rName);
606 return attr.IsU();
607 }
608
609 //YEvents()
610 TEMP EventSet THIS::YEvents(void) const {
611 FD_DG("HioConstraint(" << this << ")::YEvents()");
612 EventSet res;
613 EventSet::Iterator it;
614 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
615 if(IsY(*it)) res.Insert(*it);
616 }
617 return res;
618 }
619
620 //UEvents()
621 TEMP EventSet THIS::UEvents(void) const {
622 FD_DG("HioConstraint(" << this << ")::UEvents()");
623 EventSet res;
624 EventSet::Iterator it;
625 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
626 if(IsU(*it)) res.Insert(*it);
627 }
628 return res;
629 }
630
631/*****************************************************************/
632
633 // InsYEvent(index)
634 TEMP void THIS::InsYEvent(Idx index) {
635 FD_DG("HioConstraint(" << this << ")::InsYEvent(" << index << ")");
636 EventAttr attr;
637 attr.SetY();
638 BASE::InsEvent(index,attr);
639 }
640
641 // InsYEvent(rName)
642 TEMP Idx THIS::InsYEvent(const std::string& rName) {
643 FD_DG("HioConstraint(" << this << ")::InsYEvent(" << rName << ")");
644 EventAttr attr;
645 attr.SetY();
646 return BASE::InsEvent(rName,attr);
647 }
648
649 // InsUEvent(index)
650 TEMP void THIS::InsUEvent(Idx index) {
651 FD_DG("HioConstraint(" << this << ")::InsUEvent(" << index << ")");
652 EventAttr attr;
653 attr.SetU();
654 BASE::InsEvent(index,attr);
655 }
656
657 // InsUEvent(rName)
658 TEMP Idx THIS::InsUEvent(const std::string& rName) {
659 FD_DG("HioConstraint(" << this << ")::InsUEvent(" << rName << ")");
660 EventAttr attr;
661 attr.SetU();
662 return BASE::InsEvent(rName,attr);
663 }
664
665 // SetY(index)
666 TEMP void THIS::SetY(Idx index) {
667 FD_DG("HioConstraint(" << this << ")::SetY(" << index << ")");
668 EventAttr attr=BASE::EventAttribute(index);
669 attr.SetY();
670 BASE::pAlphabet->Attribute(index,attr);
671 }
672
673 // SetY(rName)
674 TEMP void THIS::SetY(const std::string& rName) {
675 FD_DG("HioConstraint(" << this << ")::SetY(" << rName << ")");
676 Idx index = BASE::EventIndex(rName);
677 SetY(index);
678 }
679
680 //SetY(rEvents)
681 TEMP void THIS::SetY(const EventSet& rEvents) {
682 FD_DG("HioConstraint(" << this << ")::SetY(rEvents)");
683 EventSet::Iterator it;
684 for(it=rEvents.Begin(); it!=rEvents.End(); it++) {
685 SetY(*it);
686 }
687 }
688
689 // SetU(index)
690 TEMP void THIS::SetU(Idx index) {
691 FD_DG("HioConstraint(" << this << ")::SetU(" << index << ")");
692 EventAttr attr=BASE::EventAttribute(index);
693 attr.SetU();
694 BASE::pAlphabet->Attribute(index,attr);
695 }
696
697 // SetU(rName)
698 TEMP void THIS::SetU(const std::string& rName) {
699 FD_DG("HioConstraint(" << this << ")::SetU(" << rName << ")");
700 Idx index = BASE::EventIndex(rName);
701 SetU(index);
702 }
703
704 //SetU(rEvents)
705 TEMP void THIS::SetU(const EventSet& rEvents) {
706 FD_DG("HioConstraint(" << this << ")::SetU(rEvents)");
707 EventSet::Iterator it;
708 for(it=rEvents.Begin(); it!=rEvents.End(); it++) {
709 SetU(*it);
710 }
711 }
712
713/*******************************************************************
714 *****************Implementation of the state attributes*************
715*******************************************************************/
716
717 // SetQY(index)
718 TEMP void THIS::SetQY(Idx index) {
719 FD_DG("HioConstraint(" << this << ")::SetQY(" << index << ")");
720 StateAttr attr=BASE::StateAttribute(index);
721 attr.SetQY();
722 attr.ClrQU();
723 attr.ClrQC();
724 attr.ClrQP();
725 attr.ClrQE();
726 attr.ClrQL();
727 attr.ClrQYcUp();
728 attr.ClrQYlUe();
729 BASE::pStates->Attribute(index,attr);
730 }
731
732 // SetQY(rName)
733 TEMP void THIS::SetQY(const std::string& rName) {
734 FD_DG("HioConstraint(" << this << ")::SetQY(" << rName << ")");
735 Idx index = BASE::StateIndex(rName);
736 SetQY(index);
737 }
738
739 //SetQY(rStates)
740 TEMP void THIS::SetQY(const StateSet& rStates) {
741 FD_DG("HioConstraint(" << this << ")::SetQY(rStates)");
742 StateSet::Iterator sit;
743 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) {
744 SetQY(*sit);
745 }
746 }
747
748 // ClrQY(index)
749 TEMP void THIS::ClrQY(Idx index) {
750 FD_DG("HioConstraint(" << this << ")::ClrQY(" << index << ")");
751 StateAttr attr=BASE::StateAttribute(index);
752 attr.ClrQY();
753 BASE::pStates->Attribute(index,attr);
754 }
755
756 // ClrQY(rName)
757 TEMP void THIS::ClrQY(const std::string& rName) {
758 FD_DG("HioConstraint(" << this << ")::ClrQY(" << rName << ")");
759 Idx index = BASE::StateIndex(rName);
760 ClrQY(index);
761 }
762
763 //ClrQY(rStates)
764 TEMP void THIS::ClrQY(const StateSet& rStates) {
765 FD_DG("HioConstraint(" << this << ")::ClrQY(rStates)");
766 StateSet::Iterator sit;
767 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) {
768 ClrQY(*sit);
769 }
770 }
771
772 // IsQY(index)
773 TEMP bool THIS::IsQY(Idx index) const {
774 StateAttr attr=BASE::StateAttribute(index);
775 return attr.IsQY();
776 }
777
778 // IsQY(rName)
779 TEMP bool THIS::IsQY(const std::string& rName) const {
780 Idx index = BASE::StateIndex(rName);
781 return IsQY(index);
782 }
783
784 //QYStates()
785 TEMP StateSet THIS::QYStates(void) const {
786 FD_DG("HioConstraint(" << this << ")::QYStates()");
787 StateSet res;
788 StateSet::Iterator sit;
789 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) {
790 if(IsQY(*sit)) res.Insert(*sit);
791 }
792 return res;
793 }
794/***************************************************************************/
795
796 // SetQU(index)
797 TEMP void THIS::SetQU(Idx index) {
798 FD_DG("HioConstraint(" << this << ")::SetQU(" << index << ")");
799 StateAttr attr=BASE::StateAttribute(index);
800 attr.SetQU();
801 attr.ClrQY();
802 attr.ClrQC();
803 attr.ClrQP();
804 attr.ClrQE();
805 attr.ClrQL();
806 attr.ClrQYcUp();
807 attr.ClrQYlUe();
808 BASE::pStates->Attribute(index,attr);
809 }
810
811 // SetQU(rName)
812 TEMP void THIS::SetQU(const std::string& rName) {
813 FD_DG("HioConstraint(" << this << ")::SetQU(" << rName << ")");
814 Idx index = BASE::StateIndex(rName);
815 SetQU(index);
816 }
817
818 //SetQU(rStates)
819 TEMP void THIS::SetQU(const StateSet& rStates) {
820 FD_DG("HioConstraint(" << this << ")::SetQU(rStates)");
821 StateSet::Iterator sit;
822 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) {
823 SetQU(*sit);
824 }
825 }
826
827 // ClrQU(index)
828 TEMP void THIS::ClrQU(Idx index) {
829 FD_DG("HioConstraint(" << this << ")::ClrQU(" << index << ")");
830 StateAttr attr=BASE::StateAttribute(index);
831 attr.ClrQU();
832 BASE::pStates->Attribute(index,attr);
833 }
834
835 // ClrQU(rName)
836 TEMP void THIS::ClrQU(const std::string& rName) {
837 FD_DG("HioConstraint(" << this << ")::ClrQU(" << rName << ")");
838 Idx index = BASE::StateIndex(rName);
839 ClrQU(index);
840 }
841
842 //ClrQU(rStates)
843 TEMP void THIS::ClrQU(const StateSet& rStates) {
844 FD_DG("HioConstraint(" << this << ")::ClrQU(rStates)");
845 StateSet::Iterator sit;
846 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) {
847 ClrQU(*sit);
848 }
849 }
850
851 // IsQU(index)
852 TEMP bool THIS::IsQU(Idx index) const {
853 StateAttr attr=BASE::StateAttribute(index);
854 return attr.IsQU();
855 }
856
857 // IsQU(rName)
858 TEMP bool THIS::IsQU(const std::string& rName) const {
859 Idx index = BASE::StateIndex(rName);
860 return IsQU(index);
861 }
862
863 //QUStates()
864 TEMP StateSet THIS::QUStates(void) const {
865 FD_DG("HioConstraint(" << this << ")::QUStates()");
866 StateSet res;
867 StateSet::Iterator sit;
868 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) {
869 if(IsQU(*sit)) res.Insert(*sit);
870 }
871 return res;
872 }
873
874 // SetErr(index)
875 TEMP void THIS::SetErr(Idx index) {
876 FD_DG("HioPlant(" << this << ")::SetErr(" << index << ")");
877 StateAttr attr=BASE::StateAttribute(index);
878 attr.SetErr();
879 BASE::pStates->Attribute(index,attr);
880 }
881
882 // SetErr(rName)
883 TEMP void THIS::SetErr(const std::string& rName) {
884 FD_DG("HioPlant(" << this << ")::SetErr(" << rName << ")");
885 Idx index = BASE::StateIndex(rName);
886 SetErr(index);
887 }
888
889 //SetErr(rStates)
890 TEMP void THIS::SetErr(const StateSet& rStates) {
891 FD_DG("HioPlant(" << this << ")::SetErr(rStates)");
892 StateSet::Iterator sit;
893 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) {
894 SetErr(*sit);
895 }
896 }
897
898 // ClrErr(index)
899 TEMP void THIS::ClrErr(Idx index) {
900 FD_DG("HioPlant(" << this << ")::ClrErr(" << index << ")");
901 StateAttr attr=BASE::StateAttribute(index);
902 attr.ClrErr();
903 BASE::pStates->Attribute(index,attr);
904 }
905
906 // ClrErr(rName)
907 TEMP void THIS::ClrErr(const std::string& rName) {
908 FD_DG("HioPlant(" << this << ")::ClrErr(" << rName << ")");
909 Idx index = BASE::StateIndex(rName);
910 ClrErr(index);
911 }
912
913 //ClrErr(rStates)
914 TEMP void THIS::ClrErr(const StateSet& rStates) {
915 FD_DG("HioPlant(" << this << ")::ClrErr(rStates)");
916 StateSet::Iterator sit;
917 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) {
918 ClrErr(*sit);
919 }
920 }
921
922 // IsErr(index)
923 TEMP bool THIS::IsErr(Idx index) const {
924 StateAttr attr=BASE::StateAttribute(index);
925 return attr.IsErr();
926 }
927
928 // IsErr(rName)
929 TEMP bool THIS::IsErr(const std::string& rName) const {
930 Idx index = BASE::StateIndex(rName);
931 return IsErr(index);
932 }
933
934 //ErrStates()
935 TEMP StateSet THIS::ErrStates(void) const {
936 FD_DG("HioPlant(" << this << ")::ErrStates()");
937 StateSet res;
938 StateSet::Iterator sit;
939 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) {
940 if(IsErr(*sit)) res.Insert(*sit);
941 }
942 return res;
943 }
944
945
946/***************************************************************************/
947
948#undef TEMP
949#undef BASE
950#undef THIS
951
952/**
953 * IsHioConstraintForm: check if rHioConstraint is in I/O-constraint form and assign state
954 * attributes.
955 * This function tests if rHioConstraint meets the I/O-constraint form that has been formally
956 * defined by S.Perk. If so, then the alphabet of and the language marked by
957 * rHioConstraint formally describe an I/O constraint. During the test, the HioStateFlags are
958 * set according to the active event set or the respective state, for example:
959 * The QY flag is assigned to a state if its active eventset is a subset of the Y-Alphabet.
960 * The assignment of HioStateFlags is complete only if IsHioConstraintForm() returns true.
961 * Method: all conditions in the formal I/O-constraint form definition are checked
962 * individually. If crucial conditions are violated, the test of remaining
963 * conditions is omitted.
964 *
965 * @param rHioConstraint
966 * HioConstraint to check, HioStateFlags are set
967 * @param rQY
968 * State set containing all QY states
969 * @param rQU
970 * State set containing all QU states
971 * @param rErrEvSet
972 * Event set for possible 'bad' events
973 * @param rErrTrSet
974 * Event set for possible 'bad' transition relations
975 * @param rErrStSet
976 * Event set for possible 'bad' states
977 * @param rReportStr
978 * Information about test results
979 * @return
980 * true if rHioConstraint is in I/O-constraint form
981 */
982
983extern FAUDES_API bool IsHioConstraintForm(HioConstraint& rHioConstraint,
984 StateSet& rQY,
985 StateSet& rQU,
986 EventSet& rErrEvSet,
987 TransSet& rErrTrSet,
988 StateSet& rErrStSet,
989 std::string& rReportStr);
990
991/**
992 * IsHioConstraintForm: check if rHioConstraint is in I/O-constraint form and assign state
993 * attributes.
994 * This function tests if rHioConstraint meets the I/O-constraint form that has been formally
995 * defined by S.Perk. If so, then the alphabet of and the language marked by
996 * rHioConstraint formally describe an I/O constraint. During the test, the HioStateFlags are
997 * set according to the active event set or the respective state, for example:
998 * The QY flag is assigned to a state if its active eventset is a subset of the Y-Alphabet.
999 * The assignment of HioStateFlags is complete only if IsHioConstraintForm() returns true.
1000 * Method: all conditions in the formal I/O-constraint form definition are checked
1001 * individually. If crucial conditions are violated, the test of remaining
1002 * conditions is omitted.
1003 *
1004 * @param rHioConstraint
1005 * HioConstraint to check, HioStateFlags are set
1006 * @param rReportStr
1007 * Information about test results
1008 * @return
1009 * true if rHioConstraint is in I/O-constraint form
1010 */
1011extern FAUDES_API bool IsHioConstraintForm(HioConstraint& rHioConstraint,std::string& rReportStr);
1012
1013/**
1014 * IsHioConstraintForm: check if rHioConstraint is in I/O-constraint form and assign state
1015 * attributes.
1016 * This function tests if rHioConstraint meets the I/O-constraint form that has been formally
1017 * defined by S.Perk. If so, then the alphabet of and the language marked by
1018 * rHioConstraint formally describe an I/O constraint. During the test, the HioStateFlags are
1019 * set according to the active event set or the respective state, for example:
1020 * The QY flag is assigned to a state if its active eventset is a subset of the Y-Alphabet.
1021 * The assignment of HioStateFlags is complete only if IsHioConstraintForm() returns true.
1022 * Method: all conditions of the formal I/O-constraint form definition are checked
1023 * individually. If crucial conditions are violated, the test of remaining
1024 * conditions is omitted.
1025 *
1026 * @param rHioConstraint
1027 * HioConstraint to check, HioStateFlags are set
1028 * @return
1029 * true if rHioConstraint is in I/O-constraint form
1030 */
1031extern FAUDES_API bool IsHioConstraintForm(HioConstraint& rHioConstraint);
1032
1033/**
1034 * Function definition for run-time interface
1035 *
1036 * @param rConstraint
1037 * HioConstraint
1038 */
1039extern FAUDES_API void HioStatePartition(HioConstraint& rConstraint);
1040
1041} // namespace faudes
1042
1043#endif
#define TEMP
#define BASE
#define THIS
#define FD_DG(message)
#define FAUDES_API
#define FAUDES_TAPI
bool Insert(const Idx &rIndex)
bool IsU(Idx index) const
bool IsQY(const std::string &rName) const
void SetY(const EventSet &rEvents)
bool IsErr(const std::string &rName) const
virtual bool UpdateAttributes(void)
void ClrQY(const StateSet &rStates)
StateSet ErrStates(void) const
bool IsY(Idx index) const
bool IsQY(Idx index) const
void SetQU(const std::string &rName)
bool IsY(const std::string &rName) const
EventSet UEvents(void) const
StateSet QUStates(void) const
THioConstraint(const Generator &rOtherGen, const EventSet &rY, const EventSet &rU)
bool IsU(const std::string &rName) const
THioConstraint(const std::string &rFileName)
bool IsQU(Idx index) const
void ClrQY(const std::string &rName)
void SetQY(const StateSet &rStates)
void SetU(const EventSet &rEvents)
void SetQY(const std::string &rName)
void InsUEvent(Idx index)
virtual THioConstraint * Copy(void) const
void ClrErr(const std::string &rName)
THioConstraint NewHioConstraint(void) const
bool IsErr(Idx index) const
THioConstraint(const Generator &rOtherGen)
void InsYEvent(Idx index)
Idx InsYEvent(const std::string &rName)
THioConstraint * New(void) const
StateSet QYStates(void) const
void SetU(const std::string &rName)
void SetQU(const StateSet &rStates)
void ClrQU(const std::string &rName)
bool IsQU(const std::string &rName) const
void SetErr(const std::string &rName)
void ClrErr(const StateSet &rStates)
void ClrQU(const StateSet &rStates)
void SetErr(const StateSet &rStates)
EventSet YEvents(void) const
THioConstraint(const THioConstraint &rOtherGen)
void SetY(const std::string &rName)
Idx InsUEvent(const std::string &rName)
Iterator End(void) const
Iterator Begin(void) const
uint32_t Idx
void HioStatePartition(HioConstraint &rHioConstraint)
THioConstraint< AttributeVoid, HioStateFlags, HioEventFlags, AttributeVoid > HioConstraint
bool IsHioConstraintForm(HioConstraint &rHioConstraint, StateSet &rQY, StateSet &rQU, EventSet &rErrEvSet, TransSet &rErrTrSet, StateSet &rErrStSet, std::string &rReportStr)

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen