tp_tgenerator.h

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

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen