|
libFAUDES
Sections
Index
|
tp_tgenerator.hGo to the documentation of this file.00001 /** @file tp_tgenerator.h Timed generator class TtGenerator */ 00002 00003 /* 00004 Timeplugin for FAU Discrete Event Systems Library (libfaudes) 00005 00006 Copyright (C) 2007 Thomas Moor 00007 Exclusive copyright is granted to Klaus Schmidt 00008 00009 */ 00010 00011 00012 #ifndef FAUDES_TP_TGENERATOR_H 00013 #define FAUDES_TP_TGENERATOR_H 00014 00015 #include "corefaudes.h" 00016 #include "tp_attributes.h" 00017 00018 namespace faudes { 00019 00020 00021 00022 /** 00023 * Generator with timing extensions. 00024 * 00025 * \section SecTimedAlur Alur's Timed Automata 00026 * 00027 * The TtGenerator implements a timed automaton as 00028 * introduced by Alur et al. Thus, a TtGenerator is equipped with a number of clock 00029 * variables to express conditions on timing, so called time constraints. Each state has a 00030 * TimeConstraint called the invariant, which must be satisfied while the generator 00031 * resides in the respective state. Similarly, each transition has a timeconstraint called the 00032 * guard, which must be satisfied at the moment in which the transition is executed. Transitions 00033 * may also reset clock variables. 00034 * 00035 * 00036 * \section SecTimedAlusImplement Implementation 00037 * 00038 * The tGenerator is derived from the cGenerator and requires 00039 * adequate attribute parameters that implement the timing constraints. Suitable 00040 * attribute classes are provided by AttributeTimedState, AttributeTimedTrans and AttributeTimedGlobal 00041 * which may be used either directly or as base classes for further derivatives. 00042 * For the event attribute, the tGenerator assumes the AttributeCFlags interface. A convenience 00043 * definition faudes::tGenerator is used for a minimal version with the above mentioned attribute parameters. 00044 * 00045 * 00046 * \section tGeneratorFileFormat File IO 00047 * 00048 * The TtGenerator calsses use the TaGenerator file IO, i.e. the file format is the 00049 * same up to timing related requirements from the attribute parameters. The below 00050 * example is from the basic version tGenerator and represents a simplemachine with a 00051 * busy cycle of at least 5 and at most 10 time units. 00052 * @code 00053 * <Generator> 00054 * "tc simple machine" 00055 * 00056 * <Alphabet> 00057 * "alpha" +C+ "beta" "mue" "lambda" +C+ 00058 * </Alphabet> 00059 * 00060 * <States> 00061 * "idle" 00062 * "busy" <Invariant> "cBusy" "LT" 10 </Invariant> 00063 * "down" 00064 * </States> 00065 * 00066 * <TransRel> 00067 * 00068 * "idle" "alpha" "busy" 00069 * <Timing> 00070 * <Resets> 00071 * "cBusy" 00072 * </Resets> 00073 * </Timing> 00074 * 00075 * "busy" "beta" "idle" 00076 * <Timing> 00077 * <Guard> 00078 * "cBusy" "GT" 5 00079 * </Guard> 00080 * </Timing> 00081 * 00082 * "busy" "mue" "down" 00083 * 00084 * "down" "lambda" "idle" 00085 * 00086 * </TransRel> 00087 * 00088 * <InitStates> "idle" </InitStates> 00089 * <MarkedStates> "idle" </MarkedStates> 00090 * 00091 * <Clocks> "cBusy" </Clocks> 00092 * 00093 * </Generator> 00094 * @endcode 00095 * 00096 * 00097 * @ingroup TimedPlugin 00098 */ 00099 00100 template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr> 00101 class TtGenerator : public TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> { 00102 public: 00103 /** 00104 * Constructor 00105 */ 00106 TtGenerator(void); 00107 00108 /** 00109 * Copy constructor 00110 * 00111 * @param rOtherGen 00112 */ 00113 TtGenerator(const TtGenerator& rOtherGen); 00114 00115 /** 00116 * Copy constructor (no attributes) 00117 * 00118 * @param rOtherGen 00119 */ 00120 TtGenerator(const vGenerator& rOtherGen); 00121 00122 /** 00123 * Assignment operator (uses copy) 00124 * Note: you must reimplement this operator in derived 00125 * classes in order to handle internal pointers correctly 00126 * 00127 * @param rOtherGen 00128 * Other generator 00129 */ 00130 virtual TtGenerator& operator= (const TtGenerator& rOtherGen) {return Assign(rOtherGen);}; 00131 00132 /** 00133 * Assignment operator (uses copy) 00134 * 00135 * @param rOtherGen 00136 * Other generator 00137 */ 00138 virtual TtGenerator& operator= (const vGenerator& rOtherGen) {return Assign(rOtherGen);}; 00139 00140 /** 00141 * Construct from file 00142 * 00143 * @param rFileName 00144 * Name of f ile 00145 * 00146 * @exception Exception 00147 * - file format errors (id 1, 50, 51, 52) 00148 */ 00149 TtGenerator(const std::string& rFileName); 00150 00151 /** 00152 * Construct on heap. 00153 * Constructs a TtGenerator on heap with the same attribute types and the same event- and clock-symboltable. 00154 * 00155 * @return 00156 * new Generator 00157 */ 00158 TtGenerator* New(void) const; 00159 00160 /** 00161 * Construct copy on heap. 00162 * Constructs a TtGenerator on heap with the same attribute types and the same event- and clock-symboltable. 00163 * 00164 * @return 00165 * new Generator 00166 */ 00167 TtGenerator* Copy(void) const; 00168 00169 /** 00170 * Construct on stack. 00171 * Constructs a TtGenerator on stack with the same attribute types and the same event- and clock-symboltable. 00172 * 00173 * @return 00174 * new Generator 00175 */ 00176 TtGenerator NewTGen(void) const; 00177 00178 00179 /** 00180 * Copy from other tGenerator 00181 * 00182 * @param rGen 00183 * generator which will become the copy 00184 */ 00185 virtual TtGenerator& Assign(const TtGenerator& rGen); 00186 00187 00188 /** 00189 * Copy from other generator (ignore attributes) 00190 * 00191 * @param rGen 00192 * generator which will become the copy 00193 */ 00194 virtual TtGenerator& Assign(const vGenerator& rGen); 00195 00196 00197 /** 00198 * Get Pointer to mpClockSymbolTable. 00199 * 00200 * @return Pointer mpClockSymbolTable 00201 */ 00202 SymbolTable* ClockSymbolTablep(void) const; 00203 00204 /** 00205 * Set ClockSymbolTable. 00206 * 00207 * @param pClockSymTab 00208 * Pointer SymbolTable 00209 */ 00210 void ClockSymbolTablep(SymbolTable* pClockSymTab); 00211 00212 00213 /** 00214 * Return a NameSet with generator's ClockSymbolTable 00215 * 00216 * @return 00217 * New empty ClockSet on stack 00218 */ 00219 ClockSet NewClockSet(void) const; 00220 00221 /** 00222 * Construct a clock on heap. 00223 * 00224 * @return 00225 * Pointer to new empty ClockSet on heap 00226 */ 00227 ClockSet* NewClockSetp(void) const; 00228 00229 /** 00230 * Number of clocks in mClocks 00231 * 00232 * @return Number of clocks in mClocks 00233 */ 00234 Idx ClocksSize(void) const; 00235 00236 /** 00237 * Get clockset as const reference 00238 * 00239 * @return mClocks 00240 */ 00241 const ClockSet& Clocks(void) const; 00242 00243 00244 /** 00245 * Get clockset as pointer 00246 * 00247 * @return mClocks 00248 */ 00249 ClockSet* Clocksp(void); 00250 00251 /** 00252 * Overwrites mClocks with newclocks without consistency check 00253 * 00254 * @param newclocks 00255 * New clocks that are written to mClocks 00256 */ 00257 void InjectClocks(const ClockSet& newclocks); 00258 00259 /** 00260 * Looks up clock name for given index 00261 * 00262 * @param index 00263 * Clock index 00264 * 00265 * @return Clock name 00266 */ 00267 std::string ClockName(Idx index) const; 00268 00269 /** 00270 * Looks up clock index for given name 00271 * 00272 * @param rName 00273 * Clock name 00274 * 00275 * @return Clock index or 0 for nonexistent 00276 */ 00277 Idx ClockIndex(const std::string& rName) const; 00278 00279 /** 00280 * Add an existing clock to mClcoks by index 00281 * 00282 * @param index 00283 * Clock index 00284 * @return 00285 * True if clock was new to clockset 00286 */ 00287 bool InsClock(Idx index); 00288 00289 /** 00290 * Add named clock to generator. An entry in the mpClockSymbolTable will 00291 * be made if clock is new. 00292 * 00293 * @param rName 00294 * Name of the clock to add 00295 * 00296 * @return 00297 * New unique index 00298 */ 00299 Idx InsClock(const std::string& rName); 00300 00301 /** 00302 * Add new named clocks to generator. 00303 * 00304 * @param rClockSet 00305 * ClockSet 00306 */ 00307 void InsClocks(const ClockSet& rClockSet); 00308 00309 /** 00310 * Delete clock from generator by index. This also removes 00311 * any constraints and resets that refer to that clock. 00312 * 00313 * @param index 00314 * Index of clock 00315 * @return 00316 * True if clock did exist 00317 * 00318 */ 00319 bool DelClock(Idx index); 00320 00321 /** 00322 * Delete clock from generator by name. mpClockSymbolTable stays untouched. 00323 * Also removes constraints and resets that refer to this clock 00324 * 00325 * @param rName 00326 * Name of clock 00327 * @return 00328 * True if clock did exist 00329 */ 00330 bool DelClock(const std::string& rName); 00331 00332 /** 00333 * Delete a set of clocks from generator. 00334 * 00335 * @param rClocks 00336 * ClockSet containing clocks to remove 00337 */ 00338 void DelClocks(const ClockSet& rClocks); 00339 00340 /** 00341 * Test existence of clock in mClocks 00342 * 00343 * @param index 00344 * Clock index 00345 * 00346 * @return 00347 * true / false 00348 */ 00349 bool ExistsClock(Idx index) const; 00350 00351 /** 00352 * Test existence of clock in mClock 00353 * 00354 * @param rName 00355 * Clock name 00356 * 00357 * @return 00358 * True if clock exists 00359 */ 00360 bool ExistsClock(const std::string& rName) const; 00361 00362 /** 00363 * Returns a niterator to clock index in mClock 00364 * 00365 * @param index 00366 * Index to find 00367 * 00368 * @return 00369 * ClockSet::Iterator to clock index 00370 */ 00371 ClockSet::Iterator FindClock(Idx index) const; 00372 00373 /** 00374 * Returns an iterator to clock index in mClock 00375 * 00376 * @param rName 00377 * Clock name of index to find 00378 * 00379 * @return 00380 * ClockSet::Iterator to clock index 00381 */ 00382 ClockSet::Iterator FindClock(const std::string& rName) const; 00383 00384 /** 00385 * Returns all clocks used by all TimeConstraints and Resets. 00386 * Should be a subset of Clocks() 00387 * 00388 * @return 00389 * ClockSet containing all clocks 00390 */ 00391 ClockSet ActiveClocks(void) const; 00392 00393 /** 00394 * Returns all clocks not used by any TimeConstraints or Reset. 00395 * 00396 * @return 00397 * ClockSet containing all unused clocks 00398 */ 00399 ClockSet InactiveClocks(void) const; 00400 00401 /** 00402 * Update Clocks to include all active clocks 00403 * 00404 */ 00405 void InsActiveClocks(void); 00406 00407 /** 00408 * Update Clocks not to include any inactive clocks 00409 * 00410 */ 00411 void DelInactiveClocks(void); 00412 00413 /** 00414 * Iterator to Begin() of mClocks 00415 * 00416 * @return iterator to begin of mClocks 00417 */ 00418 ClockSet::Iterator ClocksBegin(void) const; 00419 00420 /** 00421 * Iterator to End() of mClocks 00422 * 00423 * @return iterator to end of mClocks 00424 */ 00425 ClockSet::Iterator ClocksEnd(void) const; 00426 00427 /** 00428 * Throw exception if timeconstraint refers to clocks not 00429 * in clockset or symboltable mismatch 00430 * 00431 * @exception Exception 00432 * - invalid cock (id 200) 00433 */ 00434 void ConsistentTimeConstraint(const TimeConstraint& rTimeConstr) const; 00435 00436 /** 00437 * Throw exception if clocksset contains clocks not 00438 * in generators clockset or symboltable mismatch 00439 * 00440 * @exception Exception 00441 * - invalid cock (id 200) 00442 */ 00443 void ConsistentClocks(const ClockSet& rClocks) const; 00444 00445 00446 /** 00447 * Get invariant of state by index 00448 * 00449 * @param idx 00450 * State index 00451 * @return 00452 * Const ref to invariant 00453 */ 00454 const TimeConstraint& Invariant(Idx idx) const; 00455 00456 /** 00457 * Get invariant of state by index 00458 * 00459 * @param idx 00460 * State index 00461 * @return 00462 * Pointer to invariant 00463 */ 00464 TimeConstraint* Invariantp(Idx idx); 00465 00466 /** 00467 * Get invariant of state by name 00468 * 00469 * @param name 00470 * State name 00471 * @return 00472 * Const ref to invariant 00473 */ 00474 const TimeConstraint& Invariant(const std::string& name) const; 00475 00476 00477 /** 00478 * Get invariant of state by name 00479 * 00480 * @param name 00481 * State index 00482 * @return 00483 * Pointer to invariant 00484 */ 00485 TimeConstraint* Invariantp(const std::string& name); 00486 00487 /** 00488 * Set invariant of state by index 00489 * 00490 * @param index 00491 * State index 00492 * @param rConstraints 00493 * New constraints 00494 */ 00495 void Invariant(Idx index, const TimeConstraint& rConstraints); 00496 00497 00498 /** 00499 * Set invariant of state by name 00500 * 00501 * @param name 00502 * State name 00503 * @param rConstraints 00504 * New constraints 00505 */ 00506 void Invariant(const std::string& name, const TimeConstraint& rConstraints); 00507 00508 00509 /** 00510 * Ins invariant of state by name 00511 * 00512 * @param name 00513 * State name 00514 * @param rConstraints 00515 * New constraints 00516 */ 00517 void InsInvariant(const std::string& name, const TimeConstraint& rConstraints); 00518 00519 00520 /** 00521 * Ins invariant of state by name 00522 * 00523 * @param index 00524 * State index 00525 * @param rConstraints 00526 * New constraints 00527 */ 00528 void InsInvariant(Idx index, const TimeConstraint& rConstraints); 00529 00530 00531 /** 00532 * Clear invariant of state by index 00533 * 00534 * @param idx 00535 * State index 00536 */ 00537 void ClrInvariant(Idx idx); 00538 00539 /** 00540 * Clear invariant of state by name 00541 * 00542 * @param name 00543 * State name 00544 */ 00545 void ClrInvariant(const std::string& name); 00546 00547 /** 00548 * Clear all invariants 00549 * 00550 */ 00551 void ClearInvariants(void); 00552 00553 /** 00554 * Add a transition to generator by indices. States and event 00555 * must already exist! 00556 * 00557 * Define FAUDES_CHECKED for consistency checks. 00558 * 00559 * @param x1 00560 * Predecessor state index 00561 * @param ev 00562 * Event index 00563 * @param x2 00564 * Successor state index 00565 * 00566 * @return 00567 * True, if the transition was new the generator 00568 * 00569 * @exception Exception 00570 * - state or event not in generator (id 95) 00571 */ 00572 bool SetTransition(Idx x1, Idx ev, Idx x2); 00573 00574 /** 00575 * Add a transition to generator by names. Statename and eventname 00576 * must already exist! 00577 * 00578 * @param rX1 00579 * Predecessor state name 00580 * @param rEv 00581 * Event name 00582 * @param rX2 00583 * Successor state name 00584 * 00585 * @return 00586 * True, if the transition was new the generator 00587 * 00588 * @exception Exception 00589 * - state or event not in generator (id 95) 00590 * - state name not known (id 90) 00591 * - event name not known (id 66) 00592 */ 00593 bool SetTransition(const std::string& rX1, const std::string& rEv, 00594 const std::string& rX2); 00595 00596 /** 00597 * Add a transition with attribute to generator. States and event 00598 * must already exist! 00599 * 00600 * Define FAUDES_CHECKED for consistency checks. 00601 * 00602 * @param rTransition 00603 * transition 00604 * @param rAttr 00605 * attribute 00606 * 00607 * @return 00608 * True, if the transition was new the generator 00609 * 00610 */ 00611 bool SetTransition(const Transition& rTransition, const TransAttr& rAttr); 00612 00613 /** 00614 * Inserts new TimedTransition constructed from parameters. 00615 * Performs consistency checks for x1, x2, ev and all clocks in rguard and rResetClocks. 00616 * 00617 * @param rTrans 00618 * new transition 00619 * @param rGuard 00620 * Guard of new TimedTransition. 00621 * @param rResets 00622 * Reset clocks of new TimedTransition. 00623 * @return 00624 * True, if the transition was new the generator 00625 */ 00626 bool SetTransition(const Transition& rTrans, 00627 const TimeConstraint& rGuard = TimeConstraint(), const ClockSet& rResets = ClockSet()); 00628 00629 /** 00630 * Inserts new TimedTransition constructed from parameters. 00631 * Performs consistency checks for x1, x2, ev and all clocks in rguard and rResetClocks. 00632 * 00633 * @param x1 00634 * Start state of new TimedTransition. 00635 * @param ev 00636 * Event of new TimedTransition. 00637 * @param x2 00638 * Goal state of new TimedTransition. 00639 * @param rguard 00640 * Guard of new TimedTransition. 00641 * @param rResetClocks 00642 * Reset clocks of new TimedTransition. 00643 */ 00644 bool SetTransition(Idx x1, Idx ev, Idx x2, 00645 const TimeConstraint& rguard, const ClockSet& rResetClocks = ClockSet()); 00646 00647 /** 00648 * Inserts new TimedTransition constructed from parameters. 00649 * Performs consistency checks for x1, x2, ev and all clocks in rguard and rResetClocks. 00650 * 00651 * @param rX1 00652 * Start state of new TimedTransition. 00653 * @param rEv 00654 * Event of new TimedTransition. 00655 * @param rX2 00656 * Goal state of new TimedTransition. 00657 * @param rGuard 00658 * Guard of new TimedTransition. 00659 * @param rResets 00660 * Reset clocks of new TimedTransition. 00661 * 00662 * @return 00663 * True, if the transition was new the generator 00664 */ 00665 bool SetTransition(const std::string& rX1, const std::string& rEv, const std::string& rX2, 00666 const TimeConstraint& rGuard = TimeConstraint(), const ClockSet& rResets = ClockSet()); 00667 00668 00669 /** 00670 * Sets Guard of a transition 00671 * 00672 * @param rTrans 00673 * transition to manupilate 00674 * @param rGuard 00675 * new Guard of transition. 00676 */ 00677 void Guard(const Transition& rTrans, const TimeConstraint& rGuard); 00678 00679 /** 00680 * adds constraints to Guard of a transition 00681 * 00682 * @param rTrans 00683 * transition to manupilate 00684 * @param rConstraints 00685 * new constraints for Guard 00686 */ 00687 void InsGuard(const Transition& rTrans, const TimeConstraint& rConstraints); 00688 00689 /** 00690 * Gets Guard refernce of a transition 00691 * 00692 * @param rTrans 00693 * transition to inspect 00694 * 00695 * @return 00696 * Guard of transition. 00697 */ 00698 const TimeConstraint& Guard(const Transition& rTrans) const; 00699 00700 /** 00701 * Gets Guard pointer of ransition 00702 * 00703 * @param rTrans 00704 * transition to inspect 00705 * 00706 * @return 00707 * Guard of transition. 00708 */ 00709 TimeConstraint* Guardp(const Transition& rTrans); 00710 00711 00712 /** 00713 * Clears Guard of a transition 00714 * 00715 * @param rTrans 00716 * transition to manupilate 00717 */ 00718 void ClrGuard(const Transition& rTrans); 00719 00720 /** 00721 * Sets Resets of a transition 00722 * 00723 * @param rTrans 00724 * transition to manupilate 00725 * @param rResets 00726 * new Resets of transition. 00727 */ 00728 void Resets(const Transition& rTrans, const ClockSet& rResets); 00729 00730 /** 00731 * adds Resets of a transition 00732 * 00733 * @param rTrans 00734 * transition to manupilate 00735 * @param rMoreResets 00736 * new Resets of transition. 00737 */ 00738 void InsResets(const Transition& rTrans, const ClockSet& rMoreResets); 00739 00740 /** 00741 * Gets Resets refernce of a transition 00742 * 00743 * @param rTrans 00744 * transition to inspect 00745 * 00746 * @return 00747 * Resets of transition. 00748 */ 00749 const ClockSet& Resets(const Transition& rTrans) const; 00750 00751 /** 00752 * Gets Resets pointer of ransition 00753 * 00754 * @param rTrans 00755 * transition to inspect 00756 * 00757 * @return 00758 * Resets of transition. 00759 */ 00760 ClockSet* Resetsp(const Transition& rTrans); 00761 00762 /** 00763 * Clears Resets of a transition 00764 * 00765 * @param rTrans 00766 * transition to manupilate 00767 */ 00768 void ClrResets(const Transition& rTrans); 00769 00770 /** 00771 * Return pretty printable clock name for index. 00772 * Primary meant for debugging messages 00773 * 00774 * @param index 00775 * Event index 00776 * 00777 * @return 00778 * std::string 00779 */ 00780 std::string CStr(Idx index) const; 00781 00782 /** 00783 * Check if generator is valid 00784 * 00785 * @return 00786 * Success 00787 */ 00788 virtual bool Valid(void); 00789 00790 00791 /** 00792 * Updates internal attributes. As a demo, we set 00793 * state flag 0x20000000 for blocking states. 00794 * Reimplement to your needs. 00795 * 00796 * @return true if value changed 00797 */ 00798 virtual bool UpdateAttributes(void); 00799 00800 00801 00802 }; // end class TtGeneraator 00803 00804 00805 /** Convenience typedef for std tGenerator */ 00806 typedef TtGenerator<AttributeTimedGlobal, AttributeTimedState, AttributeCFlags,AttributeTimedTrans> 00807 tGenerator; 00808 00809 // convenient scope macors 00810 #define THIS TtGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> 00811 #define BASE TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> 00812 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr> 00813 00814 00815 // TtGenerator(void) 00816 TEMP THIS::TtGenerator(void) : BASE() { 00817 // set basic members (cosmetic) 00818 BASE::pGlobalAttribute->mClocks.Name("Clocks"); 00819 BASE::pGlobalAttribute->mpClockSymbolTable=ClockSet::StaticSymbolTablep(); 00820 FD_DG("tGenerator(" << this << ")::tGenerator() with csymtab " 00821 << (BASE::pGlobalAttribute->mpClockSymbolTable )); 00822 } 00823 00824 // TtGenerator(rOtherGen) 00825 TEMP THIS::TtGenerator(const TtGenerator& rOtherGen) : BASE(rOtherGen) { 00826 FD_DG("tGenerator(" << this << ")::tGenerator(rOtherGen) with csymtab" 00827 << (BASE::pGlobalAttribute->mpClockSymbolTable) ); 00828 } 00829 00830 // TtGenerator(rOtherGen) 00831 TEMP THIS::TtGenerator(const vGenerator& rOtherGen) : BASE(rOtherGen) { 00832 // set basic members (cosmetic) 00833 BASE::pGlobalAttribute->mClocks.Name("Clocks"); 00834 BASE::pGlobalAttribute->mpClockSymbolTable=ClockSet::StaticSymbolTablep(); 00835 FD_DG("tGenerator(" << this << ")::tGenerator(rOtherGen) with csymtab" 00836 << (BASE::pGlobalAttribute->mpClockSymbolTable) ); 00837 } 00838 00839 // TtGenerator(rFilename) 00840 TEMP THIS::TtGenerator(const std::string& rFileName) : BASE(rFileName) { 00841 FD_DG("tGenerator(" << this << ")::tGenerator(" << rFileName << ") with csymtab" 00842 << (BASE::pGlobalAttribute->mpClockSymbolTable) ); 00843 } 00844 00845 // Assign(gen) 00846 TEMP THIS& THIS::Assign(const TtGenerator& rGen) { 00847 FD_DG("tGenerator(" << this << ")::Copy(gen&)"); 00848 // copy my data (cosmetic) 00849 BASE::pGlobalAttribute->mpClockSymbolTable = rGen.pGlobalAttribute->mpClockSymbolTable; 00850 // call base method 00851 BASE::Assign(rGen); 00852 // done 00853 return *this; 00854 } 00855 00856 // Assign(gen) 00857 TEMP THIS& THIS::Assign(const vGenerator& rGen) { 00858 FD_DG("tGenerator(" << this << ")::Assign(vgen&)"); 00859 // call base method 00860 BASE::Assign(rGen); 00861 // done 00862 return *this; 00863 } 00864 00865 00866 00867 // ClockSymbolTablep() 00868 TEMP SymbolTable* THIS::ClockSymbolTablep(void) const { 00869 return BASE::pGlobalAttribute->mpClockSymbolTable; 00870 } 00871 00872 // ClockSymbolTablep(pSymTab) 00873 TEMP void THIS::ClockSymbolTablep(SymbolTable* pSymTab) { 00874 BASE::Clear(); // TODO: relax this 00875 BASE::pGlobalAttribute->mpClockSymbolTable=pSymTab; 00876 } 00877 00878 00879 // New 00880 TEMP THIS* THIS::New(void) const { 00881 // allocate 00882 THIS* res = new THIS; 00883 // fix base data 00884 res->EventSymbolTablep(BASE::mpEventSymbolTable); 00885 res->mStateNamesEnabled=BASE::mStateNamesEnabled; 00886 // fix my data 00887 res->ClockSymbolTablep(ClockSymbolTablep()); 00888 return res; 00889 } 00890 00891 // Copy 00892 TEMP THIS* THIS::Copy(void) const { 00893 // allocate 00894 THIS* res = new THIS(*this); 00895 // done 00896 return res; 00897 } 00898 00899 // NewTGen 00900 TEMP THIS THIS::NewTGen(void) const { 00901 // call base (fixes by assignment constructor) 00902 THIS res= BASE::NewCGen(); 00903 // fix my data 00904 res.ClockSymbolTablep(ClockSymbolTablep()); 00905 return res; 00906 } 00907 00908 // ClockSize() const 00909 TEMP Idx THIS::ClocksSize(void) const { 00910 return BASE::pGlobalAttribute->mClocks.Size(); 00911 } 00912 00913 // Clocks() 00914 TEMP const ClockSet& THIS::Clocks(void) const { 00915 return BASE::pGlobalAttribute->mClocks; 00916 } 00917 00918 // Clocksp() 00919 TEMP ClockSet* THIS::Clocksp(void) { 00920 return &BASE::pGlobalAttribute->mClocks; 00921 } 00922 00923 // InjectClocks(set) 00924 TEMP void THIS::InjectClocks(const ClockSet& clockset) { 00925 BASE::pGlobalAttribute->mClocks=clockset; 00926 BASE::pGlobalAttribute->mClocks.Name("Clocks"); 00927 } 00928 00929 // InsClock(index) 00930 TEMP bool THIS::InsClock(Idx clockindex) { 00931 return BASE::pGlobalAttribute->mClocks.Insert(clockindex); 00932 } 00933 00934 // InsClock(name) 00935 TEMP Idx THIS::InsClock(const std::string& clockname) { 00936 return BASE::pGlobalAttribute->mClocks.Insert(clockname); 00937 } 00938 00939 // InsClocks(set) 00940 TEMP void THIS::InsClocks(const ClockSet& clockset) { 00941 BASE::pGlobalAttribute->mClocks.InsertSet(clockset); 00942 } 00943 00944 00945 // DelClock(index) 00946 TEMP bool THIS::DelClock(Idx clockindex) { 00947 FD_DG("tGenerator(" << this << ")::DelClock(" << clockindex << ")"); 00948 TransSet::Iterator tit; 00949 for(tit=BASE::TransRelBegin(); tit!=BASE::TransRelEnd(); tit++) { 00950 if(!BASE::pTransRel->Attribute(*tit).IsDefault()) { 00951 BASE::pTransRel->Attributep(*tit)->mGuard.EraseByClock(clockindex); 00952 BASE::pTransRel->Attributep(*tit)->mResets.Erase(clockindex); 00953 } 00954 } 00955 StateSet::Iterator it; 00956 for(it=BASE::StatesBegin(); it!=BASE::StatesEnd(); it++) { 00957 if(!BASE::pStates->Attribute(*it).IsDefault()) { 00958 BASE::pStates->Attributep(*it)->mInvariant.EraseByClock(clockindex); 00959 } 00960 } 00961 return BASE::pGlobalAttribute->mClocks.Erase(clockindex); 00962 } 00963 00964 // DelClock(name) 00965 TEMP bool THIS::DelClock(const std::string& clockname) { 00966 Idx index=BASE::pGlobalAttribute->mClocks.Index(clockname); 00967 return DelClock(index); 00968 } 00969 00970 // DelClocks(set) 00971 TEMP void THIS::DelClocks(const ClockSet& clockset) { 00972 ClockSet::Iterator it, tmpit; 00973 for(it=ClocksBegin(); it!=ClocksEnd(); ) { 00974 tmpit=it; 00975 it++; 00976 DelClock(*tmpit); 00977 } 00978 } 00979 00980 // ExistsClock(index) 00981 TEMP bool THIS::ExistsClock(Idx clockindex) const { 00982 return BASE::pGlobalAttribute->mClocks.Exists(clockindex); 00983 } 00984 00985 // ExistsClock(name) 00986 TEMP bool THIS::ExistsClock( 00987 const std::string& clockname) const { 00988 return BASE::pGlobalAttribute->mClocks.Exists(clockname); 00989 } 00990 00991 // FindClock(index) 00992 TEMP ClockSet::Iterator THIS::FindClock(Idx clockindex) const { 00993 return BASE::pGlobalAttribute->mClocks.Find(clockindex); 00994 } 00995 00996 // FindClock(name) 00997 TEMP ClockSet::Iterator THIS::FindClock(const std::string& clockname) const { 00998 return BASE::pGlobalAttribute->mClocks.Find(clockname); 00999 } 01000 01001 // ClockName(index) 01002 TEMP std::string THIS::ClockName(Idx clockindex) const { 01003 return BASE::pGlobalAttribute->mClocks.SymbolicName(clockindex); 01004 } 01005 01006 // ClockIndex(name) 01007 TEMP Idx THIS::ClockIndex(const std::string& clockname) const { 01008 return BASE::pGlobalAttribute->mClocks.Index(clockname); 01009 } 01010 01011 // ActiveClocks() const 01012 TEMP ClockSet THIS::ActiveClocks(void) const { 01013 FD_DG("tGenerator(" << this << ")::ActiveClocks() const"); 01014 ClockSet res; 01015 TransSet::Iterator tit; 01016 for(tit=BASE::TransRelBegin(); tit!=BASE::TransRelEnd(); tit++) { 01017 res.InsertSet(Guard(*tit).ActiveClocks()); 01018 res.InsertSet(Resets(*tit)); 01019 } 01020 StateSet::Iterator it; 01021 for(it=BASE::StatesBegin(); it!=BASE::StatesEnd(); it++) { 01022 res.InsertSet(Invariant(*it).ActiveClocks()); 01023 } 01024 res.Name("AcitiveClocks"); 01025 return res; 01026 } 01027 01028 // InactiveClocks() const 01029 TEMP ClockSet THIS::InactiveClocks(void) const { 01030 FD_DG("TtaGenerator(" << this << ")::InactiveClocks() const"); 01031 ClockSet res = BASE::mClocks - ActiveClocks(); 01032 res.Name("InactiveClocks"); 01033 return res; 01034 } 01035 01036 // InsActiveClocks() 01037 TEMP void THIS::InsActiveClocks(void) { 01038 FD_DG("tGenerator(" << this << ")::InsActiveClocks()"); 01039 ClockSet aclocks=ActiveClocks(); 01040 InsClocks(aclocks); 01041 } 01042 01043 // DelInactiveClocks() 01044 TEMP void THIS::DelInactiveClocks(void) { 01045 FD_DG("tGenerator(" << this << ")::InsActiveClocks()"); 01046 ClockSet iaclocks=InactiveClocks(); 01047 BASE::pGlobalAttribute->mClocks.Erase(iaclocks); 01048 } 01049 01050 // iterator ClocksBegin() const 01051 TEMP ClockSet::Iterator THIS::ClocksBegin(void) const { 01052 return BASE::pGlobalAttribute->mClocks.Begin(); 01053 } 01054 01055 // iterator ClocksEnd() const 01056 TEMP ClockSet::Iterator THIS::ClocksEnd(void) const { 01057 return BASE::pGlobalAttribute->mClocks.End(); 01058 } 01059 01060 // ConsistentTimeConstraint(constraint) 01061 TEMP void THIS::ConsistentTimeConstraint(const TimeConstraint& rTimeConstr) const { 01062 FD_DG("tGenerator(" << this << ")::ConsistentTimeConstraint(constr)"); 01063 if( rTimeConstr.ClockSymbolTablep() != ClockSymbolTablep()) { 01064 std::stringstream errstr; 01065 errstr << "clocksymboltable mismatch" << std::endl; 01066 throw Exception("tGenerator::ConsistentTimeConstraint)", errstr.str(), 200); 01067 } 01068 if(!( rTimeConstr.ActiveClocks() <= Clocks() )) { 01069 std::stringstream errstr; 01070 errstr << "time constraint refers to clocks not in clockset: " << 01071 rTimeConstr.ActiveClocks().ToString() << " versus " << Clocks().ToString() << std::endl; 01072 throw Exception("tGenerator::ConsistentTimeConstraint)", errstr.str(), 200); 01073 } 01074 FD_DG("tGenerator(" << this << ")::ConsistentTimeConstraint(constr): ok"); 01075 } 01076 01077 // ConsistentClocks(clocks) 01078 TEMP void THIS::ConsistentClocks(const ClockSet& rClocks) const { 01079 if(!( rClocks <= Clocks() )) { 01080 std::stringstream errstr; 01081 errstr << "clocksset contains clocks not in clockset" << std::endl; 01082 throw Exception("tGenerator::ConsistentClocks)", errstr.str(), 200); 01083 } 01084 if( rClocks.SymbolTablep() != ClockSymbolTablep()) { 01085 std::stringstream errstr; 01086 errstr << "clocksymboltable mismatch" << std::endl; 01087 throw Exception("tGenerator::ConsistentClocks)", errstr.str(), 200); 01088 } 01089 } 01090 01091 01092 // Invariant(index) 01093 TEMP const TimeConstraint& THIS::Invariant(Idx stateindex) const { 01094 if(!BASE::ExistsState(stateindex)) { 01095 std::stringstream errstr; 01096 errstr << "state index " << stateindex << " not found in StateSet" << std::endl; 01097 throw Exception("tGenerator::Invariant", errstr.str(), 200); 01098 } 01099 return BASE::pStates->Attribute(stateindex).mInvariant; 01100 } 01101 01102 // Invariantp(index) 01103 TEMP TimeConstraint* THIS::Invariantp(Idx stateindex) { 01104 if(!BASE::ExistsState(stateindex)) { 01105 std::stringstream errstr; 01106 errstr << "state index " << stateindex << " not found in StateSet" << std::endl; 01107 throw Exception("tGenerator::Invariant", errstr.str(), 200); 01108 } 01109 return &BASE::pStates->Attributep(stateindex)->mInvariant; 01110 } 01111 01112 // Invariant(name) 01113 TEMP const TimeConstraint& THIS::Invariant(const std::string& statename) const { 01114 Idx idx=BASE::StateIndex(statename); 01115 return Invariant(idx); 01116 } 01117 01118 // Invariantp(name) 01119 TEMP TimeConstraint* THIS::Invariantp(const std::string& statename) { 01120 Idx idx=BASE::StateIndex(statename); 01121 return Invariantp(idx); 01122 } 01123 01124 // Invariant(index,invariant) 01125 TEMP void THIS::Invariant(Idx stateindex, const TimeConstraint& rInv) { 01126 FD_DG("tGenerator(" << this << ")::Invariant("<<stateindex<<",inv)"); 01127 #ifdef FAUDES_CHECKED 01128 ConsistentTimeConstraint(rInv); 01129 if(!BASE::ExistsState(stateindex)) { 01130 std::stringstream errstr; 01131 errstr << "state index " << stateindex << " not found in StateSet" << std::endl; 01132 throw Exception("tGenerator::Invariant", errstr.str(), 200); 01133 } 01134 #endif 01135 BASE::pStates->Attributep(stateindex)->mInvariant=rInv; 01136 BASE::pStates->Attributep(stateindex)->mInvariant.Name("Invariant"); 01137 } 01138 01139 // Invariant(name,invariant) 01140 TEMP void THIS::Invariant(const std::string& statename, const TimeConstraint& rInv) { 01141 FD_DG("tGenerator(" << this << ")::Invariant("<<statename<<",inv)"); 01142 Idx idx=BASE::StateIndex(statename); 01143 Invariant(idx,rInv); 01144 } 01145 01146 // InsInvariant(index,invariant) 01147 TEMP void THIS::InsInvariant(Idx stateindex, const TimeConstraint& rInv) { 01148 FD_DG("tGenerator(" << this << ")::InsInvariant("<<stateindex<<",inv)"); 01149 #ifdef FAUDES_CHECKED 01150 ConsistentTimeConstraint(rInv); 01151 if(!BASE::ExistsState(stateindex)) { 01152 std::stringstream errstr; 01153 errstr << "state index " << stateindex << " not found in StateSet" << std::endl; 01154 throw Exception("tGenerator::InsInvariant", errstr.str(), 200); 01155 } 01156 #endif 01157 if(!rInv.Empty()) { 01158 BASE::pStates->Attributep(stateindex)->mInvariant.Insert(rInv); 01159 } 01160 } 01161 01162 // InsInvariant(name,invariant) 01163 TEMP void THIS::InsInvariant(const std::string& statename, const TimeConstraint& rInv) { 01164 FD_DG("tGenerator(" << this << ")::InsInvariant("<<statename<<",inv)"); 01165 Idx idx=BASE::StateIndex(statename); 01166 InsInvariant(idx,rInv); 01167 } 01168 01169 // ClrInvariant(index) 01170 TEMP void THIS::ClrInvariant(Idx stateindex) { 01171 if(!BASE::pStates->Attribute(stateindex).IsDefault()) 01172 BASE::pStates->Attributep(stateindex)->mInvariant.Clear(); 01173 } 01174 01175 // ClrInvariant(name) 01176 TEMP void THIS::ClrInvariant(const std::string& statename) { 01177 Idx idx=BASE::StateIndex(statename); 01178 ClrInvariant(idx); 01179 } 01180 01181 // ClearInvariants() 01182 TEMP void THIS::ClearInvariants(void) { 01183 // FIXME: should iterate, there could be other attributes 01184 BASE::pStates->ClearAttributes(); 01185 } 01186 01187 01188 // SetTransition(rX1, rEv, rX2) 01189 TEMP bool THIS::SetTransition(const std::string& rX1, const std::string& rEv, const std::string& rX2) { 01190 return BASE::SetTransition(rX1,rEv,rX2); 01191 } 01192 01193 01194 // SetTransition(x1, ev, x2) 01195 TEMP bool THIS::SetTransition(Idx x1, Idx ev, Idx x2) { 01196 return BASE::SetTransition(Transition(x1,ev,x2)); 01197 } 01198 01199 // SetTransition(rTransition, rAttr) 01200 TEMP bool THIS::SetTransition(const Transition& rTransition, const TransAttr& rAttr) { 01201 return BASE::SetTransition(rTransition,rAttr); 01202 } 01203 01204 // SetTransition(trans,....) 01205 TEMP bool THIS::SetTransition(const Transition& rTrans, 01206 const TimeConstraint& rGuard, const ClockSet& rResets) { 01207 FD_DG("tGenerator(" << this << ")::SetTransition(" << (BASE::TStr(rTrans)) <<", " << 01208 rGuard.ToString() << ", " << rResets.ToString() << ") const"); 01209 if(rResets.Empty() && rGuard.Empty()) { 01210 return BASE::SetTransition(rTrans); 01211 } 01212 TransAttr attr; 01213 attr.mGuard=rGuard; 01214 attr.mResets=rResets; 01215 attr.mGuard.Name("Guard"); 01216 attr.mResets.Name("Resets"); 01217 #ifdef FAUDES_CHECKED 01218 ConsistentTimeConstraint(rGuard); 01219 ConsistentClocks(rResets); 01220 #endif 01221 return BASE::SetTransition(rTrans,attr); 01222 } 01223 01224 // SetTransition(x1,ev,x2, ...) 01225 TEMP bool THIS::SetTransition(Idx x1, Idx ev, Idx x2, 01226 const TimeConstraint& rGuard, const ClockSet& rResets) { 01227 return SetTransition(Transition(x1,ev,x2),rGuard,rResets); 01228 } 01229 01230 // SetTransition(X1,Ev,X2, ...) 01231 TEMP bool THIS::SetTransition( 01232 const std::string& rX1, const std::string& rEv, const std::string& rX2, 01233 const TimeConstraint& rGuard, const ClockSet& rResets) { 01234 FD_DG("tGenerator(" << this << ")::SetTransition(" << rX1 << " " << rEv <<" " << rX2 << 01235 rGuard.ToString() << ", " << rResets.ToString() << ") const"); 01236 bool res=BASE::SetTransition(rX1,rEv,rX2); 01237 if(rResets.Empty() && rGuard.Empty()) { 01238 return res; 01239 } 01240 TransAttr attr; 01241 attr.mResets=rResets; 01242 attr.mGuard=rGuard; 01243 attr.mGuard.Name("Guard"); 01244 attr.mResets.Name("Resets"); 01245 #ifdef FAUDES_CHECKED 01246 ConsistentTimeConstraint(rGuard); 01247 ConsistentClocks(rResets); 01248 #endif 01249 BASE::TransAttribute(Transition(rX1,rEv,rX2),attr); 01250 return res; 01251 } 01252 01253 // Guard(trans) 01254 TEMP const TimeConstraint& THIS::Guard(const Transition& rTrans) const { 01255 #ifdef FAUDES_CHECKED 01256 if(!BASE::ExistsTransition(rTrans)) { 01257 std::stringstream errstr; 01258 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01259 throw Exception("tGenerator::Guard(trans)", errstr.str(), 200); 01260 } 01261 #endif 01262 return BASE::pTransRel->Attribute(rTrans).mGuard; 01263 } 01264 01265 01266 // Guardp(trans) 01267 TEMP TimeConstraint* THIS::Guardp(const Transition& rTrans) { 01268 #ifdef FAUDES_CHECKED 01269 if(!BASE::ExistsTransition(rTrans)) { 01270 std::stringstream errstr; 01271 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01272 throw Exception("tGenerator::Guardp(trans)", errstr.str(), 200); 01273 } 01274 #endif 01275 return &BASE::pTransRel->Attributep(rTrans)->mGuard; 01276 } 01277 01278 01279 // Guard(trans,guard) 01280 TEMP void THIS::Guard(const Transition& rTrans, const TimeConstraint& rGuard) { 01281 #ifdef FAUDES_CHECKED 01282 ConsistentTimeConstraint(rGuard); 01283 if(!BASE::ExistsTransition(rTrans)) { 01284 std::stringstream errstr; 01285 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01286 throw Exception("tGenerator::Guard(trans,guard)", errstr.str(), 200); 01287 } 01288 #endif 01289 BASE::pTransRel->Attributep(rTrans)->mGuard=rGuard; 01290 BASE::pTransRel->Attributep(rTrans)->mGuard.Name("Guard"); 01291 } 01292 01293 // InsGuard(trans,guard) 01294 TEMP void THIS::InsGuard(const Transition& rTrans, const TimeConstraint& rGuard) { 01295 #ifdef FAUDES_CHECKED 01296 ConsistentTimeConstraint(rGuard); 01297 if(!BASE::ExistsTransition(rTrans)) { 01298 std::stringstream errstr; 01299 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01300 throw Exception("tGenerator::InsGuard(trans,guard)", errstr.str(), 200); 01301 } 01302 #endif 01303 if(!rGuard.Empty()) { 01304 BASE::pTransRel->Attributep(rTrans)->mGuard.Insert(rGuard); 01305 } 01306 } 01307 01308 // ClrGuard(trans) 01309 TEMP void THIS::ClrGuard(const Transition& rTrans) { 01310 #ifdef FAUDES_CHECKED 01311 if(!BASE::ExistsTransition(rTrans)) { 01312 std::stringstream errstr; 01313 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01314 throw Exception("tGenerator::ClrGuard(trans)", errstr.str(), 200); 01315 } 01316 #endif 01317 if(!BASE::pTransRel->Attribute(rTrans).IsDefault()) 01318 BASE::pTransRel->Attributep(rTrans)->mGuard.Clear; 01319 } 01320 01321 01322 // Resets(trans) 01323 TEMP const ClockSet& THIS::Resets(const Transition& rTrans) const { 01324 #ifdef FAUDES_CHECKED 01325 if(!BASE::ExistsTransition(rTrans)) { 01326 std::stringstream errstr; 01327 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01328 throw Exception("tGenerator::Resets(trans)", errstr.str(), 200); 01329 } 01330 #endif 01331 return BASE::pTransRel->Attribute(rTrans).mResets; 01332 } 01333 01334 01335 // Resetsp(trans) 01336 TEMP ClockSet* THIS::Resetsp(const Transition& rTrans) { 01337 #ifdef FAUDES_CHECKED 01338 if(!BASE::ExistsTransition(rTrans)) { 01339 std::stringstream errstr; 01340 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01341 throw Exception("tGenerator::Resetsp(trans)", errstr.str(), 200); 01342 } 01343 #endif 01344 return &BASE::pTransRel->Attributep(rTrans)->mResets; 01345 } 01346 01347 01348 // Resets(trans,guard) 01349 TEMP void THIS::Resets(const Transition& rTrans, const ClockSet& rResets) { 01350 #ifdef FAUDES_CHECKED 01351 ConsistentClocks(rResets); 01352 if(!BASE::ExistsTransition(rTrans)) { 01353 std::stringstream errstr; 01354 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01355 throw Exception("tGenerator::Resets(trans,guard)", errstr.str(), 200); 01356 } 01357 #endif 01358 BASE::pTransRel->Attributep(rTrans)->mResets=rResets; 01359 BASE::pTransRel->Attributep(rTrans)->mResets.Name("Resets"); 01360 } 01361 01362 // InsResets(trans,guard) 01363 TEMP void THIS::InsResets(const Transition& rTrans, const ClockSet& rResets) { 01364 #ifdef FAUDES_CHECKED 01365 ConsistentClocks(rResets); 01366 if(!BASE::ExistsTransition(rTrans)) { 01367 std::stringstream errstr; 01368 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01369 throw Exception("tGenerator::InsResets(trans,guard)", errstr.str(), 200); 01370 } 01371 #endif 01372 if(!rResets.Empty()) { 01373 BASE::pTransRel->Attributep(rTrans)->mResets.InsertSet(rResets); 01374 } 01375 } 01376 01377 01378 // ClrResets(trans) 01379 TEMP void THIS::ClrResets(const Transition& rTrans) { 01380 #ifdef FAUDES_CHECKED 01381 if(!BASE::ExistsTransition(rTrans)) { 01382 std::stringstream errstr; 01383 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl; 01384 throw Exception("tGenerator::ClrResets(trans)", errstr.str(), 200); 01385 } 01386 #endif 01387 if(!BASE::pTransRel->Attribute(rTrans).IsDefault()) 01388 BASE::pTransRel->Attributep(rTrans)->mGuard.Clear; 01389 } 01390 01391 01392 // Valid() 01393 TEMP bool THIS::Valid(void) { 01394 FD_DV("tGenerator(" << this << ")::Valid()"); 01395 //call base 01396 if(!BASE::Valid()) return false; 01397 // check my names 01398 TransSet::Iterator tit; 01399 StateSet::Iterator sit; 01400 for(sit = BASE::StatesBegin(); sit!= BASE::StatesEnd(); ++sit) { 01401 if(Invariant(*sit).Name()!="Invariant") return false; 01402 } 01403 for(tit = BASE::TransRelBegin(); tit!= BASE::TransRelEnd(); ++tit) { 01404 if(Guard(*tit).Name()!="Guard") return false; 01405 if(Resets(*tit).Name()!="Resets") return false; 01406 } 01407 if(Clocks().Name()!="Clocks") return false; 01408 // check my clockset 01409 ClockSet aclocks=ActiveClocks(); 01410 if(!(aclocks <= Clocks())) return false; 01411 // check all clocksymboltables 01412 for(sit = BASE::StatesBegin(); sit!= BASE::StatesEnd(); ++sit) { 01413 if(Invariant(*sit).ClockSymbolTablep()!=ClockSymbolTablep()) return false; 01414 } 01415 for(tit = BASE::TransRelBegin(); tit!= BASE::TransRelEnd(); ++tit) { 01416 if(Guard(*tit).ClockSymbolTablep()!=ClockSymbolTablep()) return false; 01417 if(Resets(*tit).SymbolTablep()!=ClockSymbolTablep()) return false; 01418 } 01419 if(Clocks().SymbolTablep()!=ClockSymbolTablep()) return false; 01420 01421 return true; 01422 } 01423 01424 01425 // UpdateAttributes() 01426 TEMP bool THIS::UpdateAttributes(void) { 01427 FD_DG("tGenerator(" << this << ")::UpdateAttributes()"); 01428 01429 // debugging example: flag blocking states 01430 // btw: need efficient methods to set/clr flags by sets 01431 StateSet blockstates=BASE::BlockingStates(); 01432 StateSet::Iterator sit; 01433 for(sit=BASE::StatesBegin(); sit!= BASE::StatesEnd(); sit++) { 01434 StateAttr attr=BASE::StateAttribute(*sit); 01435 if(blockstates.Exists(*sit)) { 01436 attr.Set(0x20000000); 01437 } else { 01438 attr.Clr(0x20000000); 01439 } 01440 BASE::StateAttribute(*sit,attr); 01441 }; 01442 01443 return true; 01444 } 01445 01446 01447 01448 // CStr(index) 01449 TEMP std::string THIS::CStr(Idx index) const { 01450 return BASE::pGlobalAttribute->mClocks.Str(index); 01451 } 01452 01453 01454 01455 #undef BASE 01456 #undef THIS 01457 #undef TEMP 01458 01459 01460 01461 } // namespace faudes 01462 01463 01464 #endif 01465 |
libFAUDES 2.18b --- 2010-12-17 --- c++ source docu by doxygen 1.6.3