hio_constraint.hGo to the documentation of this file.00001 /** @file hio_constraint.h Generator with I/O-constraint attributes */ 00002 00003 /* Hierarchical IO Systems Plug-In for FAU Discrete Event Systems Library (libfaudes) 00004 00005 Copyright (C) 2006 Sebastian Perk 00006 Copyright (C) 2006 Thomas Moor 00007 Copyright (C) 2006 Klaus Schmidt 00008 00009 */ 00010 00011 #ifndef FAUDES_HIO_CONSTRAINT_H 00012 #define FAUDES_HIO_CONSTRAINT_H 00013 00014 #include "corefaudes.h" 00015 #include "hio_attributes.h" 00016 00017 namespace faudes { 00018 00019 00020 /** 00021 * Generator with I/O-constraint attributes. The HioConstraint is a variant of the 00022 * Generator to add an interface for events and states with I/O-constraint attributes, 00023 * built from HioEvent- and HioStateFlags 00024 * - event attributes: Y 00025 * U 00026 * 00027 * - state attributes: QY 00028 * QU 00029 * 00030 * Technically, the construct is based on the specialized attribute classes 00031 * faudes::HioEventFlags and faudes::HioStateFlags that provide attributes with 00032 * semantics for hierarchical I/O properties. The THioConstraint expects attribute template 00033 * parameters with the minimum interface defined in HioEventFlags and HioStateFlags. 00034 * Thus, you can add further semantics by deriving a class HioEventFlagsAndMore from 00035 * HioEventFlags (same for HioStateFlags) and use this as event attribute parameter for 00036 * THioConstraint. To model a plain finite state machine plus I/O-constraint properties, use THioConstraint 00037 * with HioEventFlags and HioStateFlags for the event and state attribute parameters 00038 * and AttributeVoid for the other parameters. 00039 * For convenience, this has been typedefed as HioConstraint. 00040 * 00041 * @ingroup hiosysplugin 00042 */ 00043 00044 template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr> 00045 class THioConstraint : public TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> { 00046 public: 00047 /** 00048 * Creates an empty HioConstraint object 00049 */ 00050 THioConstraint(void); 00051 00052 /** 00053 * HioConstraint from a std Generator. Copy constructor 00054 * 00055 * @param rOtherGen 00056 */ 00057 THioConstraint(const Generator& rOtherGen); 00058 00059 /** 00060 * HioConstraint from a std Generator and event sets. Copy constructor 00061 * 00062 * @param rOtherGen 00063 * Generator 00064 * @param rY 00065 * Output alphabet 00066 * @param rU 00067 * Input alphabet 00068 */ 00069 THioConstraint( 00070 const Generator& rOtherGen, 00071 const EventSet& rY, 00072 const EventSet& rU 00073 ); 00074 00075 /** 00076 * HioConstraint from a HioConstraint. Copy constructor 00077 * 00078 * @param rOtherGen 00079 */ 00080 THioConstraint(const THioConstraint& rOtherGen); 00081 00082 /** 00083 * construct a HioConstraint from file 00084 * 00085 * @param rFileName 00086 * Filename 00087 * 00088 * @exception Exception 00089 * If opening/reading fails an Exception object is thrown (id 1, 50, 51) 00090 */ 00091 THioConstraint(const std::string& rFileName); 00092 00093 /** 00094 * Construct on heap 00095 * 00096 * @return 00097 * new Generator 00098 */ 00099 THioConstraint* New(void) const; 00100 00101 /** 00102 * Construct copy on heap 00103 * 00104 * @return 00105 * new Generator 00106 */ 00107 virtual THioConstraint* Copy(void) const; 00108 00109 /** 00110 * Create empty HioConstraint with same symboltable as this 00111 * 00112 * @return 00113 * New Generator 00114 */ 00115 THioConstraint NewHioConstraint(void) const; 00116 00117 /** 00118 * Assignment operator (uses copy ) 00119 * Note: you must reimplement this operator in derived 00120 * classes in order to handle internal pointers correctly 00121 * 00122 * @param rOtherGen 00123 * Other generator 00124 */ 00125 virtual THioConstraint& operator= (const THioConstraint& rOtherGen) {this->Assign(rOtherGen); return *this;}; 00126 00127 /** 00128 * Assignment operator (uses copy ) 00129 * 00130 * @param rOtherGen 00131 * Other generator 00132 */ 00133 virtual THioConstraint& operator= (const Generator& rOtherGen) {this->Assign(rOtherGen); return *this;}; 00134 00135 00136 //**************** I/O constraint event attributes ********************/ 00137 00138 /** 00139 * Add an existing Y-event to generator. 00140 * An entry in the global event table will be made. 00141 * 00142 * @param index 00143 * Event index 00144 */ 00145 void InsYEvent(Idx index); 00146 00147 /** 00148 * Add new named Y-event to generator. 00149 * An entry in the global event table will be made if event is new. 00150 * 00151 * @param rName 00152 * Name of the event to add 00153 * 00154 * @return 00155 * New global unique index 00156 */ 00157 Idx InsYEvent(const std::string& rName); 00158 00159 /** 00160 * Add an existing U-event to generator. 00161 * An entry in the global event table will be made. 00162 * 00163 * @param index 00164 * Event index 00165 */ 00166 void InsUEvent(Idx index); 00167 00168 /** 00169 * Add new named U-event to generator. 00170 * An entry in the global event table will be made if event is new. 00171 * 00172 * @param rName 00173 * Name of the event to add 00174 * 00175 * @return 00176 * New global unique index 00177 */ 00178 Idx InsUEvent(const std::string& rName); 00179 00180 /** 00181 * Mark event as Y-event (by index) 00182 * 00183 * @param index 00184 * Event index 00185 */ 00186 void SetY(Idx index); 00187 00188 /** 00189 * Mark event as Y-event(by name) 00190 * 00191 * @param rName 00192 * Event name 00193 */ 00194 void SetY(const std::string& rName); 00195 00196 /** 00197 * Mark set of events as Y-events 00198 * 00199 * @param rEvents 00200 * EventSet 00201 */ 00202 void SetY(const EventSet& rEvents); 00203 00204 /** 00205 * Mark event U-event(by index) 00206 * 00207 * @param index 00208 * Event index 00209 */ 00210 void SetU(Idx index); 00211 00212 /** 00213 * Mark event U-event(by name) 00214 * 00215 * @param rName 00216 * Event name 00217 */ 00218 void SetU(const std::string& rName); 00219 00220 /** 00221 * Mark set of events as U-events 00222 * 00223 * @param rEvents 00224 * EventSet 00225 */ 00226 void SetU(const EventSet& rEvents); 00227 00228 /** 00229 * Is event Y-event(by index) 00230 * 00231 * @param index 00232 * Event index 00233 * 00234 * @return 00235 * True / false 00236 */ 00237 bool IsY(Idx index) const; 00238 00239 /** 00240 * Is event Y-event(by name) 00241 * 00242 * @param rName 00243 * Event name 00244 * 00245 * @return 00246 * True / false 00247 */ 00248 bool IsY(const std::string& rName) const; 00249 00250 /** 00251 * Is event U-event(by index) 00252 * 00253 * @param index 00254 * Event index 00255 * 00256 * @return 00257 * True / false 00258 */ 00259 bool IsU(Idx index) const; 00260 00261 /** 00262 * Is event U-event(by name) 00263 * 00264 * @param rName 00265 * Event name 00266 * 00267 * @return 00268 * True / false 00269 */ 00270 bool IsU(const std::string& rName) const; 00271 00272 /** 00273 * Get EventSet with Y-events 00274 * 00275 * @return 00276 * EventSet of Y-events 00277 */ 00278 EventSet YEvents(void) const; 00279 00280 /** 00281 * Get EventSet with U-events 00282 * 00283 * @return 00284 * EventSet of U-events 00285 */ 00286 EventSet UEvents(void) const; 00287 00288 /*************** I/O constraint state attributes **********************/ 00289 00290 /** 00291 * Mark event as QY-state (by index) 00292 * 00293 * @param index 00294 * State index 00295 */ 00296 void SetQY(Idx index); 00297 00298 /** 00299 * Mark state as QY-state (by name) 00300 * 00301 * @param rName 00302 * State name 00303 */ 00304 void SetQY(const std::string& rName); 00305 00306 /** 00307 * Mark set of states as QY-states 00308 * 00309 * @param rStates 00310 * StateSet 00311 */ 00312 void SetQY(const StateSet& rStates); 00313 00314 /** Mark state as NOT QY-state (by index) 00315 * 00316 * @param index 00317 * State index 00318 */ 00319 void ClrQY(Idx index); 00320 00321 /** 00322 * Mark state as NOT QY-state (by name) 00323 * 00324 * @param rName 00325 * State name 00326 */ 00327 void ClrQY(const std::string& rName); 00328 00329 /** 00330 * Mark set of states as NOT QY-states (by index) 00331 * 00332 * @param rStates 00333 * StateSet 00334 */ 00335 void ClrQY(const StateSet& rStates); 00336 00337 /** Is state QY-state (by index) 00338 * 00339 * @param index 00340 * State index 00341 * 00342 * @return 00343 * True / false 00344 */ 00345 bool IsQY(Idx index) const; 00346 00347 /** 00348 * Is state QY-state (by name) 00349 * 00350 * @param rName 00351 * State name 00352 * 00353 * @return 00354 * True / false 00355 */ 00356 bool IsQY(const std::string& rName) const; 00357 00358 /** 00359 * Get StateSet with QY-states 00360 * 00361 * @return 00362 * StateSet of QY-states 00363 */ 00364 StateSet QYStates(void) const; 00365 00366 /** 00367 * Mark event as QU-state (by index) 00368 * 00369 * @param index 00370 * State index 00371 */ 00372 void SetQU(Idx index); 00373 00374 /** 00375 * Mark state as QU-state (by name) 00376 * 00377 * @param rName 00378 * State name 00379 */ 00380 void SetQU(const std::string& rName); 00381 00382 /** 00383 * Mark set of states as QU-states 00384 * 00385 * @param rStates 00386 * StateSet 00387 */ 00388 void SetQU(const StateSet& rStates); 00389 00390 /** Mark state as NOT QU-state (by index) 00391 * 00392 * @param index 00393 * State index 00394 */ 00395 void ClrQU(Idx index); 00396 00397 /** 00398 * Mark state as NOT QU-state (by name) 00399 * 00400 * @param rName 00401 * State name 00402 */ 00403 void ClrQU(const std::string& rName); 00404 00405 /** 00406 * Mark set of states as NOT QU-states (by index) 00407 * 00408 * @param rStates 00409 * StateSet 00410 */ 00411 void ClrQU(const StateSet& rStates); 00412 00413 /** Is state QU-state (by index) 00414 * 00415 * @param index 00416 * State index 00417 * 00418 * @return 00419 * True / false 00420 */ 00421 bool IsQU(Idx index) const; 00422 00423 /** 00424 * Is state QU-state (by name) 00425 * 00426 * @param rName 00427 * State name 00428 * 00429 * @return 00430 * True / false 00431 */ 00432 bool IsQU(const std::string& rName) const; 00433 00434 /** 00435 * Get StateSet with QU-states 00436 * 00437 * @return 00438 * StateSet of QU-states 00439 */ 00440 StateSet QUStates(void) const; 00441 00442 /** 00443 * Mark state as Err-state (by index) 00444 * 00445 * @param index 00446 * State index 00447 */ 00448 void SetErr(Idx index); 00449 00450 /** 00451 * Mark state as Err-state (by name) 00452 * 00453 * @param rName 00454 * State name 00455 */ 00456 void SetErr(const std::string& rName); 00457 00458 /** 00459 * Mark set of states as Err-states 00460 * 00461 * @param rStates 00462 * StateSet 00463 */ 00464 void SetErr(const StateSet& rStates); 00465 00466 /** Mark state as NOT Err-state (by index) 00467 * 00468 * @param index 00469 * State index 00470 */ 00471 void ClrErr(Idx index); 00472 00473 /** 00474 * Mark state as NOT Err-state (by name) 00475 * 00476 * @param rName 00477 * State name 00478 */ 00479 void ClrErr(const std::string& rName); 00480 00481 /** 00482 * Mark set of states as NOT Err-states (by index) 00483 * 00484 * @param rStates 00485 * StateSet 00486 */ 00487 void ClrErr(const StateSet& rStates); 00488 00489 /** Is state Err-state (by index) 00490 * 00491 * @param index 00492 * State index 00493 * 00494 * @return 00495 * True / false 00496 */ 00497 bool IsErr(Idx index) const; 00498 00499 /** 00500 * Is state Err-state (by name) 00501 * 00502 * @param rName 00503 * State name 00504 * 00505 * @return 00506 * True / false 00507 */ 00508 bool IsErr(const std::string& rName) const; 00509 00510 /** 00511 * Get StateSet with Err-states 00512 * 00513 * @return 00514 * StateSet of Err-states 00515 */ 00516 StateSet ErrStates(void) const; 00517 00518 /** 00519 * Updates internal attributes. 00520 * This method sets the state partition attributes. 00521 * 00522 * @return True if value changed 00523 */ 00524 virtual bool UpdateAttributes(void) {IsHioConstraintForm(*this); return true;}; 00525 00526 private: 00527 00528 protected: 00529 00530 }; // end class THioConstraint 00531 00532 00533 // convenience typedef for std HioConstraint 00534 typedef THioConstraint<AttributeVoid, HioStateFlags, HioEventFlags, AttributeVoid> HioConstraint; 00535 00536 /* convenience access to relevant scopes */ 00537 #define THIS THioConstraint<GlobalAttr, StateAttr, EventAttr, TransAttr> 00538 #define BASE TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> 00539 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr> 00540 00541 00542 // THioConstraint(void) 00543 TEMP THIS::THioConstraint(void) : BASE() { 00544 FD_DG("HioConstraint(" << this << ")::HioConstraint()"); 00545 } 00546 00547 // THioConstraint(rOtherGen) 00548 TEMP THIS::THioConstraint(const THioConstraint& rOtherGen) : BASE(rOtherGen) { 00549 FD_DG("HioConstraint(" << this << ")::HioConstraint(rOtherGen)"); 00550 } 00551 00552 // THioConstraint(rOtherGen) 00553 TEMP THIS::THioConstraint(const Generator& rOtherGen) : BASE(rOtherGen) { 00554 FD_DG("HioConstraint(" << this << ")::HioConstraint(rOtherGen)"); 00555 } 00556 00557 // THioConstraint(rOtherGen,rY,rU) 00558 TEMP THIS::THioConstraint( 00559 const Generator& rOtherGen, 00560 const EventSet& rY, 00561 const EventSet& rU 00562 ) : BASE(rOtherGen) { 00563 FD_DG("HioConstraint(" << this << ")::HioConstraint(rOtherGen)"); 00564 SetY(rY); 00565 SetU(rU); 00566 } 00567 00568 // THioConstraint(rFileName) 00569 TEMP THIS::THioConstraint(const std::string& rFileName) : BASE(rFileName) { 00570 FD_DG("HioConstraint(" << this << ")::HioConstraint(rFilename) : done"); 00571 } 00572 00573 // New() 00574 TEMP THIS* THIS::New(void) const { 00575 // allocate 00576 THIS* res = new THIS; 00577 // fix base data 00578 res->EventSymbolTablep(BASE::mpEventSymbolTable); 00579 res->mStateNamesEnabled=BASE::mStateNamesEnabled; 00580 return res; 00581 } 00582 00583 // Copy() 00584 TEMP THIS* THIS::Copy(void) const { 00585 return new THIS(*this); 00586 } 00587 00588 // NewHioConstraint() 00589 TEMP THIS THIS::NewHioConstraint(void) const { 00590 // call base (fixes by assignment constructor) 00591 THIS res= BASE::NewAGen(); 00592 return res; 00593 } 00594 00595 /******************************************************/ 00596 00597 // IsY(index) 00598 TEMP bool THIS::IsY(Idx index) const { 00599 EventAttr attr=BASE::EventAttribute(index); 00600 return attr.IsY(); 00601 } 00602 00603 // IsY(rName) 00604 TEMP bool THIS::IsY(const std::string& rName) const { 00605 EventAttr attr=BASE::EventAttribute(rName); 00606 return attr.IsY(); 00607 } 00608 00609 // IsU(index) 00610 TEMP bool THIS::IsU(Idx index) const { 00611 EventAttr attr=BASE::EventAttribute(index); 00612 return attr.IsU(); 00613 } 00614 00615 // IsU(rName) 00616 TEMP bool THIS::IsU(const std::string& rName) const { 00617 EventAttr attr=BASE::EventAttribute(rName); 00618 return attr.IsU(); 00619 } 00620 00621 //YEvents() 00622 TEMP EventSet THIS::YEvents(void) const { 00623 FD_DG("HioConstraint(" << this << ")::YEvents()"); 00624 EventSet res; 00625 EventSet::Iterator it; 00626 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 00627 if(IsY(*it)) res.Insert(*it); 00628 } 00629 return res; 00630 } 00631 00632 //UEvents() 00633 TEMP EventSet THIS::UEvents(void) const { 00634 FD_DG("HioConstraint(" << this << ")::UEvents()"); 00635 EventSet res; 00636 EventSet::Iterator it; 00637 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 00638 if(IsU(*it)) res.Insert(*it); 00639 } 00640 return res; 00641 } 00642 00643 /*****************************************************************/ 00644 00645 // InsYEvent(index) 00646 TEMP void THIS::InsYEvent(Idx index) { 00647 FD_DG("HioConstraint(" << this << ")::InsYEvent(" << index << ")"); 00648 EventAttr attr; 00649 attr.SetY(); 00650 BASE::InsEvent(index,attr); 00651 } 00652 00653 // InsYEvent(rName) 00654 TEMP Idx THIS::InsYEvent(const std::string& rName) { 00655 FD_DG("HioConstraint(" << this << ")::InsYEvent(" << rName << ")"); 00656 EventAttr attr; 00657 attr.SetY(); 00658 return BASE::InsEvent(rName,attr); 00659 } 00660 00661 // InsUEvent(index) 00662 TEMP void THIS::InsUEvent(Idx index) { 00663 FD_DG("HioConstraint(" << this << ")::InsUEvent(" << index << ")"); 00664 EventAttr attr; 00665 attr.SetU(); 00666 BASE::InsEvent(index,attr); 00667 } 00668 00669 // InsUEvent(rName) 00670 TEMP Idx THIS::InsUEvent(const std::string& rName) { 00671 FD_DG("HioConstraint(" << this << ")::InsUEvent(" << rName << ")"); 00672 EventAttr attr; 00673 attr.SetU(); 00674 return BASE::InsEvent(rName,attr); 00675 } 00676 00677 // SetY(index) 00678 TEMP void THIS::SetY(Idx index) { 00679 FD_DG("HioConstraint(" << this << ")::SetY(" << index << ")"); 00680 EventAttr attr=BASE::EventAttribute(index); 00681 attr.SetY(); 00682 BASE::pAlphabet->Attribute(index,attr); 00683 } 00684 00685 // SetY(rName) 00686 TEMP void THIS::SetY(const std::string& rName) { 00687 FD_DG("HioConstraint(" << this << ")::SetY(" << rName << ")"); 00688 Idx index = BASE::EventIndex(rName); 00689 SetY(index); 00690 } 00691 00692 //SetY(rEvents) 00693 TEMP void THIS::SetY(const EventSet& rEvents) { 00694 FD_DG("HioConstraint(" << this << ")::SetY(rEvents)"); 00695 EventSet::Iterator it; 00696 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 00697 SetY(*it); 00698 } 00699 } 00700 00701 // SetU(index) 00702 TEMP void THIS::SetU(Idx index) { 00703 FD_DG("HioConstraint(" << this << ")::SetU(" << index << ")"); 00704 EventAttr attr=BASE::EventAttribute(index); 00705 attr.SetU(); 00706 BASE::pAlphabet->Attribute(index,attr); 00707 } 00708 00709 // SetU(rName) 00710 TEMP void THIS::SetU(const std::string& rName) { 00711 FD_DG("HioConstraint(" << this << ")::SetU(" << rName << ")"); 00712 Idx index = BASE::EventIndex(rName); 00713 SetU(index); 00714 } 00715 00716 //SetU(rEvents) 00717 TEMP void THIS::SetU(const EventSet& rEvents) { 00718 FD_DG("HioConstraint(" << this << ")::SetU(rEvents)"); 00719 EventSet::Iterator it; 00720 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 00721 SetU(*it); 00722 } 00723 } 00724 00725 /******************************************************************* 00726 *****************Implementation of the state attributes************* 00727 *******************************************************************/ 00728 00729 // SetQY(index) 00730 TEMP void THIS::SetQY(Idx index) { 00731 FD_DG("HioConstraint(" << this << ")::SetQY(" << index << ")"); 00732 StateAttr attr=BASE::StateAttribute(index); 00733 attr.SetQY(); 00734 attr.ClrQU(); 00735 attr.ClrQC(); 00736 attr.ClrQP(); 00737 attr.ClrQE(); 00738 attr.ClrQL(); 00739 attr.ClrQYcUp(); 00740 attr.ClrQYlUe(); 00741 BASE::pStates->Attribute(index,attr); 00742 } 00743 00744 // SetQY(rName) 00745 TEMP void THIS::SetQY(const std::string& rName) { 00746 FD_DG("HioConstraint(" << this << ")::SetQY(" << rName << ")"); 00747 Idx index = BASE::StateIndex(rName); 00748 SetQY(index); 00749 } 00750 00751 //SetQY(rStates) 00752 TEMP void THIS::SetQY(const StateSet& rStates) { 00753 FD_DG("HioConstraint(" << this << ")::SetQY(rStates)"); 00754 StateSet::Iterator sit; 00755 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) { 00756 SetQY(*sit); 00757 } 00758 } 00759 00760 // ClrQY(index) 00761 TEMP void THIS::ClrQY(Idx index) { 00762 FD_DG("HioConstraint(" << this << ")::ClrQY(" << index << ")"); 00763 StateAttr attr=BASE::StateAttribute(index); 00764 attr.ClrQY(); 00765 BASE::pStates->Attribute(index,attr); 00766 } 00767 00768 // ClrQY(rName) 00769 TEMP void THIS::ClrQY(const std::string& rName) { 00770 FD_DG("HioConstraint(" << this << ")::ClrQY(" << rName << ")"); 00771 Idx index = BASE::StateIndex(rName); 00772 ClrQY(index); 00773 } 00774 00775 //ClrQY(rStates) 00776 TEMP void THIS::ClrQY(const StateSet& rStates) { 00777 FD_DG("HioConstraint(" << this << ")::ClrQY(rStates)"); 00778 StateSet::Iterator sit; 00779 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) { 00780 ClrQY(*sit); 00781 } 00782 } 00783 00784 // IsQY(index) 00785 TEMP bool THIS::IsQY(Idx index) const { 00786 StateAttr attr=BASE::StateAttribute(index); 00787 return attr.IsQY(); 00788 } 00789 00790 // IsQY(rName) 00791 TEMP bool THIS::IsQY(const std::string& rName) const { 00792 Idx index = BASE::StateIndex(rName); 00793 return IsQY(index); 00794 } 00795 00796 //QYStates() 00797 TEMP StateSet THIS::QYStates(void) const { 00798 FD_DG("HioConstraint(" << this << ")::QYStates()"); 00799 StateSet res; 00800 StateSet::Iterator sit; 00801 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) { 00802 if(IsQY(*sit)) res.Insert(*sit); 00803 } 00804 return res; 00805 } 00806 /***************************************************************************/ 00807 00808 // SetQU(index) 00809 TEMP void THIS::SetQU(Idx index) { 00810 FD_DG("HioConstraint(" << this << ")::SetQU(" << index << ")"); 00811 StateAttr attr=BASE::StateAttribute(index); 00812 attr.SetQU(); 00813 attr.ClrQY(); 00814 attr.ClrQC(); 00815 attr.ClrQP(); 00816 attr.ClrQE(); 00817 attr.ClrQL(); 00818 attr.ClrQYcUp(); 00819 attr.ClrQYlUe(); 00820 BASE::pStates->Attribute(index,attr); 00821 } 00822 00823 // SetQU(rName) 00824 TEMP void THIS::SetQU(const std::string& rName) { 00825 FD_DG("HioConstraint(" << this << ")::SetQU(" << rName << ")"); 00826 Idx index = BASE::StateIndex(rName); 00827 SetQU(index); 00828 } 00829 00830 //SetQU(rStates) 00831 TEMP void THIS::SetQU(const StateSet& rStates) { 00832 FD_DG("HioConstraint(" << this << ")::SetQU(rStates)"); 00833 StateSet::Iterator sit; 00834 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) { 00835 SetQU(*sit); 00836 } 00837 } 00838 00839 // ClrQU(index) 00840 TEMP void THIS::ClrQU(Idx index) { 00841 FD_DG("HioConstraint(" << this << ")::ClrQU(" << index << ")"); 00842 StateAttr attr=BASE::StateAttribute(index); 00843 attr.ClrQU(); 00844 BASE::pStates->Attribute(index,attr); 00845 } 00846 00847 // ClrQU(rName) 00848 TEMP void THIS::ClrQU(const std::string& rName) { 00849 FD_DG("HioConstraint(" << this << ")::ClrQU(" << rName << ")"); 00850 Idx index = BASE::StateIndex(rName); 00851 ClrQU(index); 00852 } 00853 00854 //ClrQU(rStates) 00855 TEMP void THIS::ClrQU(const StateSet& rStates) { 00856 FD_DG("HioConstraint(" << this << ")::ClrQU(rStates)"); 00857 StateSet::Iterator sit; 00858 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) { 00859 ClrQU(*sit); 00860 } 00861 } 00862 00863 // IsQU(index) 00864 TEMP bool THIS::IsQU(Idx index) const { 00865 StateAttr attr=BASE::StateAttribute(index); 00866 return attr.IsQU(); 00867 } 00868 00869 // IsQU(rName) 00870 TEMP bool THIS::IsQU(const std::string& rName) const { 00871 Idx index = BASE::StateIndex(rName); 00872 return IsQU(index); 00873 } 00874 00875 //QUStates() 00876 TEMP StateSet THIS::QUStates(void) const { 00877 FD_DG("HioConstraint(" << this << ")::QUStates()"); 00878 StateSet res; 00879 StateSet::Iterator sit; 00880 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) { 00881 if(IsQU(*sit)) res.Insert(*sit); 00882 } 00883 return res; 00884 } 00885 00886 // SetErr(index) 00887 TEMP void THIS::SetErr(Idx index) { 00888 FD_DG("HioPlant(" << this << ")::SetErr(" << index << ")"); 00889 StateAttr attr=BASE::StateAttribute(index); 00890 attr.SetErr(); 00891 BASE::pStates->Attribute(index,attr); 00892 } 00893 00894 // SetErr(rName) 00895 TEMP void THIS::SetErr(const std::string& rName) { 00896 FD_DG("HioPlant(" << this << ")::SetErr(" << rName << ")"); 00897 Idx index = BASE::StateIndex(rName); 00898 SetErr(index); 00899 } 00900 00901 //SetErr(rStates) 00902 TEMP void THIS::SetErr(const StateSet& rStates) { 00903 FD_DG("HioPlant(" << this << ")::SetErr(rStates)"); 00904 StateSet::Iterator sit; 00905 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) { 00906 SetErr(*sit); 00907 } 00908 } 00909 00910 // ClrErr(index) 00911 TEMP void THIS::ClrErr(Idx index) { 00912 FD_DG("HioPlant(" << this << ")::ClrErr(" << index << ")"); 00913 StateAttr attr=BASE::StateAttribute(index); 00914 attr.ClrErr(); 00915 BASE::pStates->Attribute(index,attr); 00916 } 00917 00918 // ClrErr(rName) 00919 TEMP void THIS::ClrErr(const std::string& rName) { 00920 FD_DG("HioPlant(" << this << ")::ClrErr(" << rName << ")"); 00921 Idx index = BASE::StateIndex(rName); 00922 ClrErr(index); 00923 } 00924 00925 //ClrErr(rStates) 00926 TEMP void THIS::ClrErr(const StateSet& rStates) { 00927 FD_DG("HioPlant(" << this << ")::ClrErr(rStates)"); 00928 StateSet::Iterator sit; 00929 for(sit=rStates.Begin(); sit!=rStates.End(); sit++) { 00930 ClrErr(*sit); 00931 } 00932 } 00933 00934 // IsErr(index) 00935 TEMP bool THIS::IsErr(Idx index) const { 00936 StateAttr attr=BASE::StateAttribute(index); 00937 return attr.IsErr(); 00938 } 00939 00940 // IsErr(rName) 00941 TEMP bool THIS::IsErr(const std::string& rName) const { 00942 Idx index = BASE::StateIndex(rName); 00943 return IsErr(index); 00944 } 00945 00946 //ErrStates() 00947 TEMP StateSet THIS::ErrStates(void) const { 00948 FD_DG("HioPlant(" << this << ")::ErrStates()"); 00949 StateSet res; 00950 StateSet::Iterator sit; 00951 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) { 00952 if(IsErr(*sit)) res.Insert(*sit); 00953 } 00954 return res; 00955 } 00956 00957 00958 /***************************************************************************/ 00959 00960 #undef TEMP 00961 #undef BASE 00962 #undef THIS 00963 00964 /** 00965 * IsHioConstraintForm: check if rHioConstraint is in I/O-constraint form and assign state 00966 * attributes. 00967 * This function tests if rHioConstraint meets the I/O-constraint form that has been formally 00968 * defined by S.Perk. If so, then the alphabet of and the language marked by 00969 * rHioConstraint formally describe an I/O constraint. During the test, the HioStateFlags are 00970 * set according to the active event set or the respective state, for example: 00971 * The QY flag is assigned to a state if its active eventset is a subset of the Y-Alphabet. 00972 * The assignment of HioStateFlags is complete only if IsHioConstraintForm() returns true. 00973 * Method: all conditions in the formal I/O-constraint form definition are checked 00974 * individually. If crucial conditions are violated, the test of remaining 00975 * conditions is omitted. 00976 * 00977 * @param rHioConstraint 00978 * HioConstraint to check, HioStateFlags are set 00979 * @param rQY 00980 * State set containing all QY states 00981 * @param rQU 00982 * State set containing all QU states 00983 * @param rErrEvSet 00984 * Event set for possible 'bad' events 00985 * @param rErrTrSet 00986 * Event set for possible 'bad' transition relations 00987 * @param rErrStSet 00988 * Event set for possible 'bad' states 00989 * @param rReportStr 00990 * Information about test results 00991 * @return 00992 * true if rHioConstraint is in I/O-constraint form 00993 */ 00994 00995 bool IsHioConstraintForm(HioConstraint& rHioConstraint, 00996 StateSet& rQY, 00997 StateSet& rQU, 00998 EventSet& rErrEvSet, 00999 TransSet& rErrTrSet, 01000 StateSet& rErrStSet, 01001 std::string& rReportStr); 01002 01003 /** 01004 * IsHioConstraintForm: check if rHioConstraint is in I/O-constraint form and assign state 01005 * attributes. 01006 * This function tests if rHioConstraint meets the I/O-constraint form that has been formally 01007 * defined by S.Perk. If so, then the alphabet of and the language marked by 01008 * rHioConstraint formally describe an I/O constraint. During the test, the HioStateFlags are 01009 * set according to the active event set or the respective state, for example: 01010 * The QY flag is assigned to a state if its active eventset is a subset of the Y-Alphabet. 01011 * The assignment of HioStateFlags is complete only if IsHioConstraintForm() returns true. 01012 * Method: all conditions in the formal I/O-constraint form definition are checked 01013 * individually. If crucial conditions are violated, the test of remaining 01014 * conditions is omitted. 01015 * 01016 * @param rHioConstraint 01017 * HioConstraint to check, HioStateFlags are set 01018 * @param rReportStr 01019 * Information about test results 01020 * @return 01021 * true if rHioConstraint is in I/O-constraint form 01022 */ 01023 bool IsHioConstraintForm(HioConstraint& rHioConstraint,std::string& rReportStr); 01024 01025 /** 01026 * IsHioConstraintForm: check if rHioConstraint is in I/O-constraint form and assign state 01027 * attributes. 01028 * This function tests if rHioConstraint meets the I/O-constraint form that has been formally 01029 * defined by S.Perk. If so, then the alphabet of and the language marked by 01030 * rHioConstraint formally describe an I/O constraint. During the test, the HioStateFlags are 01031 * set according to the active event set or the respective state, for example: 01032 * The QY flag is assigned to a state if its active eventset is a subset of the Y-Alphabet. 01033 * The assignment of HioStateFlags is complete only if IsHioConstraintForm() returns true. 01034 * Method: all conditions of the formal I/O-constraint form definition are checked 01035 * individually. If crucial conditions are violated, the test of remaining 01036 * conditions is omitted. 01037 * 01038 * @param rHioConstraint 01039 * HioConstraint to check, HioStateFlags are set 01040 * @return 01041 * true if rHioConstraint is in I/O-constraint form 01042 */ 01043 bool IsHioConstraintForm(HioConstraint& rHioConstraint); 01044 01045 /** 01046 * Function definition for run-time interface 01047 * 01048 * @param rConstraint 01049 * HioConstraint 01050 */ 01051 void HioStatePartition(HioConstraint& rConstraint); 01052 01053 } // namespace faudes 01054 01055 #endif libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |