pd_pdgenerator.h

Go to the documentation of this file.
00001 /** @file pd_pdgenerator.h  pushdown generator class TpdGenerator */
00002 
00003 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2013  Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
00006 
00007 */
00008 
00009 #ifndef FAUDES_PD_PDGENERATOR_H
00010 #define FAUDES_PD_PDGENERATOR_H
00011 #define FAUDES_DEBUG_GENERATOR
00012 #define FAUDES_DEBUG_CONTAINER
00013 
00014 #include "corefaudes.h"
00015 #include "pd_attributes.h"
00016 #include "pd_grammar.h"
00017 
00018 
00019 namespace faudes {
00020 
00021 
00022 
00023 /**
00024  * Generator with push down extensions. 
00025  *
00026  *
00027  * @ingroup PushdownPlugin
00028  * 
00029  * @section Overview
00030  *  tratarterteartawrtrae
00031  * 
00032  * @section Contents
00033  *  fvdgdthrthorthtiop
00034  */
00035 
00036 template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
00037 class TpdGenerator : public TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> {  
00038   
00039 public:
00040   /**
00041    * Constructor
00042    */
00043   TpdGenerator(void);
00044   
00045   /** 
00046    * Copy constructor 
00047    *
00048    * @param rOtherGen
00049    */
00050   TpdGenerator(const TpdGenerator& rOtherGen);
00051   
00052   /** 
00053    * Copy constructor (no attributes)
00054    *
00055    * @param rOtherGen
00056    */
00057   TpdGenerator(const vGenerator& rOtherGen);
00058   
00059   /**
00060    * Assignment operator (uses copy)
00061    *  Note: you must reimplement this operator in derived 
00062    *  classes in order to handle internal pointers correctly
00063    *
00064    * @param rOtherGen
00065    *   Other generator
00066    */
00067   virtual TpdGenerator& operator= (const TpdGenerator& rOtherGen) {this->Assign(rOtherGen); return *this;};
00068 
00069   /**
00070    * Assignment operator (uses copy)
00071    *
00072    * @param rOtherGen
00073    *   Other generator
00074    */
00075   virtual TpdGenerator& operator= (const vGenerator& rOtherGen) {this->Assign(rOtherGen); return *this;};
00076   
00077   /**
00078    * Construct from file
00079    *
00080    * @param rFileName
00081    *   Name of file
00082    *
00083    * @exception Exception
00084    *   - file format errors (id 1, 50, 51, 52)
00085    */
00086   TpdGenerator(const std::string& rFileName);
00087   
00088   /**
00089    * Construct on heap. 
00090    * Constructs a TpdGenerator on heap.
00091    *
00092    * @return 
00093    *   new Generator 
00094    */
00095   TpdGenerator* New(void) const;
00096   
00097   /**
00098    * Construct copy on heap. 
00099    * Constructs a TpdGenerator on heap.
00100    *
00101    * @return 
00102    *   new Generator 
00103    */
00104   TpdGenerator* Copy(void) const;
00105   
00106   /**
00107    * Type test.
00108    * Uses C++ dynamic cast to test whether the specified object
00109    * casts to a PushdownGenerator.
00110    *
00111    * @return 
00112    *   TpdGenerator reference if dynamic cast succeeds, else NULL 
00113    */
00114   virtual const Type* Cast(const Type* pOther) const {
00115     return dynamic_cast< const TpdGenerator* > (pOther);
00116   };
00117   
00118   
00119   /**
00120    * Construct on stack.
00121    * Constructs a TpdGenerator on stack.
00122    *
00123    * @return 
00124    *   new Generator 
00125    */
00126   TpdGenerator NewPdGen(void) const;
00127   
00128     /**
00129     * Get Pointer to global StackSymbolTable. This is
00130     * a static member of SymbolTable and used as default
00131     * for all derived generator classes and instantiated objects.
00132     *
00133     * @return
00134     *   Pointer to global StackSymbolTable
00135     */
00136     static SymbolTable* GlobalStackSymbolTablep(void);
00137     
00138     
00139     /**
00140     * Get Pointer to mpStackSymbolTable.
00141     *
00142     * @return Pointer mpStackSymbolTable
00143     */
00144     SymbolTable* StackSymbolTablep(void) const;
00145 
00146    /**
00147     * Set StackSymbolTable.
00148     *
00149     * @param pStackSymTab
00150     *    Pointer SymbolTable
00151     */
00152     void StackSymbolTablep(SymbolTable* pStackSymTab);
00153   
00154     /**
00155      * Return a NameSet with generator's StackSymbolTable 
00156      *
00157      * @return
00158      *   New empty StackSymbolSet on stack
00159      */
00160      StackSymbolSet NewStackSymbolSet(void) const;
00161 
00162     /**
00163      * Construct a stack symbol on heap.
00164      *
00165      * @return
00166      *   Pointer to new empty StackSymbolSet on heap
00167      */
00168      StackSymbolSet* NewStackSymbolSetp(void) const;
00169 
00170    /**
00171     * Number of stacks symbols in mStackSymbols
00172     *
00173     * @return Number of stack symbols in mStackSymbols
00174     */
00175     Idx StackSymbolsSize(void) const;
00176 
00177    /**
00178     * Get stack symbol set as const reference
00179     *
00180     * @return mStackSymbols
00181     */
00182     const StackSymbolSet& StackSymbols(void) const;
00183 
00184 
00185    /**
00186     * Get stack symbol set as pointer
00187     *
00188     * @return mStackSymbols
00189     */
00190     StackSymbolSet* StackSymbolsp(void);
00191 
00192    /**
00193     * Overwrites mStackSymbols with new stack symbols without consistency check
00194     *
00195     * @param newstacksymbols
00196     *    New stack symbols that are written to mStackSymbols
00197     */
00198     void InjectStackSymbols(const StackSymbolSet& newstacksymbols);
00199 
00200    /**
00201     * Looks up stack symbol name for given index
00202     *
00203     * @param index
00204     *    Stack symbol index
00205     *
00206     * @return Stack symbol name
00207     */
00208     std::string StackSymbolName(Idx index) const;
00209     
00210     /**
00211     * Returns stack symbol for given index
00212     *
00213     * @param index
00214     *    Stack symbol index
00215     *
00216     * @return Stack symbol object
00217     */
00218     StackSymbol StackSymbolObj(Idx index) const;
00219     
00220     /**
00221     * Looks up stack symbol index for given name
00222     *
00223     * @param rName
00224     *    Stack symbol name
00225     *
00226     * @return Stack symbol index or 0 for nonexistent
00227     */
00228     Idx StackSymbolIndex(const std::string& rName) const;
00229 
00230     /**
00231     * Add named stack symbol to generator. An entry in the mpStackSymbolTable will
00232     * be made if stack symbol is new.
00233     *
00234     * @param rName
00235     *   Name of the stack symbol to add
00236     *
00237     * @return 
00238     *   New unique index
00239     */
00240     Idx InsStackSymbol(const std::string& rName);
00241     
00242     /**
00243     * Add stack symbol to generator. An entry in the mpStackSymbolTable will
00244     * be made if stack symbol is new.
00245     *
00246     * @param rSymbol
00247     *   The stack symbol to add
00248     *
00249     * @return 
00250     *   New unique index
00251     */
00252     Idx InsStackSymbol(const StackSymbol& rSymbol);
00253     
00254     /**
00255     * Add named stack bottom to generator. An entry in the mpStackSymbolTable will
00256     * be made if stack symbol is new. This will replace any old stack bottom symbol.
00257     *
00258     * @param rName
00259     *   Name of the stack bottom symbol to add
00260     *
00261     * @return 
00262     *   Stack bottom symbol index
00263     */
00264     Idx SetStackBottom(const std::string& rName);
00265     
00266     /**
00267     * Add stack bottom to generator. An entry in the mpStackSymbolTable will
00268     * be made if stack symbol is new. This will replace any old stack bottom symbol.
00269     *
00270     * @param rSymbol
00271     *   The stack bottom symbol to add
00272     *
00273     * @return 
00274     *   Stack bottom symbol index
00275     */
00276     Idx SetStackBottom(const StackSymbol& rSymbol);
00277     
00278     /**
00279     * Add stack bottom to generator. An entry in the mpStackSymbolTable will
00280     * be made if stack symbol is new. This will replace any old stack bottom symbol.
00281     *
00282     * @param idx
00283     *   The index of the stack bottom symbol to add
00284     *
00285     * @return 
00286     *   Stack bottom symbol index
00287     */
00288     Idx SetStackBottom(const Idx idx);
00289     
00290     /**
00291      * Get the index of the stack bottom symbol
00292      * 
00293      * @return
00294      *      index of the stack bottom symbol
00295      */
00296     Idx StackBottom() const;
00297     
00298     /**
00299     * Add new named stack symbols to generator.
00300     *
00301     * @param rStackSymbolSet
00302     *   StackSymbolSet
00303     */
00304     void InsStackSymbols(const StackSymbolSet& rStackSymbolSet);
00305 
00306     /**
00307     * Delete stack symbol from generator by index.
00308     *
00309     * @param index
00310     *   Index of stack symbol
00311     * @return
00312     *   True if stack symbol did exist
00313     *
00314     */
00315     bool DelStackSymbol(Idx index);
00316     
00317     /**
00318     * Delete stack symbol from generator by name. mpStackSymbolTable stays untouched.
00319     *
00320     * @param rName
00321     *    Name of stack symbol
00322     * @return
00323     *    True if stack symbol did exist
00324     */
00325     bool DelStackSymbol(const std::string& rName);
00326     
00327     /** 
00328     * Delete a set of stack symbols from generator. 
00329     * 
00330     * @param rStackSymbols
00331     *   StackSymbolSet containing stack symbols to remove
00332     */
00333     void DelStackSymbols(const StackSymbolSet& rStackSymbols);
00334     
00335    /** 
00336     * Test existence of stack symbol in mStackSymbols
00337     *
00338     * @param index
00339     *   Stack symbol index
00340     *
00341     * @return
00342     *   true / false
00343     */
00344     bool ExistsStackSymbol(Idx index) const;
00345 
00346    /** 
00347     * Test existence of stack symbol in mStackSymbols
00348     *
00349     * @param rName
00350     *   Stack symbol name
00351     *
00352     * @return
00353     *   True if stack symbol exists
00354     */
00355     bool ExistsStackSymbol(const std::string& rName) const;
00356 
00357    /**
00358     * Returns an iterator to stack symbol index in mStackSymbols
00359     *
00360     * @param index
00361     *   Index to find
00362     *
00363     * @return
00364     *   StackSymbolSet::Iterator to stack symbol index
00365     */
00366     StackSymbolSet::Iterator FindStackSymbol(Idx index) const;
00367 
00368    /**
00369     * Returns an iterator to stack symbol index in mStackSymbols
00370     *
00371     * @param rName
00372     *   Stack symbol name of index to find
00373     *
00374     * @return
00375     *   StackSymbolSet::Iterator to stack symbol index
00376     */
00377     StackSymbolSet::Iterator FindStackSymbol(const std::string& rName) const;
00378 
00379    /**
00380     * Iterator to Begin() of mStackSymbols
00381     *
00382     * @return iterator to begin of mStackSymbols
00383     */
00384     StackSymbolSet::Iterator StackSymbolsBegin(void) const;
00385     
00386     /**
00387     * Iterator to End() of mStackSymbols
00388     *
00389     * @return iterator to end of mStackSymbols
00390     */
00391     StackSymbolSet::Iterator StackSymbolsEnd(void) const;
00392     
00393     /**
00394      * Converts a vector of stack symbols to a vector of Idx
00395      * 
00396      * @param symbols
00397      *      the vector of stack symbols
00398      * @return
00399      *      vector of Idx
00400      */
00401     std::vector<Idx> StackSymbolsToIndices(const std::vector<StackSymbol> symbols) const;
00402     
00403     
00404     /**
00405      * Get number of transitions including pop-push-pairs
00406      * 
00407      * @return
00408      *      number of transitions
00409      */
00410     Idx TransRelSize() const;
00411     
00412   /** 
00413    * Add a transition to generator by indices. States and event
00414    * must already exist!
00415    *
00416    * Define FAUDES_CHECKED for consistency checks.
00417    *
00418    * @param x1 
00419    *   Predecessor state index 
00420    * @param ev 
00421    *   Event index 
00422    * @param x2
00423    *   Successor state index
00424    *
00425    * @return
00426    *   True, if the transition was new the generator
00427    *
00428    * @exception Exception
00429    *   - state or event not in generator (id 95)
00430    */
00431   bool SetTransition(Idx x1, Idx ev, Idx x2);
00432   
00433   /** 
00434    * Add a transition to generator by names. Statename and eventname
00435    * must already exist!
00436    *
00437    * @param rX1
00438    *   Predecessor state name
00439    * @param rEv
00440    *   Event name
00441    * @param rX2
00442    *   Successor state name
00443    *
00444    * @return
00445    *   True, if the transition was new the generator
00446    *
00447    * @exception Exception
00448    *   - state or event not in generator (id 95)
00449    *   - state name not known (id 90)
00450    *   - event name not known (id 66)
00451    */
00452   bool SetTransition(const std::string& rX1, const std::string& rEv, 
00453              const std::string& rX2);
00454   
00455   /** 
00456    * Add a transition with attribute to generator. States and event
00457    * must already exist!
00458    *
00459    * Define FAUDES_CHECKED for consistency checks.
00460    *
00461    * @param rTransition
00462    *   transition
00463    * @param rAttr
00464    *   attribute
00465    *
00466    * @return
00467    *   True, if the transition was new the generator
00468    *
00469    */
00470   bool SetTransition(const Transition& rTransition, const TransAttr& rAttr);
00471   
00472   /**
00473    * Inserts new PushdownTransition constructed from parameters.
00474    * Performs consistency checks for x1, x2, ev and all stack symbols in rPop and rPush.
00475    *
00476    * @param rTrans
00477    *    new transition 
00478    * @param rPop
00479    *    Stack symbol vector to be popped when transitioning
00480    * @param rPush
00481    *    Stack symbol vector to be pushed when transitioning
00482    * @return
00483    *   True, if the transition was new to the generator
00484    */
00485   bool SetTransition(const Transition& rTrans, const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush);
00486     
00487     
00488     /**
00489      * Inserts new PushdownTransition constructed from parameters.
00490      * Performs consistency checks for x1, x2, ev and all stack symbols in rPop and rPush.
00491      *
00492      * @param rTrans
00493      *    new transition 
00494      * @param rPop
00495      *    Stack symbol vector to be popped when transitioning
00496      * @param rPush
00497      *    Stack symbol vector to be pushed when transitioning
00498      * @return
00499      *   True, if the transition was new to the generator
00500      */
00501     bool SetTransition(const Transition& rTrans, const std::vector<Idx>& rPop, const std::vector<Idx>& rPush);
00502 
00503   
00504     /**
00505      * Inserts new PushdownTransition constructed from parameters.
00506      * Performs consistency checks for x1, x2, ev and stack symbols in rPop and rPush.
00507      *
00508      * @param x1
00509      *    Start state of new PushdownTransition.
00510      * @param ev
00511      *    Event of new PushdownTransition.
00512      * @param x2
00513      *    End state of new PushdownTransition.
00514      * @param rPop
00515      *    Stack symbol vector to be popped when transitioning
00516      * @param rPush
00517      *    Stack symbol vector to be pushed when transitioning
00518      * @return
00519      *   True, if the transition was new to the generator
00520      */
00521     bool SetTransition(Idx x1, Idx ev, Idx x2,
00522               const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush);
00523     
00524     /**
00525      * Inserts new PushdownTransition constructed from parameters.
00526      * Performs consistency checks for x1, x2, ev and stack symbols in rPop and rPush.
00527      *
00528      * @param x1
00529      *    Start state of new PushdownTransition.
00530      * @param ev
00531      *    Event of new PushdownTransition.
00532      * @param x2
00533      *    End state of new PushdownTransition.
00534      * @param rPop
00535      *    Stack symbol vector to be popped when transitioning
00536      * @param rPush
00537      *    Stack symbol vector to be pushed when transitioning
00538      * @return
00539      *   True, if the transition was new to the generator
00540      */
00541     bool SetTransition(Idx x1, Idx ev, Idx x2,
00542               const std::vector<Idx>& rPop, const std::vector<Idx>& rPush);
00543   
00544     /**
00545      * Inserts new PushdownTransition constructed from parameters.
00546      * Performs consistency checks for x1, x2, ev and stack symbols in rPop and rPush.
00547      *
00548      * @param rX1
00549      *    Start state of new PushdownTransition.
00550      * @param rEv
00551      *    Event of new PushdownTransition.
00552      * @param rX2
00553      *    End state of new PushdownTransition.
00554      * @param rPop
00555      *    Stack symbol vector to be popped when transitioning
00556      * @param rPush
00557      *    Stack symbol vector to be pushed when transitioning
00558      * @return
00559      *   True, if the transition was new to the generator
00560     */
00561     bool SetTransition(const std::string& rX1, const std::string& rEv, const std::string& rX2, const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush);
00562     
00563     /**
00564      * Inserts new PushdownTransition constructed from parameters.
00565      * Performs consistency checks for x1, x2, ev and stack symbols in rPop and rPush.
00566      *
00567      * @param rX1
00568      *    Start state of new PushdownTransition.
00569      * @param rEv
00570      *    Event of new PushdownTransition.
00571      * @param rX2
00572      *    End state of new PushdownTransition.
00573      * @param rPop
00574      *    Stack symbol vector to be popped when transitioning
00575      * @param rPush
00576      *    Stack symbol vector to be pushed when transitioning
00577      * @return
00578      *   True, if the transition was new to the generator
00579     */
00580     bool SetTransition(const std::string& rX1, const std::string& rEv, const std::string& rX2, const std::vector<Idx>& rPop, const std::vector<Idx>& rPush);
00581     
00582     /**
00583      * Delete an exisiting PushdownTransition with the provided parameters.
00584      *
00585      * @param x1
00586      *    Start state of the PushdownTransition.
00587      * @param ev
00588      *    Event of the PushdownTransition.
00589      * @param x2
00590      *    End state of the PushdownTransition.
00591      * @param rPop
00592      *    Stack symbol vector to be popped when transitioning
00593      * @param rPush
00594      *    Stack symbol vector to be pushed when transitioning
00595      * @return
00596      *   True, if the transition was deleted from the generator
00597      */
00598     bool ClrTransition(Idx x1, Idx ev, Idx x2,
00599               const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush);
00600     
00601     /**
00602      * Delete an exisiting PushdownTransition with the provided parameters.
00603      *
00604      * @param x1
00605      *    Start state of the PushdownTransition.
00606      * @param ev
00607      *    Event of the PushdownTransition.
00608      * @param x2
00609      *    End state of the PushdownTransition.
00610      * @param rPop
00611      *    Stack symbol vector to be popped when transitioning
00612      * @param rPush
00613      *    Stack symbol vector to be pushed when transitioning
00614      * @return
00615      *   True, if the transition was deleted from the generator
00616      */
00617     bool ClrTransition(Idx x1, Idx ev, Idx x2,
00618               const std::vector<Idx>& rPop, const std::vector<Idx>& rPush);
00619     
00620     
00621     /**
00622      * Delete an exisiting PushdownTransition with the provided parameters.
00623      *
00624      * @param rTrans
00625      *    the transition
00626      * @param rPop
00627      *    Stack symbol vector to be popped when transitioning
00628      * @param rPush
00629      *    Stack symbol vector to be pushed when transitioning
00630      * @return
00631      *   True, if the transition was deleted from the generator
00632      */
00633     bool ClrTransition(const Transition& rTrans,
00634               const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush);
00635     
00636     /**
00637      * Delete an exisiting PushdownTransition with the provided parameters.
00638      *
00639      * @param rTrans
00640      *    the transition
00641      * @param rPop
00642      *    Stack symbol vector to be popped when transitioning
00643      * @param rPush
00644      *    Stack symbol vector to be pushed when transitioning
00645      * @return
00646      *   True, if the transition was deleted from the generator
00647      */
00648     bool ClrTransition(const Transition& rTrans,
00649               const std::vector<Idx>& rPop, const std::vector<Idx>& rPush);
00650 
00651 
00652     /**
00653      * Get the pop/push set attached to this transition
00654      * 
00655      * @param rTrans
00656      *      the transition
00657      * @return
00658      *      the pop/push set
00659      */
00660     const PopPushSet& PopPush(const Transition& rTrans) const;
00661     
00662     /**
00663      * Get an iterator to the beginning of the pop/push set attached to this
00664      * transition
00665      * 
00666      * @param rTrans
00667      *      the transition
00668      * @return
00669      *      iterator to the beginning of the pop/push set
00670      */
00671     PopPushSet::const_iterator PopPushBegin(const Transition& rTrans) const;
00672     
00673     /**
00674      * Get an iterator to the end of the pop/push set attached to this
00675      * transition
00676      * 
00677      * @param rTrans
00678      *      the transition
00679      * @return
00680      *      iterator to the end of the pop/push set
00681      */
00682     PopPushSet::const_iterator PopPushEnd(const Transition& rTrans) const;
00683     
00684      
00685     /**
00686      * determine if the stack symbol associated with the given index is lambda
00687      * 
00688      * @param index
00689      *      index of a stack symbol
00690      * @return
00691      *      true if the associated stack symbol is lambda, else false
00692      */
00693     bool IsStackSymbolLambda(Idx index) const;
00694     
00695     /**
00696      * determine if the event associated with the given index is lambda
00697      * 
00698      * @param index
00699      *      index of an event
00700      * @return
00701      *      true if the associated event is lambda, else false
00702      */
00703     bool IsEventLambda(Idx index) const;
00704   
00705     
00706    /**
00707     * Throw exception if stack symbol refers to stack symbol not
00708     * in stack symbol set
00709     *
00710     * @exception Exception
00711     *   - invalid stack symbol (id 1001)
00712     */
00713     void ConsistentStackSymbol(const StackSymbol& rStackSymbol) const;
00714     
00715     /**
00716     * Throw exception if stack symbol refers to stack symbol not
00717     * in stack symbol set
00718     *
00719     * @exception Exception
00720     *   - invalid stack symbol (id 1001)
00721     */
00722     void ConsistentStackSymbol(Idx idx) const;
00723 
00724     /**
00725     * Throw exception if vector of stack symbols contains stack symbols not
00726     * in generators stack symbol set 
00727     *
00728     * @exception Exception
00729     *   - invalid stack symbol (id 1001)
00730     */
00731     void ConsistentVectorStackSymbol(const std::vector<StackSymbol>& rVector) const;
00732     
00733    /**
00734     * Throw exception if vector of stack symbols contains stack symbols not
00735     * in generators stack symbol set 
00736     *
00737     * @exception Exception
00738     *   - invalid stack symbol (id 1001)
00739     */
00740     void ConsistentVectorStackSymbol(const std::vector<Idx>& rVector) const;
00741     
00742     /**
00743     * Throw exception if vector of stack symbols is empty 
00744     *
00745     * @exception Exception
00746     *   - invalid stack symbol (id 1001)
00747     */
00748     void EmptyVectorPopPush(const std::vector<StackSymbol>& rVector) const;
00749     
00750     /**
00751     * Throw exception if vector of stack symbols is empty 
00752     *
00753     * @exception Exception
00754     *   - invalid stack symbol (id 1001)
00755     */
00756     void EmptyVectorPopPush(const std::vector<Idx>& rVector) const;
00757   
00758     /**
00759      * Marks a state as being merged from other data type by setting mpMerge.
00760      * 
00761      * @param stateName
00762      *      the name of the state to mark
00763      * @param rMerge
00764      *      the merged state
00765      */
00766      void SetMerge(const std::string& stateName, MergeAbstract& rMerge);
00767      
00768      /**
00769       * Marks a state as being merged from other data type by setting mpMerge.
00770       * 
00771       * @param index
00772       *      the index of the state to mark
00773       * @param rMerge
00774       *      the merged state
00775       */
00776      void SetMerge(Idx index, MergeAbstract& rMerge);
00777      
00778      /**
00779       * Return the merge attribute of a state.
00780       * 
00781       * @param index
00782       *      the index of the state
00783       */
00784      const MergeAbstract* Merge(Idx index) const;
00785      
00786      /**
00787       * Marks a state as being derived from the intersection with a DFA.
00788       * 
00789       * @param stateName
00790       *      the name of the state to mark
00791       * @param dfaIndex
00792       *      the index of the DFA state
00793       */
00794      void SetDfaState(const std::string& stateName, Idx dfaIndex);
00795      
00796      /**
00797       * Marks a state as being derived from the intersection with a DPA.
00798       * 
00799       * @param index
00800       *      the index of the state to mark
00801       * @param dfaIndex
00802       *      the index of the DFA state
00803       */
00804      void SetDfaState(Idx index, Idx dfaIndex);
00805      
00806      /**
00807       * Return the dfaState attribute of a state.
00808       * 
00809       * @param index
00810       *      the index of the state
00811       */
00812      Idx DfaState(Idx index) const;
00813      
00814     /** 
00815      * Check if generator is valid 
00816      *
00817      * @return 
00818      *   Success
00819      */
00820     virtual bool Valid(void);
00821   
00822 }; //end class TpdGenerator
00823 
00824 /** Convenience typedef for std PushdownGenerator */
00825 typedef TpdGenerator<AttributePushdownGlobal, AttributePushdownState, AttributeCFlags,AttributePushdownTransition>
00826   PushdownGenerator;
00827   
00828 typedef TaTransSet<AttributePushdownTransition> PdTransSet;
00829 
00830 
00831 // convenient scope macros  
00832 #define THIS TpdGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
00833 #define BASE TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
00834 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
00835 
00836 // TpdGenerator(void)
00837 TEMP THIS::TpdGenerator(void) : BASE() {
00838   // set basic members (cosmetic)
00839   BASE::pGlobalAttribute->mStackSymbols.Name("StackSymbols");
00840   BASE::pGlobalAttribute->mpStackSymbolTable=StackSymbolSet::StaticSymbolTablep();
00841   FD_DG("PushdownGenerator(" << this << ")::PushdownGenerator() with csymtab " 
00842     << (BASE::pGlobalAttribute->mpStackSymbolTable ));
00843 }
00844 
00845 
00846 
00847 // TpdGenerator(rOtherGen)
00848 TEMP THIS::TpdGenerator(const TpdGenerator& rOtherGen) : BASE(rOtherGen) {
00849   FD_DG("PushdownGenerator(" << this << ")::PushdownGenerator(rOtherGen) with csymtab" 
00850     << "(BASE::pGlobalAttribute->mpStackSymbolTable)" );
00851 }
00852 
00853 // TpdGenerator(rOtherGen)
00854 TEMP THIS::TpdGenerator(const vGenerator& rOtherGen) : BASE(rOtherGen) {
00855   // set basic members (cosmetic)
00856   BASE::pGlobalAttribute->mStackSymbols.Name("StackSymbols");
00857   BASE::pGlobalAttribute->mpStackSymbolTable=StackSymbolSet::StaticSymbolTablep();
00858   FD_DG("PushdownGenerator(" << this << ")::PushdownGenerator(rOtherGen) with csymtab" 
00859     << "(BASE::pGlobalAttribute->mpStackSymbolTable)" );
00860 }
00861 
00862 // TpdGenerator(rFilename)
00863 TEMP THIS::TpdGenerator(const std::string& rFileName) : BASE(rFileName) {
00864   FD_DG("PushdownGenerator(" << this << ")::PushdownGenerator(" << rFileName << ") with csymtab" 
00865     << "(BASE::pGlobalAttribute->mpStackSymbolTable)" );
00866 }
00867 
00868 //GlobalStackSymbolTablep
00869 TEMP SymbolTable* THIS::GlobalStackSymbolTablep(void) {
00870   return StackSymbolSet::StaticSymbolTablep();
00871 }
00872 
00873 // StackSymbolTablep()
00874 TEMP SymbolTable* THIS::StackSymbolTablep(void) const {
00875   return BASE::pGlobalAttribute->mpStackSymbolTable;
00876 }
00877 
00878 // StackSymbolTablep(pSymTab)
00879 TEMP void THIS::StackSymbolTablep(SymbolTable* pSymTab) {
00880    BASE::Clear(); // TODO: relax this
00881    BASE::pGlobalAttribute->mpStackSymbolTable=pSymTab;
00882 }
00883 
00884 // New
00885 TEMP THIS* THIS::New(void) const {
00886   // allocate
00887   THIS* res = new THIS;
00888   // fix base data
00889   res->EventSymbolTablep(BASE::mpEventSymbolTable);
00890   res->mStateNamesEnabled=BASE::mStateNamesEnabled;
00891   res->mReindexOnWrite=BASE::mReindexOnWrite;  
00892   // fix my data
00893   res->StackSymbolTablep(StackSymbolTablep());
00894   return res;
00895 }
00896 
00897 // Copy
00898 TEMP THIS* THIS::Copy(void) const {
00899   // allocate
00900   THIS* res = new THIS(*this);
00901   // done
00902   return res;
00903 }
00904 
00905 // NewTGen
00906 TEMP THIS THIS::NewPdGen(void) const {
00907   // call base (fixes by assignment constructor)
00908   THIS res= BASE::NewCGen();
00909   // fix my data
00910   res.StackSymbolTablep(StackSymbolTablep());
00911   return res;
00912 }
00913 
00914 // StackSymbolsSize() const
00915 TEMP Idx THIS::StackSymbolsSize(void) const {
00916   return BASE::pGlobalAttribute->mStackSymbols.Size();
00917 }
00918 
00919 // StackSymbols()
00920 TEMP const StackSymbolSet& THIS::StackSymbols(void) const {
00921   return BASE::pGlobalAttribute->mStackSymbols;
00922 }
00923 
00924 // StackSymbolssp()
00925 TEMP StackSymbolSet* THIS::StackSymbolsp(void) {
00926   return &BASE::pGlobalAttribute->mStackSymbols;
00927 }
00928 
00929 // InjectStackSymbols(set)
00930 TEMP void THIS::InjectStackSymbols(const StackSymbolSet& newstacksymbols) {
00931   BASE::pGlobalAttribute->mStackSymbols=newstacksymbols;
00932   BASE::pGlobalAttribute->mStackSymbols.Name("StackSymbols");
00933 }
00934 
00935 // StackSymbolName(index)
00936 TEMP std::string THIS::StackSymbolName(Idx index) const {
00937   return BASE::pGlobalAttribute->mStackSymbols.SymbolicName(index);
00938 }
00939 
00940 //StackSymbolObj(index)
00941 TEMP StackSymbol THIS::StackSymbolObj(Idx index) const {
00942   return StackSymbol(BASE::pGlobalAttribute->mStackSymbols.SymbolicName(index));
00943 }
00944 
00945 // StackSymbolIndex(name)
00946 TEMP Idx THIS::StackSymbolIndex(const std::string& rName) const {
00947   return BASE::pGlobalAttribute->mStackSymbols.Index(rName);
00948 }
00949 
00950 // InsStackSymbol(name)
00951 TEMP Idx THIS::InsStackSymbol(const std::string& rName) {
00952   return BASE::pGlobalAttribute->mStackSymbols.Insert(rName);
00953 }
00954 
00955 //InsStackSymbol(symbol)
00956 TEMP Idx THIS::InsStackSymbol(const StackSymbol& rSymbol){
00957   return BASE::pGlobalAttribute->mStackSymbols.Insert(rSymbol.Symbol());
00958 }
00959 
00960 // InsStackSymbols(set)
00961 TEMP void THIS::InsStackSymbols(const StackSymbolSet& rStackSymbolSet) {
00962   BASE::pGlobalAttribute->mStackSymbols.InsertSet(rStackSymbolSet);
00963 }
00964 
00965 // SetStackBottom(name)
00966 TEMP Idx THIS::SetStackBottom(const std::string& rName) {
00967   Idx i = BASE::pGlobalAttribute->mStackSymbols.Insert(rName);
00968   BASE::pGlobalAttribute->mStackBottom = i;
00969   return i;
00970 }
00971 
00972 //SetStackBottom(symbol)
00973 TEMP Idx THIS::SetStackBottom(const StackSymbol& rSymbol){
00974   Idx i = BASE::pGlobalAttribute->mStackSymbols.Insert(rSymbol.Symbol());
00975   BASE::pGlobalAttribute->mStackBottom = i;
00976   return i;
00977 }
00978 
00979 //SetStackBottom(index)
00980 TEMP Idx THIS::SetStackBottom(const Idx idx){
00981   if(!ExistsStackSymbol(idx)) {
00982       std::stringstream errstr;
00983       errstr << "stack symbol with index " << idx << " not found in generator. " << std::endl;
00984       throw Exception("PushdownGenerator::SetStackBottom(idx)", errstr.str(), 200);
00985   }
00986   BASE::pGlobalAttribute->mStackBottom = StackSymbol(StackSymbolName(idx));
00987   return idx;
00988 }
00989 
00990 //StackBottom()
00991 TEMP Idx THIS::StackBottom() const{
00992   return BASE::pGlobalAttribute->mStackBottom;
00993 }
00994 
00995 // DelStackSymbol(index)
00996 TEMP bool THIS::DelStackSymbol(Idx index) {
00997   FD_DG("PushdownGenerator(" << this << ")::DelStackSymbol(" << index << ")");
00998   return BASE::pGlobalAttribute->mStackSymbols.Erase(index);
00999 }
01000 
01001 // DelStackSymbol(name)
01002 TEMP bool THIS::DelStackSymbol(const std::string& rName) {
01003   Idx index=BASE::pGlobalAttribute->mStackSymbols.Index(rName);
01004   return DelStackSymbol(index);
01005 }
01006 
01007 // DelStackSymbols(set)
01008 TEMP void THIS::DelStackSymbols(const StackSymbolSet& rStackSymbols) {
01009   StackSymbolSet::Iterator it=StackSymbolsBegin();
01010   while(it!=StackSymbolsEnd()){
01011     DelStackSymbol(*(it++)); // fixed: 2013-12-17
01012   }
01013 }
01014 
01015 // ExistsStackSymbol(index)
01016 TEMP bool THIS::ExistsStackSymbol(Idx index) const {
01017   return BASE::pGlobalAttribute->mStackSymbols.Exists(index);
01018 }
01019 
01020 // ExistsStackSymbol(name)
01021 TEMP bool THIS::ExistsStackSymbol(
01022   const std::string& rName) const {
01023   return BASE::pGlobalAttribute->mStackSymbols.Exists(rName);
01024 }
01025 
01026 // FindStackSymbol(index)
01027 TEMP StackSymbolSet::Iterator THIS::FindStackSymbol(Idx index) const {
01028   return BASE::pGlobalAttribute->mStackSymbols.Find(index);
01029 }
01030 
01031 // FindStackSymbol(name)
01032 TEMP StackSymbolSet::Iterator THIS::FindStackSymbol(const std::string& rName) const {
01033   return BASE::pGlobalAttribute->mStackSymbols.Find(rName);
01034 }
01035 
01036 // iterator StackSymbolsBegin() const
01037 TEMP StackSymbolSet::Iterator THIS::StackSymbolsBegin(void) const {
01038   return BASE::pGlobalAttribute->mStackSymbols.Begin();
01039 }
01040 
01041 // iterator StackSymbolsEnd() const
01042 TEMP StackSymbolSet::Iterator THIS::StackSymbolsEnd(void) const {
01043   return BASE::pGlobalAttribute->mStackSymbols.End();
01044 }
01045 //StackSymbolsToIndices
01046 TEMP std::vector<Idx> THIS::StackSymbolsToIndices(const std::vector<StackSymbol> symbols) const{
01047   std::vector<StackSymbol>::const_iterator ssit;
01048   std::vector<Idx> rV;
01049   for(ssit = symbols.begin(); ssit != symbols.end(); ssit++){
01050     rV.push_back(StackSymbolIndex(ssit->Symbol()));
01051   }
01052   return rV;
01053 }
01054 
01055 TEMP Idx THIS::TransRelSize() const{
01056   
01057   TransSet::Iterator transit;
01058   Idx s = 0;
01059   for(transit = BASE::TransRelBegin(); transit != BASE::TransRelEnd(); transit++){
01060     s += PopPush(*transit).size();
01061   }
01062   return s;
01063 }
01064 
01065 // SetTransition(rX1, rEv, rX2)
01066 TEMP bool THIS::SetTransition(const std::string& rX1, const std::string& rEv, const std::string& rX2) {
01067   return BASE::SetTransition(rX1,rEv,rX2);
01068 }
01069 
01070 
01071 // SetTransition(x1, ev, x2)
01072 TEMP bool THIS::SetTransition(Idx x1, Idx ev, Idx x2) {
01073   return BASE::SetTransition(Transition(x1,ev,x2));
01074 }
01075 
01076 // SetTransition(rTransition, rAttr)
01077 TEMP bool THIS::SetTransition(const Transition& rTransition, const TransAttr& rAttr) {
01078   return BASE::SetTransition(rTransition,rAttr);
01079 }
01080 
01081 // SetTransition(trans,....)
01082 
01083 TEMP bool THIS::SetTransition(const Transition& rTrans,
01084     const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush) {
01085 //   FD_DG("PushdownGenerator(" << this << ")::SetTransition(" << (BASE::TStr(rTrans)) <<", " <<
01086 //     ", PopVector" << ", " << "PushVector" << ") const");
01087 // #ifdef FAUDES_CHECKED
01088 //   EmptyVectorPopPush(rPop);
01089 //   EmptyVectorPopPush(rPush);
01090 // #endif
01091 //   BASE::SetTransition(rTrans);
01092 //   //get the transition attribute or take new one if it does not exist
01093 //   TransAttr attr;
01094 //   if(BASE::TransAttributep(rTrans) != 0){
01095 //     attr = *BASE::TransAttributep(rTrans);
01096 //   }
01097 //   std::pair<std::vector<Idx>, std::vector<Idx> > popPushPair;
01098 //   popPushPair.first = StackSymbolsToIndices(rPop);
01099 //   popPushPair.second = StackSymbolsToIndices(rPush);
01100 //   //add new PopPushPair
01101 //   attr.mPopPush.insert(popPushPair);
01102 // #ifdef FAUDES_CHECKED
01103 //   ConsistentVectorStackSymbol(rPop);
01104 //   ConsistentVectorStackSymbol(rPush);
01105 // #endif
01106 //   return BASE::SetTransition(rTrans,attr);
01107   return SetTransition(rTrans, StackSymbolsToIndices(rPop), StackSymbolsToIndices(rPush));
01108 }
01109 
01110 TEMP bool THIS::SetTransition(const Transition& rTrans,
01111     const std::vector<Idx>& rPop, const std::vector<Idx>& rPush) {
01112   FD_DG("PushdownGenerator(" << this << ")::SetTransition(" << (BASE::TStr(rTrans)) <<", " <<
01113     ", PopVector" << ", " << "PushVector" << ") const");
01114 #ifdef FAUDES_CHECKED
01115   EmptyVectorPopPush(rPop);
01116   EmptyVectorPopPush(rPush);
01117 #endif
01118   BASE::SetTransition(rTrans);
01119   //get the transition attribute or take new one if it does not exist
01120   TransAttr attr;
01121   if(BASE::TransAttributep(rTrans) != 0){
01122     attr = *BASE::TransAttributep(rTrans);
01123   }
01124   std::pair<std::vector<Idx>, std::vector<Idx> > popPushPair;
01125   popPushPair.first = rPop;
01126   popPushPair.second = rPush;
01127   //add new PopPushPair
01128   attr.mPopPush.insert(popPushPair);
01129 #ifdef FAUDES_CHECKED
01130   ConsistentVectorStackSymbol(rPop);
01131   ConsistentVectorStackSymbol(rPush);
01132 #endif
01133   return BASE::SetTransition(rTrans,attr);
01134 }
01135 
01136 // SetTransition(x1,ev,x2, ...)
01137 TEMP bool THIS::SetTransition(Idx x1, Idx ev, Idx x2,
01138     const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush) {
01139   return SetTransition(Transition(x1,ev,x2),rPop,rPush);
01140 }
01141 
01142 // SetTransition(x1,ev,x2, ...)
01143 TEMP bool THIS::SetTransition(Idx x1, Idx ev, Idx x2,
01144     const std::vector<Idx>& rPop, const std::vector<Idx>& rPush) {
01145   return SetTransition(Transition(x1,ev,x2),rPop,rPush);
01146 }
01147 
01148 // SetTransition(X1,Ev,X2, ...)
01149 TEMP bool THIS::SetTransition(
01150     const std::string& rX1, const std::string& rEv, const std::string& rX2,
01151     const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush) {
01152     FD_DG("PushdownGenerator(" << this << ")::SetTransition(" << rX1 << " " << rEv <<" " << rX2 <<
01153       ", PopVector" << ", " << "PushVector" << ") const");
01154   //try to add transition, will do nothing if transition exists
01155   bool res=BASE::SetTransition(rX1,rEv,rX2);
01156   //get transition via iterator
01157   Transition rTrans = *(BASE::FindTransition(rX1,rEv,rX2));
01158 #ifdef FAUDES_CHECKED
01159   EmptyVectorPopPush(rPop);
01160   EmptyVectorPopPush(rPush);
01161 #endif
01162   //get the transition attribute or take new one if it does not exist
01163   TransAttr attr;
01164   if(BASE::TransAttributep(rTrans) != 0){
01165     attr = *BASE::TransAttributep(rTrans);
01166   }
01167   std::pair<std::vector<Idx>, std::vector<Idx> > popPushPair;
01168   popPushPair.first = StackSymbolsToIndices(rPop);
01169   popPushPair.second = StackSymbolsToIndices(rPush);
01170   //add new PopPushPair
01171   attr.mPopPush.insert(popPushPair);
01172 #ifdef FAUDES_CHECKED
01173   ConsistentVectorStackSymbol(rPop);
01174   ConsistentVectorStackSymbol(rPush);
01175 #endif
01176   BASE::TransAttribute(Transition(BASE::StateIndex(rX1),BASE::EventIndex(rEv),BASE::StateIndex(rX2)),attr);
01177   return res;
01178 }
01179 
01180 // SetTransition(X1,Ev,X2, ...)
01181 TEMP bool THIS::SetTransition(
01182     const std::string& rX1, const std::string& rEv, const std::string& rX2,
01183     const std::vector<Idx>& rPop, const std::vector<Idx>& rPush) {
01184   
01185   Transition(BASE::StateIndex(rX1),BASE::EventIndex(rEv),BASE::StateIndex(rX2));
01186   return SetTransition(Transition(BASE::StateIndex(rX1),BASE::EventIndex(rEv),BASE::StateIndex(rX2)),rPop,rPush);
01187 }
01188 
01189 //clearTransition(x1,ev,x2,rPop,rPush)
01190 TEMP bool THIS::ClrTransition(Idx x1, Idx ev, Idx x2,
01191     const std::vector<StackSymbol>& rPop, const std::vector<StackSymbol>& rPush){
01192   return ClrTransition(Transition(x1,ev,x2),rPop,rPush);
01193 }
01194 
01195 //clearTransition(x1,ev,x2,rPop,rPush)
01196 TEMP bool THIS::ClrTransition(Idx x1, Idx ev, Idx x2,
01197     const std::vector<Idx>& rPop, const std::vector<Idx>& rPush){
01198   return ClrTransition(Transition(x1,ev,x2),rPop,rPush);
01199 }
01200 
01201 //clearTransition(rTrans,rPop,rPush)
01202 TEMP bool THIS::ClrTransition(const Transition& rTrans, const std::vector<StackSymbol>& rPop,const std::vector<StackSymbol>& rPush){
01203   
01204 //  //check for existence of base transition
01205 //   if(!BASE::ExistsTransition(rTrans)){
01206 //     return false;
01207 //   }
01208 //   
01209 //   //delete pop/push pair in said transition
01210 //   if(!BASE::pTransRel->Attributep(rTrans)->ClrPopPush(StackSymbolsToIndices(rPop),StackSymbolsToIndices(rPush))){
01211 //     return false;
01212 //   }
01213 //   
01214 //   //delete transition if popPush is empty
01215 //   if(PopPush(rTrans).empty()){
01216 //     BASE::ClrTransition(rTrans);
01217 //   }
01218 //   return true;
01219   return ClrTransition(rTrans,StackSymbolsToIndices(rPop),StackSymbolsToIndices(rPush));
01220 }
01221 
01222 //clearTransition(rTrans,rPop,rPush)
01223 TEMP bool THIS::ClrTransition(const Transition& rTrans, const std::vector<Idx>& rPop,const std::vector<Idx>& rPush){
01224   
01225   //check for existence of base transition
01226   if(!BASE::ExistsTransition(rTrans)){
01227     return false;
01228   }
01229   
01230   //delete pop/push pair in said transition
01231   if(!BASE::pTransRel->Attributep(rTrans)->ClrPopPush(rPop, rPush)){
01232     return false;
01233   }
01234   
01235   //delete transition if popPush is empty
01236   if(PopPush(rTrans).empty()){
01237     BASE::ClrTransition(rTrans);
01238   }
01239   return true;
01240 }
01241 
01242 //PopPush(trans)
01243 TEMP const PopPushSet& THIS::PopPush(const Transition& rTrans) const{
01244 #ifdef FAUDES_CHECKED
01245   if(!BASE::ExistsTransition(rTrans)) {
01246       std::stringstream errstr;
01247       errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
01248       throw Exception("PushdownGenerator::PopPush(trans)", errstr.str(), 200);
01249   }
01250 #endif
01251   return BASE::pTransRel->Attribute(rTrans).PopPush();
01252 }
01253 
01254 //PopPushBegin(trans)
01255 TEMP PopPushSet::const_iterator THIS::PopPushBegin(const Transition& rTrans) const {
01256   return BASE::pTransRel->Attribute(rTrans).PopPush().begin();
01257 }
01258 
01259 //PopPushEnd(trans)
01260 TEMP PopPushSet::const_iterator THIS::PopPushEnd(const Transition& rTrans) const {
01261   return BASE::pTransRel->Attribute(rTrans).PopPush().end();
01262 }
01263 
01264 //IsStackSymbolLambda(index)
01265 TEMP bool THIS::IsStackSymbolLambda(Idx index) const{
01266   if(StackSymbolName(index).compare(FAUDES_PD_LAMBDA) == 0)
01267     return true;
01268   else
01269     return false;
01270 }
01271 
01272 //IsEventLambda(index)
01273 TEMP bool THIS::IsEventLambda(Idx index) const{
01274   if(BASE::EventName(index).compare(FAUDES_PD_LAMBDA) == 0)
01275     return true;
01276   else
01277     return false;
01278 }
01279 
01280 
01281 // ConsistentStackSymbol(rStackSymbol)
01282 TEMP void THIS::ConsistentStackSymbol(const StackSymbol& rStackSymbol) const {
01283   FD_DG("PushdownGenerator(" << this << ")::ConsistentStackSymbol(rStackSymbol)");
01284   if(!StackSymbols().Exists(rStackSymbol.Symbol())) {
01285     std::stringstream errstr;
01286     errstr << "stack symbol table mismatch (symbol " << rStackSymbol.mSymbol << " does not exist)" << std::endl;
01287     throw Exception("PushdownGenerator::ConsistentStackSymbol", errstr.str(), 1001);
01288   }
01289   FD_DG("PushdownGenerator(" << this << ")::ConsistentStackSymbol(rStackSymbol): ok");
01290 }
01291 
01292 // ConsistentStackSymbol(Idx)
01293 TEMP void THIS::ConsistentStackSymbol(Idx idx) const {
01294   FD_DG("PushdownGenerator(" << this << ")::ConsistentStackSymbol(idx)");
01295   if(!StackSymbols().Exists(idx)) {
01296     std::stringstream errstr;
01297     errstr << "stack symbol table mismatch (symbol with idx " << idx << " does not exist)" << std::endl;
01298     throw Exception("PushdownGenerator::ConsistentStackSymbol", errstr.str(), 1001);
01299   }
01300   FD_DG("PushdownGenerator(" << this << ")::ConsistentStackSymbol(idx): ok");
01301 }
01302 
01303 // ConsistentVectorStackSymbol(vector)
01304 TEMP void THIS::ConsistentVectorStackSymbol(const std::vector<StackSymbol>& rVector) const {
01305   FD_DG("PushdownGenerator(" << this << ")::ConsistentVectorStackSymbol(rVector)");
01306   std::vector<StackSymbol>::const_iterator it;
01307   it = rVector.begin();
01308   for ( ; it < rVector.end(); it++){
01309     if(!StackSymbols().Exists(it->Symbol())) {
01310       std::stringstream errstr;
01311       errstr << "stack symbol table mismatch (symbol " << it->mSymbol << " does not exist)" <<std::endl;
01312       throw Exception("PushdownGenerator::ConsistentVectorStackSymbol", errstr.str(), 1001);
01313     }
01314   }
01315   FD_DG("PushdownGenerator(" << this << ")::ConsistentVectorStackSymbol(rVector): ok");
01316 }
01317 
01318 // ConsistentVectorStackSymbol(vector)
01319 TEMP void THIS::ConsistentVectorStackSymbol(const std::vector<Idx>& rVector) const {
01320   FD_DG("PushdownGenerator(" << this << ")::ConsistentVectorStackSymbol(rVector)");
01321   std::vector<Idx>::const_iterator it;
01322   it = rVector.begin();
01323   for ( ; it < rVector.end(); it++){
01324     if(!StackSymbols().Exists(*it)) {
01325       std::stringstream errstr;
01326       errstr << "stack symbol table mismatch (symbol with index " << *it << " does not exist)" <<std::endl;
01327       throw Exception("PushdownGenerator::ConsistentVectorStackSymbol", errstr.str(), 1001);
01328     }
01329   }
01330   FD_DG("PushdownGenerator(" << this << ")::ConsistentVectorStackSymbol(rVector): ok");
01331 }
01332 
01333 // EmptyVector(vector)
01334 TEMP void THIS::EmptyVectorPopPush(const std::vector<StackSymbol>& rVector) const {
01335   FD_DG("PushdownGenerator(" << this << ")::EmptyVector(rVector)");
01336   if(rVector.empty()) {
01337     std::stringstream errstr;
01338     errstr << "empty vector not allowed in pop or push" <<std::endl;
01339     throw Exception("PushdownGenerator::EmptyVector", errstr.str(), 1001);
01340   }
01341   FD_DG("PushdownGenerator(" << this << ")::EmptyVectorPopPush(rVector): ok");
01342 }
01343 
01344 // EmptyVector(vector)
01345 TEMP void THIS::EmptyVectorPopPush(const std::vector<Idx>& rVector) const {
01346   FD_DG("PushdownGenerator(" << this << ")::EmptyVector(rVector)");
01347   if(rVector.empty()) {
01348     std::stringstream errstr;
01349     errstr << "empty vector not allowed in pop or push" <<std::endl;
01350     throw Exception("PushdownGenerator::EmptyVector", errstr.str(), 1001);
01351   }
01352   FD_DG("PushdownGenerator(" << this << ")::EmptyVectorPopPush(rVector): ok");
01353 }
01354 
01355 
01356 //SetMerge(stateName,rMerge)
01357 TEMP void THIS::SetMerge(const std::string& stateName, MergeAbstract& rMerge){
01358   Idx index=BASE::StateIndex(stateName);
01359   BASE::pStates->Attributep(index)->SetMerge(rMerge);
01360 }
01361 
01362 //SetMerge(index,rMerge)
01363 TEMP void THIS::SetMerge(Idx index, MergeAbstract& rMerge){
01364   BASE::pStates->Attributep(index)->SetMerge(rMerge);
01365 }
01366 
01367 //Merge(index)
01368 TEMP const MergeAbstract* THIS::Merge(Idx index) const{
01369   return BASE::pStates->Attributep(index)->Merge();
01370 }
01371 
01372 //SetDfaState(stateName, dpaIndex)
01373 TEMP void THIS::SetDfaState(const std::string& stateName, Idx dfaIndex){
01374   Idx index=BASE::StateIndex(stateName);
01375   BASE::pStates->Attributep(index)->DfaState(dfaIndex);
01376 }
01377 
01378 //SetDfaState(index, dpaIndex)
01379 TEMP void THIS::SetDfaState(Idx index, Idx dfaIndex){
01380   BASE::pStates->Attributep(index)->DfaState(dfaIndex);
01381 }
01382 
01383 //DfaState(index)
01384 TEMP Idx THIS::DfaState(Idx index) const{
01385   return BASE::pStates->Attributep(index)->DfaState();
01386 }
01387 
01388 // Valid() TODO checks?
01389 TEMP bool THIS::Valid(void) {
01390     FD_DV("PushdownGenerator(" << this << ")::Valid()");
01391     //call base
01392     if(!BASE::Valid()) return false;
01393     // check my names
01394    
01395     // check my clockset
01396     
01397     // check all clocksymboltables
01398     
01399     return true;
01400 }
01401   
01402 
01403 // clean up defs (tmoor)
01404 #undef THIS 
01405 #undef BASE 
01406 #undef TEMP 
01407 
01408 
01409   
01410 } // namespace faudes
01411 
01412 
01413 #endif
01414 

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