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

libFAUDES 2.24g --- 2014.09.15 --- c++ api documentaion by doxygen