cfl_cgenerator.hGo to the documentation of this file.00001 /** @file cfl_cgenerator.h Classes TcGenerator, System and AttributeCFlags */ 00002 00003 /* FAU Discrete Event Systems Library (libfaudes) 00004 00005 Copyright (C) 2006 Bernd Opitz 00006 Copyright (C) 2007 Thomas Moor 00007 Exclusive copyright is granted to Klaus Schmidt 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 00022 00023 00024 #ifndef FAUDES_CGENERATOR_H 00025 #define FAUDES_CGENERATOR_H 00026 00027 #include "cfl_definitions.h" 00028 #include "cfl_agenerator.h" 00029 #include "cfl_parallel.h" 00030 #include "cfl_project.h" 00031 00032 00033 namespace faudes { 00034 00035 00036 /** 00037 * Attribute class to model event controllability properties. 00038 * 00039 * This attribute is meant to be an event attribute and can distinguish between 00040 * controllable, observable, forcible and abstraction events. It is based on faudes::AttributeFlags 00041 * and uses the lower four bits in the flag word to store the respective boolean values. 00042 * The AttributeCFlags class adds convenience functions to access these bits and a default-value 00043 * that corresponds to observable and neiter controllable nor forcible. 00044 * 00045 * Presuming that only controllability flags are uses (different from default), the 00046 * token representation is by an Option String consisting of the initials <tt>c</tt>,<tt>o</tt>,<tt>f</tt> 00047 * and <tt>a</tt>, where initials are capitatised for set flags and default values 00048 * are not written; eg <tt>+C+</tt> 00049 * for a controllable event that is observable (default), not forcible (default) and 00050 * an abstraction event (default). 00051 * If other than the four controllability bits are used, std. hex format is used. 00052 * 00053 */ 00054 00055 00056 class AttributeCFlags : public AttributeFlags { 00057 00058 FAUDES_TYPE_DECLARATION(Void,AttributeCFlags,AttributeFlags) 00059 00060 public: 00061 /** 00062 * Default constructor 00063 */ 00064 AttributeCFlags(void) : AttributeFlags() { mFlags=mDefCFlags; }; 00065 00066 /** Destructor */ 00067 virtual ~AttributeCFlags(void) {}; 00068 00069 /** 00070 * Set controllable flag 00071 */ 00072 void SetControllable(void) { mFlags |= mControllableFlag; } 00073 00074 /** 00075 * Clear controllable flag 00076 */ 00077 00078 void ClrControllable(void) { mFlags &= ~mControllableFlag; }; 00079 00080 /** 00081 * Query controllablility 00082 */ 00083 bool Controllable(void) const {return ( (mFlags & mControllableFlag) != 0 ); } 00084 00085 00086 /** 00087 * Set observable flag 00088 */ 00089 void SetObservable(void) { mFlags |= mObservableFlag; } 00090 00091 /** 00092 * Clear observable flag 00093 */ 00094 void ClrObservable(void) { mFlags &= ~mObservableFlag; }; 00095 00096 /** 00097 * Query observablility 00098 */ 00099 bool Observable(void) const {return ( (mFlags & mObservableFlag) != 0 ); } 00100 00101 00102 /** 00103 * Set forcible flag 00104 */ 00105 void SetForcible(void) { mFlags |= mForcibleFlag; } 00106 00107 /** 00108 * Clear forcible flag 00109 */ 00110 00111 void ClrForcible(void) { mFlags &= ~mForcibleFlag; }; 00112 00113 /** 00114 * Query forcibility 00115 */ 00116 bool Forcible(void) const {return ( (mFlags & mForcibleFlag) != 0 ); } 00117 00118 00119 /** 00120 * Set abstraction flag 00121 */ 00122 void SetHighlevel(void) { mFlags |= mAbstractionFlag; } 00123 00124 /** 00125 * Clear abstraction flag 00126 */ 00127 void SetLowlevel(void) { mFlags &= ~mAbstractionFlag; }; 00128 00129 /** 00130 * Query abstaction flag 00131 */ 00132 bool Highlevel(void) const {return ( (mFlags & mAbstractionFlag) != 0 ); } 00133 00134 /** 00135 * Query abstaction flag 00136 */ 00137 bool Lowlevel(void) const {return ( (mFlags & mAbstractionFlag) == 0 ); } 00138 00139 00140 /** 00141 * Test for default value 00142 */ 00143 virtual bool IsDefault(void) const {return mFlags==mDefCFlags;}; 00144 00145 // flag masks for the three properties 00146 const static fType mControllableFlag =0x01; 00147 const static fType mObservableFlag =0x02; 00148 const static fType mForcibleFlag =0x04; 00149 const static fType mAbstractionFlag =0x08; 00150 00151 private: 00152 /** Overall default value */ 00153 const static fType mDefCFlags =0x0a; 00154 00155 /** All flags used by CFlags */ 00156 const static fType mAllCFlags =0x0f; 00157 00158 protected: 00159 00160 /** 00161 * Assignment method. 00162 * 00163 * @param rSrcAttr 00164 * Source to assign from 00165 */ 00166 void DoAssign(const AttributeCFlags& rSrcAttr); 00167 00168 /** 00169 * Test equality of configuration data. 00170 * 00171 * @param rOther 00172 * Other attribute to compare with. 00173 * @return 00174 * True on match. 00175 */ 00176 virtual bool DoEqual(const AttributeCFlags& rOther) const; 00177 00178 /** 00179 * Reads attribute from TokenReader, see AttributeVoid for public wrappers. 00180 * Reads a single token if it can be interpreted as AttributeCFlag, that is, if 00181 * it is a respective option string or hex number. Label and Context 00182 * argument are ignored. No token mismatch exceptions are thrown on error. 00183 * 00184 * @param rTr 00185 * TokenReader to read from 00186 * @param rLabel 00187 * Section to read 00188 * @param pContext 00189 * Read context to provide contextual information 00190 * 00191 * @exception Exception 00192 * - IO error (id 1) 00193 */ 00194 virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0); 00195 00196 /** 00197 * Writes attribute to TokenWriter, see AttributeVoid for public wrappers. 00198 * Label and Context argument are ignored. 00199 * 00200 * @param rTw 00201 * TokenWriter to write to 00202 * @param rLabel 00203 * Section to write 00204 * @param pContext 00205 * Write context to provide contextual information 00206 * 00207 * @exception Exception 00208 * - IO error (id 2) 00209 */ 00210 virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const; 00211 00212 00213 /** 00214 * Writes attribute to TokenWriter (XML format), see AttributeVoid for public wrappers. 00215 * Label and Context argument are ignored. 00216 * 00217 * @param rTw 00218 * TokenWriter to write to 00219 * @param rLabel 00220 * Section to write 00221 * @param pContext 00222 * Write context to provide contextual information 00223 * 00224 * @exception Exception 00225 * - IO error (id 2) 00226 */ 00227 virtual void DoXWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const; 00228 00229 00230 00231 }; // class AttributeCFlags 00232 00233 00234 00235 /** 00236 * Convenience typedef for event sets with controllability attributes. 00237 * 00238 * @ingroup ContainerClasses 00239 */ 00240 typedef TaNameSet<AttributeCFlags> Alphabet; 00241 00242 /** Convenience typedef */ 00243 typedef TBaseVector<Alphabet> AlphaberVector; 00244 00245 /** Compatibility: pre 2.20b used cEventSet as C++ class name*/ 00246 #ifdef FAUDES_COMPATIBILITY 00247 typedef TaNameSet<AttributeCFlags> cEventSet; 00248 typedef TBaseVector<cEventSet> cEventSetVector; 00249 #endif 00250 00251 00252 /** 00253 * Generator with controllability attributes. 00254 * 00255 * @section Overview 00256 * 00257 * The TcGenerator is a variant of the TaGenerator to add an interface for events with 00258 * controllabilty attributes, ie an event may be controllable, observable or forcible. 00259 * 00260 * Technically, the construct is based on the specialized attribute class faudes::AttributeCFlags 00261 * that provides attributes with semantics for controllability properties. The TcGenerator 00262 * expects an event attribute template parameter with the minimum interface defined in AttribueCFlags. 00263 * Thus, you can add further semantics by deriving a class AttributeCFlagsAndMore from 00264 * AttribueeCFlags and use this as event attribute parameter for TcGenerator. To model 00265 * a plain finite state machine plus controllability properties, use TcGenerator with 00266 * AttributeCFlags for the event attribute parameter and AttributeVoid for the other 00267 * parameters. For convenience, this has been typedef-ed as System. 00268 * 00269 * @ingroup GeneratorClasses 00270 */ 00271 00272 template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr> 00273 class TcGenerator : public TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> { 00274 public: 00275 /** 00276 * Creates an emtpy System object 00277 */ 00278 TcGenerator(void); 00279 00280 /** 00281 * System from a std Generator. Copy constructor 00282 * 00283 * @param rOtherGen 00284 */ 00285 TcGenerator(const vGenerator& rOtherGen); 00286 00287 /** 00288 * System from a System. Copy constructor 00289 * 00290 * @param rOtherGen 00291 */ 00292 TcGenerator(const TcGenerator& rOtherGen); 00293 00294 /** 00295 * construct a System from file 00296 * 00297 * @param rFileName 00298 * Filename 00299 * 00300 * @exception Exception 00301 * If opening/reading fails an Exception object is thrown (id 1, 50, 51) 00302 */ 00303 TcGenerator(const std::string& rFileName); 00304 00305 /** 00306 * Construct on heap 00307 * 00308 * @return 00309 * new Generator 00310 */ 00311 TcGenerator* New(void) const; 00312 00313 /** 00314 * Construct copy on heap 00315 * 00316 * @return 00317 * new Generator 00318 */ 00319 TcGenerator* Copy(void) const; 00320 00321 /** 00322 * Type test. 00323 * Uses C++ dynamic cast to test whether the specified object 00324 * casts to a System. 00325 * 00326 * @return 00327 * TcGenerator reference if dynamic cast succeeds, else NULL 00328 */ 00329 virtual const Type* Cast(const Type* pOther) const { 00330 return dynamic_cast< const TcGenerator* > (pOther); }; 00331 00332 00333 /** 00334 * Construct on stack 00335 * 00336 * @return 00337 * new Generator 00338 */ 00339 TcGenerator NewCGen(void) const; 00340 00341 /** 00342 * Assignment operator (uses copy ) 00343 * Note: you must reimplement this operator in derived 00344 * classes in order to handle internal pointers correctly 00345 * 00346 * @param rOtherGen 00347 * Other generator 00348 */ 00349 virtual TcGenerator& operator= (const TcGenerator& rOtherGen) { this->Assign(rOtherGen); return *this;}; 00350 00351 /** 00352 * Assignment operator (uses copy ) 00353 * 00354 * @param rOtherGen 00355 * Other generator 00356 */ 00357 virtual TcGenerator& operator= (const vGenerator& rOtherGen) {this->Assign(rOtherGen); return *this;}; 00358 00359 /** 00360 * Add an existing controllable event to generator. 00361 * An entry in the global eventtable will be made. 00362 * 00363 * @param index 00364 * Event index 00365 */ 00366 void InsControllableEvent(Idx index); 00367 00368 /** 00369 * Add new named controllable event to generator. 00370 * An entry in the global eventtable will be made if event is new. 00371 * 00372 * @param rName 00373 * Name of the event to add 00374 * 00375 * @return 00376 * New global unique index 00377 */ 00378 Idx InsControllableEvent(const std::string& rName); 00379 00380 /** 00381 * Add an existing uncontrollable event to generator. 00382 * An entry in the global eventtable will be made. 00383 * 00384 * @param index 00385 * Event index 00386 */ 00387 void InsUncontrollableEvent(Idx index); 00388 00389 /** 00390 * Add new named uncontrollable event to generator. 00391 * An entry in the global eventtable will be made if event is new. 00392 * 00393 * @param rName 00394 * Name of the event to add 00395 * 00396 * @return 00397 * New global unique index 00398 */ 00399 Idx InsUncontrollableEvent(const std::string& rName); 00400 00401 /** 00402 * Mark event controllable (by index) 00403 * 00404 * @param index 00405 * Event index 00406 */ 00407 void SetControllable(Idx index); 00408 00409 /** 00410 * Mark event controllable (by name) 00411 * 00412 * @param rName 00413 * Event name 00414 */ 00415 void SetControllable(const std::string& rName); 00416 00417 /** 00418 * Mark set of events controllable (by index) 00419 * 00420 * @param rEvents 00421 * EventSet 00422 */ 00423 void SetControllable(const EventSet& rEvents); 00424 00425 /** 00426 * Mark event uncontrollable (by index) 00427 * 00428 * @param index 00429 * Event index 00430 */ 00431 void ClrControllable(Idx index); 00432 00433 /** 00434 * Mark event uncontrollable (by name) 00435 * 00436 * @param rName 00437 * Event name 00438 */ 00439 void ClrControllable(const std::string& rName); 00440 00441 /** 00442 * Mark set of events uncontrollable (by index) 00443 * 00444 * @param rEvents 00445 * EventSet 00446 */ 00447 void ClrControllable(const EventSet& rEvents); 00448 00449 /** 00450 * Is event controllable (by index) 00451 * 00452 * @param index 00453 * Event index 00454 * 00455 * @return 00456 * True / false 00457 */ 00458 bool Controllable(Idx index) const; 00459 00460 /** 00461 * Is event controllable (by name) 00462 * 00463 * @param rName 00464 * Event name 00465 * 00466 * @return 00467 * True / false 00468 */ 00469 bool Controllable(const std::string& rName) const; 00470 00471 /** 00472 * Get EventSet with controllable events 00473 * 00474 * @return 00475 * EventSet of controllable events 00476 */ 00477 EventSet ControllableEvents(void) const; 00478 00479 /** 00480 * Get EventSet with uncontrollable events 00481 * 00482 * @return 00483 * EventSet of uncontrollable events 00484 */ 00485 EventSet UncontrollableEvents(void) const; 00486 00487 /** 00488 * Add an existing observable event to generator. 00489 * An entry in the global eventtable will be made. 00490 * 00491 * @param index 00492 * Event index 00493 */ 00494 void InsObservableEvent(Idx index); 00495 00496 /** 00497 * Add new named observable event to generator. 00498 * An entry in the global eventtable will be made if event is new. 00499 * 00500 * @param rName 00501 * Name of the event to add 00502 * 00503 * @return 00504 * New global unique index 00505 */ 00506 Idx InsObservableEvent(const std::string& rName); 00507 00508 /** 00509 * Add an existing unobservable event to generator. 00510 * An entry in the global eventtable will be made. 00511 * 00512 * @param index 00513 * Event index 00514 */ 00515 void InsUnobservableEvent(Idx index); 00516 00517 /** 00518 * Add new named unobservable event to generator. 00519 * An entry in the global eventtable will be made if event is new. 00520 * 00521 * @param rName 00522 * Name of the event to add 00523 * 00524 * @return 00525 * New global unique index 00526 */ 00527 Idx InsUnobservableEvent(const std::string& rName); 00528 00529 /** 00530 * Mark event observable (by index) 00531 * 00532 * @param index 00533 * Event index 00534 */ 00535 void SetObservable(Idx index); 00536 00537 /** 00538 * Mark event observable (by name) 00539 * 00540 * @param rName 00541 * Event name 00542 */ 00543 void SetObservable(const std::string& rName); 00544 00545 /** 00546 * Mark set of events observable 00547 * 00548 * @param rEvents 00549 * EventSet 00550 */ 00551 void SetObservable(const EventSet& rEvents); 00552 00553 /** 00554 * Mark event unobservable (by index) 00555 * 00556 * @param index 00557 * Event index 00558 */ 00559 void ClrObservable(Idx index); 00560 00561 /** 00562 * Mark event unobservable (by name) 00563 * 00564 * @param rName 00565 * Event name 00566 */ 00567 void ClrObservable(const std::string& rName); 00568 00569 /** 00570 * Mark set of events unobservable 00571 * 00572 * @param rEvents 00573 * EventSet 00574 */ 00575 void ClrObservable(const EventSet& rEvents); 00576 00577 /** 00578 * Is event observable (by index) 00579 * 00580 * @param index 00581 * Event index 00582 * 00583 * @return 00584 * True / false 00585 */ 00586 bool Observable(Idx index) const; 00587 00588 /** 00589 * Is event observable (by name) 00590 * 00591 * @param rName 00592 * Event name 00593 * 00594 * @return 00595 * True / false 00596 */ 00597 bool Observable(const std::string& rName) const; 00598 00599 /** 00600 * Get EventSet with observable events 00601 * 00602 * @return 00603 * EventSet of controllable events 00604 */ 00605 EventSet ObservableEvents(void) const; 00606 00607 /** 00608 * Get EventSet with unobservable events 00609 * 00610 * @return 00611 * EventSet of uncontrollable events 00612 */ 00613 EventSet UnobservableEvents(void) const; 00614 00615 /** 00616 * Add an existing forcible event to generator. 00617 * An entry in the global eventtable will be made. 00618 * 00619 * @param index 00620 * Event index 00621 */ 00622 void InsForcibleEvent(Idx index); 00623 00624 /** 00625 * Add new named forcible event to generator. 00626 * An entry in the global eventtable will be made if event is new. 00627 * 00628 * @param rName 00629 * Name of the event to add 00630 * 00631 * @return 00632 * New global unique index 00633 */ 00634 Idx InsForcibleEvent(const std::string& rName); 00635 00636 /** 00637 * Add an existing unforcible event to generator. 00638 * An entry in the global eventtable will be made. 00639 * 00640 * @param index 00641 * Event index 00642 */ 00643 void InsUnforcibleEvent(Idx index); 00644 00645 /** 00646 * Add new named unforcible event to generator. 00647 * An entry in the global eventtable will be made if event is new. 00648 * 00649 * @param rName 00650 * Name of the event to add 00651 * 00652 * @return 00653 * New global unique index 00654 */ 00655 Idx InsUnforcibleEvent(const std::string& rName); 00656 00657 /** 00658 * Mark event forcible (by index) 00659 * 00660 * @param index 00661 * Event index 00662 */ 00663 void SetForcible(Idx index); 00664 00665 /** 00666 * Mark event forcible (by name) 00667 * 00668 * @param rName 00669 * Event name 00670 */ 00671 void SetForcible(const std::string& rName); 00672 00673 /** 00674 * Mark set of events forcible 00675 * 00676 * @param rEvents 00677 * EventSet 00678 */ 00679 void SetForcible(const EventSet& rEvents); 00680 00681 /** 00682 * Mark event unforcible (by index) 00683 * 00684 * @param index 00685 * Event index 00686 */ 00687 void ClrForcible(Idx index); 00688 00689 /** 00690 * Mark event unforcible (by name) 00691 * 00692 * @param rName 00693 * Event name 00694 */ 00695 void ClrForcible(const std::string& rName); 00696 00697 /** 00698 * Mark set of events unforcible 00699 * 00700 * @param rEvents 00701 * EventSet 00702 */ 00703 void ClrForcible(const EventSet& rEvents); 00704 00705 /** 00706 * Is event forcible (by index) 00707 * 00708 * @param index 00709 * Event index 00710 * 00711 * @return 00712 * True / false 00713 */ 00714 bool Forcible(Idx index) const; 00715 00716 /** 00717 * Is event forcible (by name) 00718 * 00719 * @param rName 00720 * Event name 00721 * 00722 * @return 00723 * True / false 00724 */ 00725 bool Forcible(const std::string& rName) const; 00726 00727 /** 00728 * Get EventSet with forcible events 00729 * 00730 * @return 00731 * EventSet of controllable events 00732 */ 00733 EventSet ForcibleEvents(void) const; 00734 00735 /** 00736 * Get EventSet with unforcible events 00737 * 00738 * @return 00739 * EventSet of uncontrollable events 00740 */ 00741 EventSet UnforcibleEvents(void) const; 00742 00743 /** 00744 * Add an existing abstraction event to generator. 00745 * An entry in the global eventtable will be made. 00746 * 00747 * @param index 00748 * Event index 00749 */ 00750 void InsHighlevelEvent(Idx index); 00751 00752 /** 00753 * Add new named abstraction event to generator. 00754 * An entry in the global eventtable will be made if event is new. 00755 * 00756 * @param rName 00757 * Name of the event to add 00758 * 00759 * @return 00760 * New global unique index 00761 */ 00762 Idx InsHighlevelEvent(const std::string& rName); 00763 00764 /** 00765 * Add an existing low-level event to generator. 00766 * An entry in the global eventtable will be made. 00767 * 00768 * @param index 00769 * Event index 00770 */ 00771 void InsLowlevelEvent(Idx index); 00772 00773 /** 00774 * Add new named low-level event to generator. 00775 * An entry in the global eventtable will be made if event is new. 00776 * 00777 * @param rName 00778 * Name of the event to add 00779 * 00780 * @return 00781 * New global unique index 00782 */ 00783 Idx InsLowlevelEvent(const std::string& rName); 00784 00785 /** 00786 * Mark event as highlevel event (by index) 00787 * 00788 * @param index 00789 * Event index 00790 */ 00791 void SetHighlevel(Idx index); 00792 00793 /** 00794 * Mark event as highlevel event (by name) 00795 * 00796 * @param rName 00797 * Event name 00798 */ 00799 void SetHighlevel(const std::string& rName); 00800 00801 /** 00802 * Mark set of events as high-level events 00803 * 00804 * @param rEvents 00805 * EventSet 00806 */ 00807 void SetHighlevel(const EventSet& rEvents); 00808 00809 /** 00810 * Mark event as low-level event (by index) 00811 * 00812 * @param index 00813 * Event index 00814 */ 00815 void SetLowlevel(Idx index); 00816 00817 /** 00818 * Mark event as low-level event (by name) 00819 * 00820 * @param rName 00821 * Event name 00822 */ 00823 void SetLowlevel(const std::string& rName); 00824 00825 /** 00826 * Mark set of events as low-level events. 00827 * 00828 * @param rEvents 00829 * EventSet 00830 */ 00831 void SetLowlevel(const EventSet& rEvents); 00832 00833 /** 00834 * Test for high-level event (by index) 00835 * 00836 * @param index 00837 * Event index 00838 * 00839 * @return 00840 * True / false 00841 */ 00842 bool Highlevel(Idx index) const; 00843 00844 /** 00845 * Test for high-level event (by name) 00846 * 00847 * @param rName 00848 * Event name 00849 * 00850 * @return 00851 * True / false 00852 */ 00853 bool Highlevel(const std::string& rName) const; 00854 00855 /** 00856 * Test for low-level event (by index) 00857 * 00858 * @param index 00859 * Event index 00860 * 00861 * @return 00862 * True / false 00863 */ 00864 bool Lowlevel(Idx index) const; 00865 00866 /** 00867 * Test for low-level event (by name) 00868 * 00869 * @param rName 00870 * Event name 00871 * 00872 * @return 00873 * True / false 00874 */ 00875 bool Lowlevel(const std::string& rName) const; 00876 00877 /** 00878 * Get EventSet of all high-level events 00879 * 00880 * @return 00881 * EventSet of high-level events 00882 */ 00883 EventSet HighlevelEvents(void) const; 00884 00885 /** 00886 * Get EventSet of all low-level events 00887 * 00888 * @return 00889 * EventSet of low-level events 00890 */ 00891 EventSet LowlevelEvents(void) const; 00892 00893 00894 private: 00895 00896 protected: 00897 00898 }; // end class TcGenerator 00899 00900 00901 /** 00902 * Convenience typedef for std System. 00903 * 00904 * @ingroup GeneratorClasses 00905 */ 00906 typedef TcGenerator<AttributeVoid, AttributeVoid, AttributeCFlags,AttributeVoid> System; 00907 00908 /** 00909 * Convenience typedef for vectors of systems 00910 * \ingroup GeneratorClasses 00911 */ 00912 typedef TBaseVector<System> SystemVector; 00913 00914 /** Compatibility: pre 2.20b used cGenerator as C++ class name*/ 00915 #ifdef FAUDES_COMPATIBILITY 00916 typedef TcGenerator<AttributeVoid, AttributeVoid, AttributeCFlags,AttributeVoid> cGenerator; 00917 typedef TBaseVector<cGenerator> cGeneratorVector; 00918 #endif 00919 00920 00921 00922 /* 00923 *************************************************************************** 00924 *************************************************************************** 00925 *************************************************************************** 00926 00927 Implementation cgenerator 00928 00929 *************************************************************************** 00930 *************************************************************************** 00931 *************************************************************************** 00932 */ 00933 00934 /* convenience access to relevant scopes */ 00935 #define THIS TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> 00936 #define BASE TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> 00937 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr> 00938 00939 00940 // TcGenerator(void) 00941 TEMP THIS::TcGenerator(void) : BASE() { 00942 FD_DG("TcGenerator(" << this << ")::TcGenerator()"); 00943 } 00944 00945 // TcGenerator(rOtherGen) 00946 TEMP THIS::TcGenerator(const TcGenerator& rOtherGen) : BASE(rOtherGen) { 00947 FD_DG("TcGenerator(" << this << ")::TcGenerator(rOtherGen)"); 00948 } 00949 00950 // TcGenerator(rOtherGen) 00951 TEMP THIS::TcGenerator(const vGenerator& rOtherGen) : BASE(rOtherGen) { 00952 FD_DG("TcGenerator(" << this << ")::TcGenerator(rOtherGen)"); 00953 } 00954 00955 // TcGenerator(rFilename) 00956 TEMP THIS::TcGenerator(const std::string& rFileName) : BASE(rFileName) { 00957 FD_DG("TcGenerator(" << this << ")::TcGenerator(rFilename) : done"); 00958 } 00959 00960 00961 // New 00962 TEMP THIS* THIS::New(void) const { 00963 // allocate 00964 THIS* res = new THIS; 00965 // fix base data 00966 res->EventSymbolTablep(BASE::mpEventSymbolTable); 00967 res->mStateNamesEnabled=BASE::mStateNamesEnabled; 00968 res->mReindexOnWrite=BASE::mReindexOnWrite; 00969 return res; 00970 } 00971 00972 // Copy 00973 TEMP THIS* THIS::Copy(void) const { 00974 // allocate 00975 THIS* res = new THIS(*this); 00976 // done 00977 return res; 00978 } 00979 00980 // NewCGen 00981 TEMP THIS THIS::NewCGen(void) const { 00982 // call base (fixes by assignment constructor) 00983 THIS res= BASE::NewAGen(); 00984 return res; 00985 } 00986 00987 00988 // CAST 00989 //TEMP const Type* THIS::Cast(const Type* pOther) const { 00990 // return dynamic_cast< const THIS* > (pOther); 00991 //} 00992 00993 00994 00995 // Controllable(index) 00996 TEMP bool THIS::Controllable(Idx index) const { 00997 EventAttr attr=BASE::EventAttribute(index); 00998 return attr.Controllable(); 00999 } 01000 01001 // Controllable(rName) 01002 TEMP bool THIS::Controllable(const std::string& rName) const { 01003 EventAttr attr=BASE::EventAttribute(rName); 01004 return attr.Controllable(); 01005 } 01006 01007 // InsControllableEvent(index) 01008 TEMP void THIS::InsControllableEvent(Idx index) { 01009 FD_DG("TcGenerator(" << this << ")::InsControllableEvent(" << index << ")"); 01010 EventAttr attr; 01011 attr.SetControllable(); 01012 BASE::InsEvent(index,attr); 01013 } 01014 01015 // InsControllableEvent(rName) 01016 TEMP Idx THIS::InsControllableEvent(const std::string& rName) { 01017 FD_DG("TcGenerator(" << this << ")::InsControllableEvent(" << rName << ")"); 01018 EventAttr attr; 01019 attr.SetControllable(); 01020 return BASE::InsEvent(rName,attr); 01021 } 01022 01023 // InsUncontrollableEvent(index) 01024 TEMP void THIS::InsUncontrollableEvent(Idx index) { 01025 FD_DG("TcGenerator(" << this << ")::InsUncontrollableEvent(" << index << ")"); 01026 EventAttr attr; 01027 attr.ClrControllable(); 01028 BASE::InsEvent(index,attr); 01029 } 01030 01031 // InsUncontrollableEvent(rName) 01032 TEMP Idx THIS::InsUncontrollableEvent(const std::string& rName) { 01033 FD_DG("TcGenerator(" << this << ")::InsUncontrollableEvent(" << rName << ")"); 01034 EventAttr attr; 01035 attr.ClrControllable(); 01036 return BASE::InsEvent(rName,attr); 01037 } 01038 01039 // SetControllable(index) 01040 TEMP void THIS::SetControllable(Idx index) { 01041 FD_DG("TcGenerator(" << this << ")::SetControllable(" << index << ")"); 01042 EventAttr attr=BASE::EventAttribute(index); 01043 attr.SetControllable(); 01044 BASE::pAlphabet->Attribute(index,attr); 01045 } 01046 01047 // SetControllable(rName) 01048 TEMP void THIS::SetControllable(const std::string& rName) { 01049 FD_DG("TcGenerator(" << this << ")::SetControllable(" << rName << ")"); 01050 Idx index = BASE::EventIndex(rName); 01051 SetControllable(index); 01052 } 01053 01054 //SetControllable(rEvents) 01055 TEMP void THIS::SetControllable(const EventSet& rEvents) { 01056 FD_DG("TcGenerator(" << this << ")::SetControllable(rEvents)"); 01057 EventSet::Iterator it; 01058 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 01059 SetControllable(*it); 01060 } 01061 } 01062 01063 // ClrControllable(index) 01064 TEMP void THIS::ClrControllable(Idx index) { 01065 FD_DG("TcGenerator(" << this << ")::ClrControllable(" << index << ")"); 01066 EventAttr attr=BASE::EventAttribute(index); 01067 attr.ClrControllable(); 01068 BASE::pAlphabet->Attribute(index,attr); 01069 } 01070 01071 // ClrControllable(rName) 01072 TEMP void THIS::ClrControllable(const std::string& rName) { 01073 FD_DG("TcGenerator(" << this << ")::ClrControllable(" << rName << ")"); 01074 Idx index = BASE::EventIndex(rName); 01075 ClrControllable(index); 01076 } 01077 01078 //ClrControllable(rEvents) 01079 TEMP void THIS::ClrControllable(const EventSet& rEvents) { 01080 FD_DG("TcGenerator(" << this << ")::ClrControllable(rEvents)"); 01081 EventSet::Iterator it; 01082 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 01083 ClrControllable(*it); 01084 } 01085 } 01086 01087 //ControllableEvents() 01088 TEMP EventSet THIS::ControllableEvents(void) const { 01089 FD_DG("TcGenerator(" << this << ")::ControllableEvents()"); 01090 EventSet res; 01091 EventSet::Iterator it; 01092 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 01093 if(Controllable(*it)) res.Insert(*it); 01094 } 01095 return res; 01096 } 01097 01098 //UncontrollableEvents() 01099 TEMP 01100 EventSet THIS::UncontrollableEvents(void) const { 01101 FD_DG("TcGenerator(" << this << ")::UncontrollableEvents()"); 01102 EventSet res; 01103 EventSet::Iterator it; 01104 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 01105 if(!Controllable(*it)) res.Insert(*it); 01106 } 01107 return res; 01108 } 01109 01110 // Observable(index) 01111 TEMP bool THIS::Observable(Idx index) const { 01112 EventAttr attr=BASE::EventAttribute(index); 01113 return attr.Observable(); 01114 } 01115 01116 // Observable(rName) 01117 TEMP bool THIS::Observable(const std::string& rName) const { 01118 EventAttr attr=BASE::EventAttribute(rName); 01119 return attr.Observable(); 01120 } 01121 01122 // InsObservableEvent(index) 01123 TEMP void THIS::InsObservableEvent(Idx index) { 01124 FD_DG("TcGenerator(" << this << ")::InsObservableEvent(" << index << ")"); 01125 EventAttr attr; 01126 attr.SetObservable(); 01127 BASE::InsEvent(index,attr); 01128 } 01129 01130 // InsObservableEvent(rName) 01131 TEMP Idx THIS::InsObservableEvent(const std::string& rName) { 01132 FD_DG("TcGenerator(" << this << ")::InsObservableEvent(" << rName << ")"); 01133 EventAttr attr; 01134 attr.SetObservable(); 01135 return BASE::InsEvent(rName,attr); 01136 } 01137 01138 // InsUnobservableEvent(index) 01139 TEMP void THIS::InsUnobservableEvent(Idx index) { 01140 FD_DG("TcGenerator(" << this << ")::InsUnobservableEvent(" << index << ")"); 01141 EventAttr attr; 01142 attr.ClrObservable(); 01143 BASE::InsEvent(index,attr); 01144 } 01145 01146 // InsUnobservableEvent(rName) 01147 TEMP Idx THIS::InsUnobservableEvent(const std::string& rName) { 01148 FD_DG("TcGenerator(" << this << ")::InsUnobservableEvent(" << rName << ")"); 01149 EventAttr attr; 01150 attr.ClrObservable(); 01151 return BASE::InsEvent(rName,attr); 01152 } 01153 01154 // SetObservable(index) 01155 TEMP void THIS::SetObservable(Idx index) { 01156 FD_DG("TcGenerator(" << this << ")::SetObservable(" << index << ")"); 01157 EventAttr attr=BASE::EventAttribute(index); 01158 attr.SetObservable(); 01159 BASE::pAlphabet->Attribute(index,attr); 01160 } 01161 01162 // SetObservable(rName) 01163 TEMP void THIS::SetObservable(const std::string& rName) { 01164 FD_DG("TcGenerator(" << this << ")::SetObservable(" << rName << ")"); 01165 Idx index = BASE::EventIndex(rName); 01166 SetObservable(index); 01167 } 01168 01169 //SetObservable(rEvents) 01170 TEMP void THIS::SetObservable(const EventSet& rEvents) { 01171 FD_DG("TcGenerator(" << this << ")::SetObservable(rEvents)"); 01172 EventSet::Iterator it; 01173 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 01174 SetObservable(*it); 01175 } 01176 } 01177 01178 // ClrObservable(index) 01179 TEMP void THIS::ClrObservable(Idx index) { 01180 FD_DG("TcGenerator(" << this << ")::ClrObservable(" << index << ")"); 01181 EventAttr attr=BASE::EventAttribute(index); 01182 attr.ClrObservable(); 01183 BASE::pAlphabet->Attribute(index,attr); 01184 } 01185 01186 // ClrObservable(rName) 01187 TEMP void THIS::ClrObservable(const std::string& rName) { 01188 FD_DG("TcGenerator(" << this << ")::ClrObservable(" << rName << ")"); 01189 Idx index = BASE::EventIndex(rName); 01190 ClrObservable(index); 01191 } 01192 01193 //ClrObservable(rEvents) 01194 TEMP void THIS::ClrObservable(const EventSet& rEvents) { 01195 FD_DG("TcGenerator(" << this << ")::ClrObservable(rEvents)"); 01196 EventSet::Iterator it; 01197 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 01198 ClrObservable(*it); 01199 } 01200 } 01201 01202 //ObservableEvents() 01203 TEMP EventSet THIS::ObservableEvents(void) const { 01204 FD_DG("TcGenerator(" << this << ")::ObservableEvents()"); 01205 EventSet res; 01206 EventSet::Iterator it; 01207 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 01208 if(Observable(*it)) res.Insert(*it); 01209 } 01210 return res; 01211 } 01212 01213 //UnobservableEvents() 01214 TEMP 01215 EventSet THIS::UnobservableEvents(void) const { 01216 FD_DG("TcGenerator(" << this << ")::UnobservableEvents()"); 01217 EventSet res; 01218 EventSet::Iterator it; 01219 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 01220 if(!Observable(*it)) res.Insert(*it); 01221 } 01222 return res; 01223 } 01224 01225 01226 //Forcible(index) 01227 TEMP bool THIS::Forcible(Idx index) const { 01228 EventAttr attr=BASE::EventAttribute(index); 01229 return attr.Forcible(); 01230 } 01231 01232 // Forcible(rName) 01233 TEMP bool THIS::Forcible(const std::string& rName) const { 01234 EventAttr attr=BASE::EventAttribute(rName); 01235 return attr.Forcible(); 01236 } 01237 01238 // InsForcibleEvent(index) 01239 TEMP void THIS::InsForcibleEvent(Idx index) { 01240 FD_DG("TcGenerator(" << this << ")::InsForcibleEvent(" << index << ")"); 01241 EventAttr attr; 01242 attr.SetForcible(); 01243 BASE::InsEvent(index,attr); 01244 } 01245 01246 // InsForcibleEvent(rName) 01247 TEMP Idx THIS::InsForcibleEvent(const std::string& rName) { 01248 FD_DG("TcGenerator(" << this << ")::InsForcibleEvent(" << rName << ")"); 01249 EventAttr attr; 01250 attr.SetForcible(); 01251 return BASE::InsEvent(rName,attr); 01252 } 01253 01254 // InsUnforcibleEvent(index) 01255 TEMP void THIS::InsUnforcibleEvent(Idx index) { 01256 FD_DG("TcGenerator(" << this << ")::InsUnforcibleEvent(" << index << ")"); 01257 EventAttr attr; 01258 attr.ClrForcible(); 01259 BASE::InsEvent(index,attr); 01260 } 01261 01262 // InsUnforcibleEvent(rName) 01263 TEMP Idx THIS::InsUnforcibleEvent(const std::string& rName) { 01264 FD_DG("TcGenerator(" << this << ")::InsUnforcibleEvent(" << rName << ")"); 01265 EventAttr attr; 01266 attr.ClrForcible(); 01267 return BASE::InsEvent(rName,attr); 01268 } 01269 01270 // SetForcible(index) 01271 TEMP void THIS::SetForcible(Idx index) { 01272 FD_DG("TcGenerator(" << this << ")::SetForcible(" << index << ")"); 01273 EventAttr attr=BASE::EventAttribute(index); 01274 attr.SetForcible(); 01275 BASE::pAlphabet->Attribute(index,attr); 01276 } 01277 01278 // SetForcible(rName) 01279 TEMP void THIS::SetForcible(const std::string& rName) { 01280 FD_DG("TcGenerator(" << this << ")::SetForcible(" << rName << ")"); 01281 Idx index = BASE::EventIndex(rName); 01282 SetForcible(index); 01283 } 01284 01285 //SetForcible(rEvents) 01286 TEMP void THIS::SetForcible(const EventSet& rEvents) { 01287 FD_DG("TcGenerator(" << this << ")::SetForcible(rEvents)"); 01288 EventSet::Iterator it; 01289 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 01290 SetForcible(*it); 01291 } 01292 } 01293 01294 // ClrForcible(index) 01295 TEMP void THIS::ClrForcible(Idx index) { 01296 FD_DG("TcGenerator(" << this << ")::ClrForcible(" << index << ")"); 01297 EventAttr attr=BASE::EventAttribute(index); 01298 attr.ClrForcible(); 01299 BASE::pAlphabet->Attribute(index,attr); 01300 } 01301 01302 // ClrForcible(rName) 01303 TEMP void THIS::ClrForcible(const std::string& rName) { 01304 FD_DG("TcGenerator(" << this << ")::ClrForcible(" << rName << ")"); 01305 Idx index = BASE::EventIndex(rName); 01306 ClrForcible(index); 01307 } 01308 01309 //ClrForcible(rEvents) 01310 TEMP void THIS::ClrForcible(const EventSet& rEvents) { 01311 FD_DG("TcGenerator(" << this << ")::ClrForcible(rEvents)"); 01312 EventSet::Iterator it; 01313 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 01314 ClrForcible(*it); 01315 } 01316 } 01317 01318 //ForcibleEvents() 01319 TEMP EventSet THIS::ForcibleEvents(void) const { 01320 FD_DG("TcGenerator(" << this << ")::ForcibleEvents()"); 01321 EventSet res; 01322 EventSet::Iterator it; 01323 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 01324 if(Forcible(*it)) res.Insert(*it); 01325 } 01326 return res; 01327 } 01328 01329 //UnforcibleEvents() 01330 TEMP 01331 EventSet THIS::UnforcibleEvents(void) const { 01332 FD_DG("TcGenerator(" << this << ")::UnforcibleEvents()"); 01333 EventSet res; 01334 EventSet::Iterator it; 01335 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 01336 if(!Forcible(*it)) res.Insert(*it); 01337 } 01338 return res; 01339 } 01340 01341 01342 //Highlevel(index) 01343 TEMP bool THIS::Highlevel(Idx index) const { 01344 EventAttr attr=BASE::EventAttribute(index); 01345 return attr.Highlevel(); 01346 } 01347 01348 // Highlevel(rName) 01349 TEMP bool THIS::Highlevel(const std::string& rName) const { 01350 EventAttr attr=BASE::EventAttribute(rName); 01351 return attr.Highlevel(); 01352 } 01353 01354 //Lowlevel(index) 01355 TEMP bool THIS::Lowlevel(Idx index) const { 01356 EventAttr attr=BASE::EventAttribute(index); 01357 return attr.Lowlevel(); 01358 } 01359 01360 // Lowlevel(rName) 01361 TEMP bool THIS::Lowlevel(const std::string& rName) const { 01362 EventAttr attr=BASE::EventAttribute(rName); 01363 return attr.Lowlevel(); 01364 } 01365 01366 // InsHighlevelEvent(index) 01367 TEMP void THIS::InsHighlevelEvent(Idx index) { 01368 FD_DG("TcGenerator(" << this << ")::InsHighlevelEvent(" << index << ")"); 01369 EventAttr attr; 01370 attr.SetHighlevel(); 01371 BASE::InsEvent(index,attr); 01372 } 01373 01374 // InsHighlevelEvent(rName) 01375 TEMP Idx THIS::InsHighlevelEvent(const std::string& rName) { 01376 FD_DG("TcGenerator(" << this << ")::InsHighlevelEvent(" << rName << ")"); 01377 EventAttr attr; 01378 attr.SetHighlevel(); 01379 return BASE::InsEvent(rName,attr); 01380 } 01381 01382 // InsLowlevelEvent(index) 01383 TEMP void THIS::InsLowlevelEvent(Idx index) { 01384 FD_DG("TcGenerator(" << this << ")::InsLowlevelEvent(" << index << ")"); 01385 EventAttr attr; 01386 attr.SetLowlevel(); 01387 BASE::InsEvent(index,attr); 01388 } 01389 01390 // InsLowlevelEvent(rName) 01391 TEMP Idx THIS::InsLowlevelEvent(const std::string& rName) { 01392 FD_DG("TcGenerator(" << this << ")::InsLowlevelEvent(" << rName << ")"); 01393 EventAttr attr; 01394 attr.SetLowlevel(); 01395 return BASE::InsEvent(rName,attr); 01396 } 01397 01398 // SetHighlevel(index) 01399 TEMP void THIS::SetHighlevel(Idx index) { 01400 FD_DG("TcGenerator(" << this << ")::SetHighlevel(" << index << ")"); 01401 EventAttr attr=BASE::EventAttribute(index); 01402 attr.SetHighlevel(); 01403 BASE::pAlphabet->Attribute(index,attr); 01404 } 01405 01406 // SetHighlevel(rName) 01407 TEMP void THIS::SetHighlevel(const std::string& rName) { 01408 FD_DG("TcGenerator(" << this << ")::SetHighlevel(" << rName << ")"); 01409 Idx index = BASE::EventIndex(rName); 01410 SetHighlevel(index); 01411 } 01412 01413 //SetHighlevel(rEvents) 01414 TEMP void THIS::SetHighlevel(const EventSet& rEvents) { 01415 FD_DG("TcGenerator(" << this << ")::SetHighlevel(rEvents)"); 01416 EventSet::Iterator it; 01417 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 01418 SetHighlevel(*it); 01419 } 01420 } 01421 01422 // SetLowlevel(index) 01423 TEMP void THIS::SetLowlevel(Idx index) { 01424 FD_DG("TcGenerator(" << this << ")::SetLowlevel(" << index << ")"); 01425 EventAttr attr=BASE::EventAttribute(index); 01426 attr.SetLowlevel(); 01427 BASE::pAlphabet->Attribute(index,attr); 01428 } 01429 01430 // SetLowlevel(rName) 01431 TEMP void THIS::SetLowlevel(const std::string& rName) { 01432 FD_DG("TcGenerator(" << this << ")::SetLowlevel(" << rName << ")"); 01433 Idx index = BASE::EventIndex(rName); 01434 SetLowlevel(index); 01435 } 01436 01437 //SetLowlevel(rEvents) 01438 TEMP void THIS::SetLowlevel(const EventSet& rEvents) { 01439 FD_DG("TcGenerator(" << this << ")::SetLowlevel(rEvents)"); 01440 EventSet::Iterator it; 01441 for(it=rEvents.Begin(); it!=rEvents.End(); it++) { 01442 SetLowlevel(*it); 01443 } 01444 } 01445 01446 //HighlevelEvents() 01447 TEMP EventSet THIS::HighlevelEvents(void) const { 01448 FD_DG("TcGenerator(" << this << ")::HighlevelEvents()"); 01449 EventSet res; 01450 EventSet::Iterator it; 01451 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 01452 if(Highlevel(*it)) res.Insert(*it); 01453 } 01454 return res; 01455 } 01456 01457 //LowlevelEvents() 01458 TEMP 01459 EventSet THIS::LowlevelEvents(void) const { 01460 FD_DG("TcGenerator(" << this << ")::LowlevelEvents()"); 01461 EventSet res; 01462 EventSet::Iterator it; 01463 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) { 01464 if(Lowlevel(*it)) res.Insert(*it); 01465 } 01466 return res; 01467 } 01468 01469 01470 01471 #undef TEMP 01472 #undef BASE 01473 #undef THIS 01474 01475 01476 } // namespace faudes 01477 01478 #endif 01479 libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |