libFAUDES

Sections

Index

vgenerator.h

Go to the documentation of this file.
00001 /** @file vgenerator.h Class vGenerator */
00002 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005 Copyright (C) 2006  Bernd Opitz
00006 Copyright (C) 2007  Thomas Moor
00007 Exclusive copyright is granted to Klaus Schmidt
00008 
00009 This library is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU Lesser General Public
00011 License as published by the Free Software Foundation; either
00012 version 2.1 of the License, or (at your option) any later version.
00013 
00014 This library is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE.  See the GNU
00017 Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public
00020 License along with this library; if not, write to the Free Software
00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00022 
00023 
00024 #ifndef FAUDES_VGENERATOR_H
00025 #define FAUDES_VGENERATOR_H
00026 
00027 #include "definitions.h"
00028 #include "exception.h"
00029 #include "rtitypes.h"
00030 #include "symboltable.h"
00031 #include "indexset.h"
00032 #include "nameset.h"
00033 #include "transset.h"
00034 #include "token.h"
00035 #include "tokenreader.h"
00036 #include "tokenwriter.h"
00037 
00038 #include <map>
00039 #include <set>
00040 #include <sstream>
00041 #include <cstdlib>
00042 #include <cassert>
00043 
00044 namespace faudes {
00045 
00046 /**
00047  * Base class of all FAUDES generators.
00048  * 
00049  * \section GeneratorMembers Overview
00050  *
00051  * The faudes::Generator models the plain five-tupel G = (X, Sigma, Delta, X_0, X_m) to represent
00052  * the marked language L(G) and closed language L_m(G), respectively. It provides read and write
00053  * access to core menbers, e.g. methods for inserting/deleting events, states 
00054  * and transitions. 
00055  *
00056  *
00057  * States, events and transitions in a generator can be addressed in three alternative methods:
00058  *
00059  * - by index, involves a search on a sorted set (efficient)
00060  * - by name, involves two searches on sorted sets (not quite so efficient)
00061  * - by iterator, involves pointer dereferencing  (very efficient)
00062  *
00063  * For read access, const refererences to sets are provided. In order to allow for consistency checks,
00064  * write access is via generator methods only. When the compiletime option FAUDES_CHECKED is 
00065  * defined, write methods throw an exception on inconsistent data, eg. setting an initial state
00066  * that is not an element of the state set, or introducing a transition with an event label that
00067  * is not in the alphabet. 
00068  *
00069  *
00070  * \section SecEventsVersusStates Events Versus States
00071  *
00072  * While both events and states are represented by the integer type faudes::Idx, there
00073  * is a fundamental distinction between both, that stems our choice to use the generator
00074  * as a tool to represent a formal language. From this perspective, events are global enteties while states
00075  * are local to the respective generator. Any two events are related while states only 
00076  * compare within a generator. 
00077  *
00078  * In consequence of the different role of events and states, there is one global
00079  * sybmoltable that provides event name resolution, while there is a local state symbol table for 
00080  * each generator. Furthermore, state names are considered cosmetic and hence are optional, while
00081  * event names are mandatory. 
00082  *
00083  * Example: two machines both refer to the event name "alpha" that models the process of passing 
00084  * a workpiece from one machine to the other. In libFAUDES this is indeed modelled as one event 
00085  * which is represented by one index. However, both machines may have a state "Idle" which indicates
00086  * that the respective machine is idle. In libFAUDES the two states are treated locally to the
00087  * generators and whether or not they have the same index is regarded irrelevant.
00088  * 
00089  * The generator class carries a flag to indicate that functions with result type
00090  * generator shall attach names to the newly created states, perhaps based on the state names
00091  * of the respective arguments. Turning of this feature and avoiding state names alltogether
00092  * considerably increases libFAUDES performance.
00093  *
00094  * \section GeneratorFileFormat File IO
00095  *
00096  * Generators inherit the standard token IO interface from the libFAUDES general purpose base Type, 
00097  * so you may use Read and Write functions for generators. The file-format consists of a generator section that includes
00098  * one subsection for each core member. It is illustrated by the below example
00099  * 
00100  * @code
00101  * <Generator>
00102  * % libFAUDES Generator for the simple machine
00103  * "simple machine"                   
00104  *
00105  * <Alphabet>                         
00106  * "alpha" "beta" "mue" "lambda"      
00107  * </Alphabet>
00108  *
00109  * <States>                           
00110  * "idle" "busy" "down"
00111  * </States>
00112  *
00113  * <TransRel>
00114  * "idle" "alpha" "busy"
00115  * "busy" "beta" "idle"
00116  * "busy" "mue" "down"
00117  * "down" "lambda" "idle"
00118  * </TransRel>
00119  * 
00120  * <InitStates>
00121  * "idle"
00122  * </InitStates>
00123  * 
00124  * <MarkedStates>
00125  * "idle"
00126  * </MarkedStates>
00127  * </Generator>
00128  * @endcode
00129  *
00130  * Note that for file IO states may be represented either ba symbolic name or index.
00131  * However, when writing a file indices will be chosen consecutively and beginning at 1.
00132  * Thus, state indices are not maintained by file IO. Events are always represented by their 
00133  * symbolic name.
00134  *
00135  * \section GeneratorAttributes Attributes
00136  *
00137  * libFAUDES generators provide an interface to access so called attributes, ie data that 
00138  * is optionally attached to individual states, events, transitions, or globally to the generator.
00139  *
00140  * The faudes::Generator's interface to attributes is abstract in the sense that a generator 
00141  * is not aware of the actual type of its attributes. 
00142  * Instances of the class Generator indeed have trivial attributes that hold no data at all. 
00143  * To use attributes, you are meant to instantiate objects of the derived class TaGenerator 
00144  * with template parameters to specify attribute types. Basic algorithms 
00145  * implemented for plain generators will accept attributed generators as arguments. Such algorithms may 
00146  * occasionally inspect or set attributes using the abstract interface and C++ dynamic casts. For
00147  * specialised algorithms that refer to extended generator semantics, we recommend derived 
00148  * generator classes as argument type.
00149  *
00150  *
00151  * @ingroup GeneratorClasses
00152  */
00153 
00154 
00155 class vGenerator : public Type  {
00156 
00157  public:
00158     
00159   /** @name Constructors & Destructor */
00160   /** @{ doxygen group */
00161 
00162   /**
00163    * Default constructor
00164    */
00165   vGenerator(void);
00166 
00167   /**
00168    * Copy-constructror
00169    */
00170   vGenerator(const vGenerator& rOtherGen);
00171 
00172   /**
00173    * Construct from file. This constructor
00174    * effectively uses the DoRead(TokenReader&) function to read.
00175    *
00176    * @param rFileName
00177    *   Name of file
00178    *
00179    * @exception Exception
00180    *   - IO errors (id 1)
00181    *   - Token mismatch (id 50, 51, 52, 80, 85)
00182    */
00183   vGenerator(const std::string& rFileName);
00184 
00185   /**
00186    * Construct on heap. 
00187    * Technically not a constructor, this function creates a vGenerator with the
00188    * same event symboltable. It is the callers reponsebilty to delete the object 
00189    * when no longer needed. Derived classes must reimplement
00190    * this function to create an object of the same class and the same event 
00191    * symboltable. The StateNamesEnabled indicator should be copied, too.
00192    *
00193    * @return 
00194    *   New vGenerator 
00195    */
00196   virtual vGenerator* New(void) const;
00197 
00198   /**
00199    * Construct copy on heap. 
00200    * Technically not a constructor, this function creates a vGenerator with the
00201    * same event symboltable. It is the callers reponsebilty to delete the object 
00202    * when no longer needed. Derived classes must reimplement
00203    * this function to create an object of the same class and the same event 
00204    * symboltable. The StateNamesEnabled indicator should be copied, too.
00205    *
00206    * @return 
00207    *   New vGenerator 
00208    */
00209   virtual vGenerator* Copy(void) const;
00210 
00211   /**
00212    * Destructor 
00213    */
00214   virtual ~vGenerator(void);
00215 
00216   /** @} doxygen group */
00217 
00218   /*****************************************
00219    *****************************************
00220    *****************************************
00221    *****************************************/
00222 
00223   /** @name Copy and Assignment */
00224   /** @{ doxygen group */
00225 
00226 
00227   /**
00228    * Copy from other vGenerator. 
00229    * The current implementation copies the generator only.
00230    * Future versions may try to be smart and copy attributes
00231    * if types can be casted. Use CopyWithoutAttributes to 
00232    * explicitely ignore attributes.
00233    *
00234    * @param rGen
00235    *   Source to copy from.
00236    */
00237   virtual vGenerator& Assign(const vGenerator& rGen); 
00238 
00239   /**
00240    * Copy from other vGenerator, ignore attributes. 
00241    *
00242    * @param rGen
00243    *   Source to copy from.
00244    */
00245   virtual vGenerator& AssignWithoutAttributes(const vGenerator& rGen); 
00246 
00247   /**
00248    * Destructive copy to other vGenerator. 
00249    * Copy method with increased performance at the cost of invalidating
00250    * the source data. If attribute types of source and destination differ,
00251    * a std copy is invoked.
00252    * 
00253    *
00254    * @param rGen
00255    *   Destination for copy operation.
00256    */
00257   virtual void Move(vGenerator& rGen); 
00258 
00259   /**
00260    * Assignment operator (uses Copy method)
00261    * Note: you must reimplement this operator in derived 
00262    * classes in order to handle internal pointers correctly.
00263    *
00264    * @param rOtherGen
00265    *   Other generator
00266    */
00267   virtual vGenerator& operator= (const vGenerator& rOtherGen);
00268 
00269   /**
00270    * Create another version of this generator.
00271    * Assembles a copy of this generator, however, with versioned events.
00272    * The new event names are created by appending an underscore and a specified string.
00273    * State names and indices as well as any attributes are maintained.
00274    *
00275    * @param rVersion
00276    *   String value to be appended to event names
00277    * @param rResGen
00278    *   Resulting versioned generator
00279    *
00280    * @exception Exception
00281    *   - Source must not match destination (id 96)
00282    */
00283   virtual void Version(const std::string& rVersion, vGenerator& rResGen) const;
00284 
00285   /**
00286    * Create another version of this generator.
00287    * Assembles a copy of this generator, however, with versioned events.
00288    * The new event names are created by appending an underscore and a numeric index.
00289    * State names and indices as well as any attributes are maintained.
00290    *
00291    * @param version
00292    *   Numeric value to be appended to event names
00293    * @param rResGen
00294    *   Resulting versioned generator
00295    * @exception Exception
00296    *   - Source must not match destination (id 96)
00297    */
00298   virtual void Version(Idx version, vGenerator& rResGen) const;
00299 
00300   /**
00301    * Create another version of this generator.
00302    * Assembles a copy of this generator, however, with versioned events.
00303    * The new event names are created by replacing all substrings matching
00304    * a specified string pattern by a replacement string.
00305    * State names and indices as well as any attributes are maintained.
00306    *
00307    * @param rPattern
00308    *   String value to be replaced in event names
00309    * @param rReplacement
00310    *   String value to be inserted in event names in place of rPattern
00311    * @param rResGen
00312    *   Resulting versioned generator
00313    * @exception Exception
00314    *   - Source must not match destination (id 96)
00315    */
00316   virtual void Version(const std::string& rPattern,const std::string& rReplacement, vGenerator& rResGen) const;
00317 
00318 
00319 
00320   /** @} doxygen group */
00321 
00322 
00323   /*****************************************
00324    *****************************************
00325    *****************************************
00326    *****************************************/
00327 
00328   /** @name Basic Maintenance */
00329   /** @{ doxygen group */
00330 
00331 
00332   /** 
00333    * Set the generator's name 
00334    *
00335    * @param rName
00336    *   Generator name
00337    */
00338   void Name(const std::string& rName);
00339 
00340   /** 
00341    * Get generator's name 
00342    *
00343    * @return 
00344    *   Name of generator
00345    */
00346   const std::string& Name(void) const;
00347 
00348  /** 
00349    * Check if generator is valid. 
00350    * Performs internal consistency tests, This method is intendend
00351    * to test generators that have been manipulated by methods without
00352    * consistency tests, eg InjectAlphabet.
00353    *
00354    * @return 
00355    *   True for success
00356    */
00357   virtual bool Valid(void);
00358 
00359   /**
00360    * Clear generator data. 
00361    * Clears state set, alphabet and transitionrealtion. Behavioural flags
00362    * eg StateNamesEnabled are maintained.
00363    */
00364   virtual void Clear(void);
00365 
00366 
00367   /**
00368    * Clear all states and transitions, maintain alphabet.
00369    */
00370   void ClearStates(void);
00371 
00372   /**
00373    * Get number of events in alphabet
00374    *
00375    * @return
00376    *   Number of events
00377    */
00378   Idx AlphabetSize(void) const;
00379 
00380   /** 
00381    * Get generator size (number of states) 
00382    * 
00383    * @return 
00384    *   Number of states
00385    */
00386   Idx Size(void) const;
00387 
00388   /**
00389    * Get number of transitions
00390    *
00391    * @return
00392    *   Number of transitions
00393    */
00394   Idx TransRelSize(void) const;
00395 
00396   /**
00397    * Get number of initial states
00398    *
00399    * @return
00400    *   Number of initial states
00401    */
00402   Idx InitStatesSize(void) const;
00403 
00404   /**
00405    * Get number of marked states
00406    *
00407    * @return
00408    *   Number of marked states
00409    */
00410   Idx MarkedStatesSize(void) const;
00411 
00412   /** 
00413    * Check if generator is empty (no states)
00414    *
00415    * @return 
00416    *   True if state set is empty
00417    */
00418   bool Empty(void) const;
00419 
00420   /**
00421    * Check if alphabet is Empty
00422    *
00423    * @return
00424    *   True if mpAlphabet is empty
00425    */
00426   bool AlphabetEmpty(void) const;
00427 
00428   /**
00429    * Check if transition relation is empty
00430    *
00431    * @return
00432    *   True if transition relation is empty
00433    */
00434   bool TransRelEmpty(void) const;
00435 
00436   /**
00437    * Check if set of initial states are empty
00438    *
00439    * @return
00440    *   True if mInitStates is empty
00441    */
00442   bool InitStatesEmpty(void) const;
00443 
00444   /**
00445    * Check if set of marked states are empty
00446    *
00447    * @return
00448    *   True if mMarkedStates is empty
00449    */
00450   bool MarkedStatesEmpty(void) const;
00451 
00452 
00453   /** @} doxygen group */
00454 
00455   /*****************************************
00456    *****************************************
00457    *****************************************
00458    *****************************************/
00459 
00460   /** @name Event Symboltable */
00461   /** @{ doxygen group */
00462 
00463   /**
00464    * Get Pointer to EventSymbolTable currently used
00465    * by this vGenerator. 
00466    *
00467    * @return
00468    *   Pointer to EventSymbolTable
00469    */
00470   SymbolTable* EventSymbolTablep(void) const;
00471 
00472   /**
00473    * Set EventSymbolTable to be used by this vGenerator. 
00474    * This function sets the reference to the event symboltable. The current implementation
00475    * in derived classes clears the generator, future versions may implement a re-indexing.
00476    *
00477    * @param pSymTab
00478    *   Pointer to SymbolTable
00479    */
00480   virtual void EventSymbolTablep(SymbolTable* pSymTab);
00481 
00482   /**
00483    * Set EventSymbolTable as given by rOtherGen. 
00484    * This function sets the reference to the event symboltable. The current implementation
00485    * clears the generator, future versions may implement a re-indexing.
00486    *
00487    * @param rOtherGen
00488    *   Other generator 
00489    *   
00490    */
00491   virtual void EventSymbolTablep(const vGenerator& rOtherGen);
00492 
00493   /**
00494    * Create EventSet with generator's EventSymbolTable (on stack).
00495    *
00496    * @return
00497    *   New empty EventSet on stack
00498    */
00499   EventSet NewEventSet(void) const;
00500 
00501   /**
00502    * Create EventSet with generator's EventSymbolTable (on heap). 
00503    *
00504    * @return
00505    *   Pointer to new empty EventSet on heap
00506    */
00507   EventSet* NewEventSetp(void) const;
00508 
00509   /**
00510    * Event index lookup 
00511    * 
00512    * @param rName
00513    *    Name of event to lookup
00514    *
00515    * @return 
00516    *   Valid index or 0 if name unknown to symboltable
00517    */
00518   Idx EventIndex(const std::string& rName) const;
00519 
00520   /** 
00521    * Event name lookup 
00522    *
00523    * @param index
00524    *   Index of event to look up
00525    *
00526    * @return 
00527    *   Name or empty std::string if non-existent
00528    */
00529   std::string EventName(Idx index) const;
00530 
00531   /**
00532    * Set name for existing event
00533    *
00534    * @param index
00535    *   Event index
00536    * @param rName
00537    *   New name
00538    *
00539    * @exception Exception
00540    *   - index not found in EventSymbolMap (id 42)
00541    *   - name already associated with another index (id 44)
00542    *   - event does not exist in generator (id 89)
00543    */
00544   void EventName(Idx index, const std::string& rName);
00545 
00546   /** 
00547    * Create a new unique symbolic event name.
00548    * See also SymbolTable::UniqueSymbol().
00549    *
00550    * @param rName
00551    *   suggestion for new state name
00552    */
00553   std::string UniqueEventName(const std::string& rName) const;
00554 
00555 
00556   /** 
00557    * Rename event in this generator.
00558    * This method renames the specified event. It does so by
00559    * removing and adding transitions. This does not
00560    * effect other generators. 
00561    *
00562    * @param event
00563    *   Event to rename
00564    * @param rNewName
00565    *   New name
00566    * @return
00567    *   True, if the new name did already exist
00568    */
00569   bool EventRename(Idx event, const std::string& rNewName);
00570 
00571 
00572   /** @} doxygen group */
00573 
00574   /* statics outside doxygen group */
00575 
00576   /**
00577    * Get Pointer to global EventSymbolTable. This is
00578    * a static member of SymbolTable and used as default
00579    * for all derived generator classes and instantiated objects.
00580    *
00581    * @return
00582    *   Pointer to global EventSymbolTable
00583    */
00584   static SymbolTable* GlobalEventSymbolTablep(void);
00585 
00586 
00587   /*****************************************
00588    *****************************************
00589    *****************************************
00590    *****************************************/
00591 
00592   /** @name State Symboltable */
00593   /** @{ doxygen group */
00594 
00595 
00596   /**
00597    * Get StateSymbolTable. 
00598    *
00599    * @return
00600    *   ref to state-symboltable
00601    */
00602   const SymbolTable& StateSymbolTable(void) const;
00603 
00604   /**
00605    * Set StateSymbolTable.
00606    *
00607    * By convention, state names and indices are local to the
00608    * respective generator. It is most unlikely that you want to use
00609    * this function.
00610    *
00611    * @return
00612    *   Pointer to mpStateSymbolTable
00613    */
00614   void StateSymbolTable(const SymbolTable& rSymTab);
00615 
00616   /**
00617    * State index lookup. 
00618    *
00619    * @param rName
00620    *
00621    * @return
00622    *  Valid index (or 0 for non-existent)
00623    */
00624   Idx StateIndex(const std::string& rName) const;
00625 
00626   /** 
00627    * State name lookup 
00628    *
00629    * @param index
00630    *
00631    * @return name (or empty string if no such exists) 
00632    */
00633   std::string StateName(Idx index) const;
00634 
00635   /** 
00636    * Set name of state
00637    *
00638    * @param index
00639    *   Index
00640    * @param rName
00641    *   Name
00642    *
00643    * @exception Exception
00644    *   - name already associated with another index (id 44)
00645    *   - state does not exist in generator (id 90)
00646    */
00647   void StateName(Idx index, const std::string& rName);
00648 
00649   /**
00650    * Remove all names from generator's StateSymbolTable
00651    */
00652   void ClearStateNames(void);
00653 
00654   /**
00655    * Clear name for individual state
00656    *
00657    * @param index
00658    *   State index
00659    * @exception Exception
00660    *   - state does not exist in generator (id 90)
00661    */
00662   void ClrStateName(Idx index);
00663 
00664   /**
00665    * Clear name for individual  state
00666    *
00667    * @param rName
00668    *   State name
00669    */
00670   void ClrStateName(const std::string& rName);
00671 
00672   /**
00673    * Whether libFAUEDS functions are requested to generate state names.
00674    * Most libFAUDES functions introduce new states to a generator can be enabled
00675    * to also assign (more or less sensible) names to those states. This feature is
00676    * purely cosmetic and may be disabled for performance reasons. 
00677    * 
00678    *
00679    * @return
00680    *   False if ClrStateNames() was called
00681    */
00682   bool StateNamesEnabled(void) const;
00683 
00684   /**
00685    * Enable/disable libFAUEDS functions to automatically generate state names.
00686    *
00687    * @param flag
00688    *   True enables statenames / false disables them
00689    */
00690   void StateNamesEnabled(bool flag);
00691 
00692   /**
00693    * Assign each state a default name bysed on its index.
00694    */
00695   void SetDefaultStateNames(void);
00696 
00697   /**
00698    * For all states without a symbolic name, assign a name 
00699    * based on suggested template and the index
00700    *
00701    * @param rTemplate
00702    *   basis for name generation
00703    */
00704   void EnforceStateNames(const std::string& rTemplate);
00705 
00706   /** 
00707    * Create a new unique symbolic state name.
00708    * See also SymbolTable::UniqueSymbol().
00709    *
00710    * @param rName
00711    *   suggestion for new state name
00712    */
00713   std::string UniqueStateName(const std::string& rName) const;
00714 
00715 
00716   /** @} doxygen group */
00717 
00718   /* statics outside doxygen group */
00719 
00720   /**
00721    * Sets the default for automatic state name generation.
00722    * This flag takes effect only on generators newly created by the default
00723    * constructor. The copy constructor copies the state name flag from the 
00724    * source generator. See also StateNamesEnabled(bool).
00725    *
00726    * @param flag
00727    *   True enables statenames / false disables them
00728    */
00729   static void StateNamesEnabledDefault(bool flag);
00730 
00731 
00732   /*****************************************
00733    *****************************************
00734    *****************************************
00735    *****************************************
00736    *****************************************/
00737 
00738   /** @name Read Access to Core Members */
00739   /** @{ doxygen group */
00740 
00741   /**
00742    * Iterator to Begin() of alphabet
00743    *
00744    * @return
00745    *   Iterator to begin of mpAlphabet
00746    */
00747   EventSet::Iterator AlphabetBegin(void) const;
00748 
00749   /**
00750    * Iterator to End() of alphabet
00751    *
00752    * @return
00753    *   Iterator to end of mpAlphabet
00754    */
00755   EventSet::Iterator AlphabetEnd(void) const;
00756 
00757   /** 
00758    * Test existence of event in alphabet
00759    *
00760    * @param index
00761    *   Event index
00762    *
00763    * @return
00764    *   True / false
00765    */
00766   bool ExistsEvent(Idx index) const;
00767 
00768   /** 
00769    * Test existence of event in alphabet
00770    *
00771    * @param rName
00772    *   Event name
00773    *
00774    * @return
00775    *   True / false
00776    */
00777   bool ExistsEvent(const std::string& rName) const;
00778 
00779   /**
00780    * Returns a iterator to event index in alphabet
00781    *
00782    * @param index
00783    *   Index to find
00784    *
00785    * @return
00786    *   Iterator to event index
00787    */
00788   EventSet::Iterator FindEvent(Idx index) const;
00789 
00790   /**
00791    * Returns a iterator to event index in alphabet
00792    *
00793    * @param rName
00794    *   Event name of index to find
00795    *
00796    * @return
00797    *   Iterator to event index
00798    */
00799   EventSet::Iterator FindEvent(const std::string& rName) const;
00800 
00801   /**
00802    * Return const reference to alphabet 
00803    *
00804    * @return EventSet
00805    *   Reference to mpAlphabet
00806    */
00807   const EventSet& Alphabet(void) const;
00808 
00809   /**
00810    * Iterator to Begin() of state set
00811    *
00812    * @return
00813    *   Iterator to begin of state set
00814    */
00815   StateSet::Iterator StatesBegin(void) const;
00816 
00817   /**
00818    * Iterator to End() of state set
00819    *
00820    * @return
00821    *   Iterator to end of state set
00822    */
00823   StateSet::Iterator StatesEnd(void) const;
00824 
00825   /**
00826    * Test existence of state in state set
00827    * 
00828    * @param index
00829    *   State index
00830    *
00831    * @return
00832    *   true / false
00833    */
00834   bool ExistsState(Idx index) const;
00835 
00836   /**
00837    * Test existence of state in state set
00838    * 
00839    * @param name
00840    *   State name
00841    *
00842    * @return
00843    *   true / false
00844    */
00845   bool ExistsState(const std::string& name) const;
00846 
00847   /**
00848    * Returns a iterator to state index in state set 
00849    *
00850    * @param index
00851    *   Index to find
00852    *
00853    * @return
00854    *   StateSet::Iterator to state index
00855    */
00856   StateSet::Iterator FindState(Idx index) const;
00857 
00858   /**
00859    * Returns a iterator to state with specified name
00860    *
00861    * @param rName
00862    *   name of state to find
00863    *
00864    * @return
00865    *   StateSet::Iterator to state 
00866    */
00867   StateSet::Iterator FindState(const std::string& rName) const;
00868 
00869 
00870   /**
00871    * Return reference to state set
00872    *
00873    * @return 
00874    *   StateSet reference incl actual attribute type
00875    */
00876   const StateSet& States(void) const;
00877 
00878   /**
00879    * Return initial state 
00880    *
00881    * @return
00882    *   Index of initial state
00883    *
00884    * @exception Exception
00885    *  - initial state does not exist uniquely (id 92)
00886    */
00887   Idx InitState(void) const;
00888 
00889   /**
00890    * Iterator to Begin() of mInitStates
00891    *
00892    * @return
00893    *   Iterator to begin of mInitStates
00894    */
00895   StateSet::Iterator InitStatesBegin(void) const;
00896 
00897   /**
00898    * Iterator to End() of mInitStates
00899    * 
00900    * @returns
00901    *   Iterator to end of mInitStates
00902    */
00903   StateSet::Iterator InitStatesEnd(void) const;
00904 
00905   /**
00906    * Test existence of state in mInitStates
00907    * 
00908    * @param index
00909    *   State index
00910    *
00911    * @return
00912    *   true / false
00913    */
00914   bool ExistsInitState(Idx index) const;
00915 
00916   /**
00917    * Returns a iterator to state index in mInitStates 
00918    *
00919    * @param index
00920    *   Index to find
00921    *
00922    * @return
00923    *   StateSet::Iterator to state index
00924    */
00925   StateSet::Iterator FindInitState(Idx index) const;
00926 
00927   /**
00928    * Return const ref to initial states
00929    *
00930    * @return StateSet
00931    */
00932   const StateSet& InitStates(void) const;
00933 
00934   /**
00935    * iterator to Begin() of mMarkedStates
00936    *
00937    * @returns
00938    *   iterator to Begin of mMarkedStates
00939    */
00940   StateSet::Iterator MarkedStatesBegin(void) const;
00941 
00942   /**
00943    * iterator to End() of mMarkedStates
00944    * 
00945    * @returns
00946    *   iterator to End of mMarkedStates
00947    */
00948   StateSet::Iterator MarkedStatesEnd(void) const;
00949 
00950   /**
00951    * Test existence of state in mMarkedStates
00952    * 
00953    * @param index
00954    *   State index
00955    *
00956    * @return
00957    *   true / false
00958    */
00959   bool ExistsMarkedState(Idx index) const;
00960 
00961   /**
00962    * Returns a iterator to state index in mMarkedStates
00963    *
00964    * @param index
00965    *   Index to find
00966    *
00967    * @return
00968    *   StateSet::Iterator to state index
00969    */
00970   StateSet::Iterator FindMarkedState(Idx index) const;
00971 
00972   /**
00973    * Return const ref of marked states
00974    *
00975    * @return StateSet
00976    */
00977   const StateSet& MarkedStates(void) const;
00978 
00979   /**
00980    * Iterator to Begin() of transition relation
00981    *
00982    * @return
00983    *   Iterator to Begin of mpTransRel
00984    */
00985   TransSet::Iterator TransRelBegin(void) const;
00986 
00987   /**
00988    * Iterator to End() of transition relation
00989    * 
00990    * @return
00991    *   Iterator to End of mpTransRel
00992    */
00993   TransSet::Iterator TransRelEnd(void) const;
00994 
00995   /**
00996    * iterator to begin of transitions with x1 as predecessor state.
00997    *
00998    * @param x1
00999    *   Predecessor state
01000    *
01001    * @return
01002    *   iterator to begin of transitions with x1
01003    */
01004   TransSet::Iterator TransRelBegin(Idx x1) const;
01005 
01006   /**
01007    * iterator to end of transitions with x1 as predecessor state. 
01008    *
01009    * Note: Set the End(x1) iterator to a variable, so it won't be 
01010    * recalculated every iteration.
01011    *
01012    * @param x1
01013    *   Predecessor state
01014    *
01015    * @return 
01016    *   iterator to end of transitions with x1 
01017    *   (one after last matching transition)
01018    */
01019   TransSet::Iterator TransRelEnd(Idx x1) const;
01020 
01021   /**
01022    * iterator to begin of transitions with x1 as predecessor state and
01023    * event ev. 
01024    *
01025    * @param x1
01026    *   Predecessor state
01027    * @param ev
01028    *   Event
01029    *
01030    * @return
01031    *   iterator to begin of transitions with x1 and ev
01032    */
01033   TransSet::Iterator TransRelBegin(Idx x1, Idx ev) const;
01034 
01035   /**
01036    * iterator to end of transitions with x1 as predecessor state and
01037    * event ev.
01038    *
01039    * Note: Set the End(x1,ev) iterator to a variable, so it won't be 
01040    * recalculated every iteration.
01041    * 
01042    * @param x1
01043    *   Predecessor state
01044    * @param ev
01045    *   Event
01046    *
01047    * @return
01048    *   iterator to end of transitions with x1 and ev 
01049    *   (one after last matching transition)
01050    */
01051   TransSet::Iterator TransRelEnd(Idx x1, Idx ev) const;
01052 
01053   /**
01054    * iterator to transition given by x1, ev, x2
01055    *
01056    * 
01057    * @param rX1
01058    *   name of Predecessor state
01059    * @param rEv
01060    *   name of Event
01061    * @param rX2
01062    *   name of Successor state
01063    *
01064    * @return
01065    *   iterator to transition or end() if not exists
01066    */
01067   TransSet::Iterator FindTransition(
01068     const std::string& rX1, const std::string& rEv, const std::string& rX2) const;
01069 
01070   /**
01071    * iterator to transition given by x1, ev, x2
01072    *
01073    * 
01074    * @param x1
01075    *   Predecessor state
01076    * @param ev
01077    *   Event
01078    * @param x2
01079    *   Successor state
01080    *
01081    * @return
01082    *   iterator to transition or End() if not exists
01083    */
01084   TransSet::Iterator FindTransition(Idx x1, Idx ev, Idx x2) const;
01085 
01086   /**
01087    * iterator to transition 
01088    *
01089    * 
01090    * @param rTrans
01091    *   transition
01092    *
01093    * @return
01094    *   iterator to transition or end() if not exists
01095    */
01096   TransSet::Iterator FindTransition(const Transition& rTrans) const;
01097 
01098   /**
01099    * test for transition given by x1, ev, x2
01100    *
01101    * 
01102    * @param rX1
01103    *   name of Predecessor state
01104    * @param rEv
01105    *   name of Event
01106    * @param rX2
01107    *   name of Successor state
01108    *
01109    * @return
01110    *   true / false
01111    */
01112   bool ExistsTransition(
01113     const std::string& rX1, const std::string& rEv, const std::string& rX2) const;
01114 
01115   /**
01116    * test for transition given by x1, ev, x2
01117    *
01118    * 
01119    * @param x1
01120    *   Predecessor state
01121    * @param ev
01122    *   Event
01123    * @param x2
01124    *   Successor state
01125    *
01126    * @return
01127    *   true / false
01128    */
01129   bool ExistsTransition(Idx x1, Idx ev, Idx x2) const;
01130 
01131   /**
01132    * test for transition 
01133    *
01134    * 
01135    * @param rTrans
01136    *   transition
01137    *
01138    * @return
01139    *   true / false
01140    */
01141   bool ExistsTransition(const Transition& rTrans) const;
01142 
01143   /**
01144    * Return reference to transition relation
01145    *
01146    * @return TransRel
01147    */
01148   const TransSet& TransRel(void) const;
01149 
01150   /**
01151    * Get copy of trantision relation  sorted by other compare 
01152    * operator, e.g. "x2,ev,x1"
01153    * 
01154    * @param res
01155    *   resulting transition relation 
01156    */
01157   void TransRel(TransSetX1EvX2& res) const;
01158   void TransRel(TransSetEvX1X2& res) const;
01159   void TransRel(TransSetEvX2X1& res) const;
01160   void TransRel(TransSetX2EvX1& res) const;
01161   void TransRel(TransSetX2X1Ev& res) const;
01162   void TransRel(TransSetX1X2Ev& res) const;
01163 
01164   /** @} doxygen group */
01165 
01166 
01167 
01168   /*****************************************
01169    *****************************************
01170    *****************************************
01171    *****************************************/
01172 
01173   /** @name Write Access to Core Members */
01174   /** @{ doxygen group */
01175 
01176 
01177   /**
01178    * Add an existing event to alphabet by index. It is an error to insert
01179    * an event index that is not known to the mpEventSymbolTable.
01180    *
01181    * @param index
01182    *   Event index
01183    * @return
01184    *   True, if event was new to alphabet
01185    */
01186   bool InsEvent(Idx index);
01187 
01188   /**
01189    * Add named event to generator. An entry in the mpEventSymbolTable will
01190    * be made if event name is not known so far.
01191    *
01192    * @param rName
01193    *   Name of the event to add
01194    *
01195    * @return 
01196    *   New unique index
01197    */
01198   Idx InsEvent(const std::string& rName);
01199 
01200   /**
01201    * Add new named events to generator.
01202    * If the event allready exists, the attribute is maintained.
01203    *
01204    * @param events
01205    *   EventSet
01206    */
01207   void InsEvents(const EventSet& events);
01208 
01209   /**
01210    * Delete event from generator by index. mpEventSymbolTable stays untouched.
01211    * Transitions containing event will be removed too.
01212    *
01213    * @param index
01214    *   Index of event
01215    * @return
01216    *   True, if event was in alphabet
01217    *
01218    */
01219   bool DelEvent(Idx index);
01220 
01221   /**
01222    * Delete event from generator by name. mpEventSymbolTable stays untouched.
01223    * Transitions containing event will be removed too.
01224    *
01225    * @param rName
01226    *    Name of event
01227    * @return
01228    *   True, if event was in alphabet
01229    *
01230    */
01231   bool DelEvent(const std::string& rName);
01232 
01233   /** 
01234    * Delete a set of events from generator. mpEventSymbolTable stays untouched.
01235    * Transitions containing events will be removed too.
01236    * 
01237    * @param rEvents
01238    *   EventSet containing events to remove
01239    */
01240   void DelEvents(const EventSet& rEvents);
01241 
01242   /** 
01243    * Delete event from alphabet without consistency check. The event is only
01244    * deleted from mpAlphabet but not from transition relation.
01245    *
01246    * @param index
01247    *   Index of event
01248    * @return
01249    *   True, if event was in alphabet
01250    *
01251    */
01252   bool DelEventFromAlphabet(Idx index);
01253 
01254   /**
01255    * Set mpAlphabet without consistency check.
01256    * Sets the alphabet incl attributes, if provided.
01257    *
01258    * @param rNewalphabet
01259    *   EventSet with new alphabet
01260    */
01261   void InjectAlphabet(const EventSet& rNewalphabet);
01262 
01263   /**
01264    * Restricts mpAlphabet without consistency check.
01265    * Maintains attributes if any.
01266    *
01267    * @param rNewalphabet
01268    *   EventSet with alphabet
01269    */
01270   void RestrictAlphabet(const EventSet& rNewalphabet);
01271 
01272   /** 
01273    * Add new anonymous state to generator 
01274    * 
01275    * @return 
01276    *   Index of new unique state
01277    */
01278   Idx InsState(void);
01279 
01280   /** 
01281    * Add (perhaps new) state to generator 
01282    * 
01283    * @return 
01284    *   True to indicate that state was new to generator
01285    */
01286   bool InsState(Idx index);
01287 
01288   /** 
01289    * Add new named state to generator. 
01290    *
01291    * @param rName
01292    *   Name of the state to add
01293    *
01294    * @return 
01295    *   Index of new unique state
01296    *
01297    * @exception Exception
01298    *   Name already exists (id 44)
01299    */
01300   Idx InsState(const std::string& rName);
01301 
01302   /** 
01303    * Delete a state from generator by index. 
01304    * Cleans mpStates, mInitStates, mMarkedStates, mpTransRel and mpStateSymbolTable.
01305    *
01306    * @param index
01307    *   Index of state to delete. 
01308    * @return
01309    *   True, if state was in stateset
01310    */
01311   bool DelState(Idx index);
01312 
01313   /** 
01314    * Delete a state from generator by name.
01315    * Cleans mpStates, mInitStates, mMarkedStates, mpTransRel and mpStateSymbolTable.
01316    *
01317    * @param rName
01318    *   Name of state to delete. Will be erased in mpStateSymbolTable too
01319    * @return
01320    *   True, if state was in stateset
01321    *
01322    * @exception Exception
01323    *   - Symbolic name not known (id 90)
01324    */
01325   bool DelState(const std::string& rName);
01326 
01327   /**
01328    * Delete a set of states 
01329    * Cleans mpStates, mInitStates, mMarkedStates, mpTransrel, and mpStateSymboltable
01330    *
01331    * @param rDelStates
01332    *   StateSet containing states aka indicees to delete
01333    */
01334   void DelStates(const StateSet& rDelStates);
01335 
01336 
01337   /**
01338    * Delete a state from generator without consistency check. This removes the
01339    * state from mpStates and mpStateSymbolTable but doesn't touch mpTransRel,
01340    * mInitStates and mMarkedStates.
01341    *
01342    * @param index
01343    *   Index of state to delete. 
01344    * @return
01345    *   True, if state was in stateset
01346    *
01347    */
01348   bool DelStateFromStates(Idx index);
01349 
01350   /**
01351    * Delete a state from generator without consistency check. This removes the
01352    * state from mpStates and mpStateSymbolTable but doesn't touch mpTransRel,
01353    * mInitStates and mMarkedStates.
01354    * Index to delete is given by iterator. 
01355    *
01356    * @param pos
01357    *   StateSet::Iterator
01358    * @return
01359    *   Iteraror to next state
01360    */
01361   StateSet::Iterator DelStateFromStates(StateSet::Iterator pos);
01362 
01363   /** 
01364    * Inject an existing state index into generators mStates
01365    * Use with care! For use in performance optimized functions.
01366    *
01367    * @param index
01368    *   State index to inject
01369    */
01370   void InjectState(Idx index);
01371 
01372   /**
01373    * Inject a complete state set without consistency checks (without attributes)
01374    *
01375    * @param rNewStates
01376    *    StateSet
01377    */
01378   void InjectStates(const StateSet& rNewStates);
01379 
01380 
01381   /**
01382    * Create new anonymous state and set as initial state
01383    *
01384    * @return 
01385    *   Index of new unique
01386    */
01387   Idx InsInitState(void);
01388 
01389   /** 
01390    * Add (perhaps new) state to generator and turn it
01391    * into a initial state. 
01392    * 
01393    * @param index
01394    *   State to insert
01395    * @return 
01396    *   True to indicate that state was new to generator
01397    */
01398   bool InsInitState(Idx index);
01399 
01400   /**
01401    * Create a new named state and set as initial state
01402    *
01403    * @param rName
01404    *   Name of the state to add
01405    *
01406    * @return 
01407    *   Index of new unique state
01408    */
01409   Idx InsInitState(const std::string& rName);
01410 
01411   /**
01412    * Create new anonymous state and set as marked state
01413    *
01414    * @return 
01415    *   Index of new unique state
01416    */
01417   Idx InsMarkedState(void);
01418 
01419   /** 
01420    * Add (perhaps new) state to generator and turn it
01421    * into a marked state. 
01422    * 
01423    * @param index
01424    *   State to insert
01425    * @return 
01426    *   True to indicate that state was new to generator
01427    */
01428   bool InsMarkedState(Idx index);
01429 
01430   /**
01431    * Create a new named state and set as marked state
01432    *
01433    * @param rName
01434    *   Name of the state to add
01435    *
01436    * @return 
01437    *   Index of new unique state
01438    */
01439   Idx InsMarkedState(const std::string& rName);
01440 
01441   /**
01442    * Set an existing state as initial state by index.
01443    *
01444    * @param index
01445    *   Index of state to set as initial state
01446    * @exception Exception
01447    *   - State index not found in generator (id 91)
01448    */
01449   void SetInitState(Idx index);
01450 
01451   /**
01452    * Set an existing state as initial state by name. 
01453    *
01454    * @param rName
01455    *   Name of state to set as initial state
01456    *
01457    * @exception Exception
01458    *   - State name not known in generator (id 90)
01459    */
01460   void SetInitState(const std::string& rName);
01461 
01462   /**
01463    * Replace mInitStates with StateSet given as parameter without consistency checks.
01464    *
01465    * @param rNewInitStates
01466    *   StateSet containing new mInitStates
01467    */
01468   void InjectInitStates(const StateSet& rNewInitStates);
01469 
01470   /**
01471    * Unset an existing state as initial state by index
01472    *
01473    * Define FAUDES_CHECKED for consistency checks.
01474    *
01475    * @param index
01476    *   State index
01477    *
01478    * @exception Exception
01479    *   - State index not found in generator (id 91)
01480    */
01481   void ClrInitState(Idx index);
01482 
01483   /**
01484    * Unset an existing state as initial state by name 
01485    *
01486    * @param rName
01487    *   State name
01488    *
01489    * @exception Exception
01490    *   - State name not known in generator (id 90)
01491    */
01492   void ClrInitState(const std::string& rName);
01493 
01494   /**
01495    * Unset an existing state as initial state by iterator
01496    *
01497    * @param pos
01498    *   StateSet::iterator
01499    * @return 
01500    *   Iterator to next init state
01501    */
01502   StateSet::Iterator ClrInitState(StateSet::Iterator pos);
01503 
01504   /**
01505    * Clear all mInitStates
01506    */
01507   void ClearInitStates(void); 
01508 
01509   /**
01510    * Set an existing state as marked state by index
01511    *
01512    * @param index
01513    *   Index of state to set as initial state
01514    * @exception Exception
01515    *   - State index not found in generator (id 91)
01516    */
01517   void SetMarkedState(Idx index);
01518 
01519   /**
01520    * Set an existing state as marked state by name. 
01521    *
01522    * @param rName
01523    *   Name of state to set as marked state
01524    *
01525    * @exception Exception
01526    *   - State name not known in generator (id 90)
01527    */
01528   void SetMarkedState(const std::string& rName);
01529 
01530   /**
01531    * Unset an existing state as marked state by index
01532    *
01533    * @param index
01534    *   State index
01535    *
01536    * @exception Exception
01537    *   - State index not found in generator (id 91)
01538    */
01539   void ClrMarkedState(Idx index);
01540 
01541   /**
01542    * Unset an existing state as marked state by name
01543    *
01544    * @param rName
01545    *   State name
01546    *
01547    * @exception Exception
01548    *   - State index not found in generator (id 91)
01549    */
01550    void ClrMarkedState(const std::string& rName);
01551 
01552   /**
01553    * Unset an existing state as marked state by iterator
01554    *
01555    * @param pos
01556    *   StateSet::iterator
01557    * @return 
01558    *   Iterator to next marked state
01559    */
01560   StateSet::Iterator ClrMarkedState(StateSet::Iterator pos);
01561 
01562   /**
01563    * Clear all marked states
01564    */
01565   void ClearMarkedStates(void);
01566 
01567   /**
01568    * Replace mMarkedStates with StateSet given as parameter without consistency checks.
01569    *
01570    * @param rNewMarkedStates
01571    *   StateSet containing new marked states
01572    */
01573   void InjectMarkedStates(const StateSet& rNewMarkedStates);
01574 
01575   /** 
01576    * Add a transition to generator by indices. States and event
01577    * must already exist.
01578    *
01579    * @param x1 
01580    *   Predecessor state index 
01581    * @param ev 
01582    *   Event index 
01583    * @param x2
01584    *   Successor state index
01585    *
01586    * @return
01587    *   True, if the transition was new the generator
01588    *
01589    * @exception Exception
01590    *   - state or event not in generator (id 95)
01591    */
01592   bool SetTransition(Idx x1, Idx ev, Idx x2);
01593 
01594   /** 
01595    * Add a transition to generator by names. Statename and eventname
01596    * must already exist.
01597    *
01598    * @param rX1
01599    *   Predecessor state name
01600    * @param rEv
01601    *   Event name
01602    * @param rX2
01603    *   Successor state name
01604    *
01605    * @return
01606    *   True, if the transition was new the generator
01607    *
01608    * @exception Exception
01609    *   - state or event not in generator (id 95)
01610    *   - state name not known (id 90)
01611    *   - event name not known (id 66)
01612    */
01613   bool SetTransition(const std::string& rX1, const std::string& rEv, 
01614            const std::string& rX2);
01615 
01616   /** 
01617    * Add a transition to generator. States and event
01618    * must already exist.
01619    *
01620    *
01621    * @param rTransition
01622    *   Transition
01623    *
01624    * @return
01625    *   True, if the transition was new the generator
01626    * @exception Exception
01627    *   - state or event not in generator (id 95)
01628    */
01629   bool SetTransition(const Transition& rTransition);
01630 
01631   /**
01632    * Remove a transition by indices
01633    *
01634    * @param x1
01635    *   Predecessor state index
01636    * @param ev
01637    *   Event index
01638    * @param x2
01639    *   Successor state index
01640    */
01641   void ClrTransition(Idx x1, Idx ev, Idx x2);
01642 
01643   /**
01644    * Remove a transition by transition object
01645    *
01646    * @param rTrans
01647    *   Transition object
01648    */
01649   void ClrTransition(const Transition& rTrans);
01650 
01651   /**
01652    * Remove a transition by iterator
01653    *
01654    * @param it
01655    *   TransSet::iterator 
01656    * @return
01657    *   Iterator to next transition
01658    */
01659   TransSet::Iterator ClrTransition(TransSet::Iterator it);
01660 
01661   /**
01662    * Clear all transitions
01663    */
01664   void ClearTransRel(void);
01665 
01666   /**
01667    * Set transition without consistency check.
01668    *
01669    * @param rTrans
01670    *   Transition to insert
01671    */
01672   void InjectTransition(const Transition& rTrans);
01673 
01674   /**
01675    * Set transition relation without consistency check (no attributes)
01676    *
01677    * @param rNewtransrel
01678    *   TransRel to insert
01679    */
01680   void InjectTransRel(const TransSet& rNewtransrel);
01681 
01682   /** @} doxygen group */
01683 
01684 
01685 
01686   /*****************************************
01687    *****************************************
01688    *****************************************
01689    *****************************************/
01690 
01691   /** @name Attributes */
01692   /** @{ doxygen group */
01693 
01694 
01695   /**
01696    * Clear Attributes
01697    */
01698   virtual void ClearAttributes(void);
01699 
01700   /**
01701    * Updates internal attributes. 
01702    * This method does nothing and may be reimplemented 
01703    * by a any class that adds semantics to attributes
01704    * Eg. you may set a particular state flag, if this state 
01705    * is reachable.
01706    * 
01707    * @return True if value changed
01708    */
01709   virtual bool UpdateAttributes(void) {return false;};
01710 
01711   /**
01712    * Clear event attributes
01713    */
01714   virtual void ClearEventAttributes(void);
01715 
01716   /**
01717    * Clear attribute for existing event
01718    *
01719    * @param index
01720    *   Event index
01721    */
01722   virtual void ClrEventAttribute(Idx index);
01723 
01724   /**
01725    * Set attribute for existing event. 
01726    * This version uses a dynamic cast
01727    * to test the actual type of the provided attribute. An exception is
01728    * thrown for an invalid attribute type. 
01729    * In a context where
01730    * the attribute type is known, you may prefer the TaGenerator method.
01731    *
01732    * @param index
01733    *   Event index
01734    * @param rAttr
01735    *   New attribute
01736    *
01737    * @exception Exception
01738    *   - Index not found in alphabet (id 60)
01739    *   - Cannot cast attribute (id 63)
01740    */
01741    virtual void EventAttribute(Idx index, const Type& rAttr);
01742 
01743   /**
01744    * Set attributes for existing events. 
01745    * This version uses a dynamic cast
01746    * to test the actual type of the provided attributes. An exception is
01747    * thrown for an invalid attribute type. 
01748    *
01749    * @param rEventSet
01750    *   Set of attributed events
01751    * @exception Exception
01752    *   - Element not found in alphabet (id 60)
01753    *   - Cannot cast attribute (id 63)
01754    */
01755    virtual void EventAttributes(const EventSet& rEventSet);
01756 
01757   /** 
01758    * Event attribute lookup. 
01759    * In a context where
01760    * the attribute type is known, you may prefer the TaGenerator method.
01761    *
01762    * @param index
01763    *
01764    * @return 
01765    *   reference to attribute
01766    */
01767   virtual const AttributeVoid& EventAttribute(Idx index) const;
01768 
01769   /** 
01770    * Event attribute lookup. 
01771    * In a context where the attribute type is known, 
01772    * you may prefer the TaGenerator method.
01773    *
01774    * @param rName
01775    *
01776    * @return 
01777    *   reference to attribute
01778    */
01779   virtual const AttributeVoid& EventAttribute(const std::string& rName) const;
01780 
01781   /** 
01782    * Event attribute pointer to access Attribute methods.
01783    * If there are no attributes (plain vGenerator) this method
01784    * returs 0. If there are attributes, an explicit default value
01785    * may be inserted. 
01786    * In a context where the attribute type is known, 
01787    * you may prefer the TaGenerator method.
01788    *
01789    * @param index
01790    *
01791    * @return 
01792    *   pointer to attribute
01793    */
01794   virtual AttributeVoid* EventAttributep(Idx index);
01795 
01796   /** 
01797    * Event attribute pointer to access Attribute methods.
01798    * If there are no attributes (plain vGenerator) this method
01799    * returs 0. If there are attributes, an explicit default value
01800    * may be inserted. 
01801    * In a context where the attribute type is known, 
01802    * you may prefer the TaGenerator method.
01803    *
01804    * @param rName
01805    *
01806    * @return 
01807    *   pointer to attribute
01808    */
01809   virtual AttributeVoid* EventAttributep(const std::string& rName);
01810 
01811 
01812   /**
01813    * Clear state attributes
01814    */
01815   virtual void ClearStateAttributes(void);
01816 
01817   /**
01818    * Clear attribute for existing state
01819    *
01820    * @param index
01821    *   State index
01822    */
01823   virtual void ClrStateAttribute(Idx index);
01824 
01825   /**
01826    * Set attribute for existing state. 
01827    * This version uses a dynamic cast
01828    * to test the actual type of the provided attribute. An exception is
01829    * thrown for an invalid attribute type. 
01830    * In a context where
01831    * the attribute type is known, you may prefer the TaGenerator method.
01832    *
01833    * @param index
01834    *   State index
01835    * @param rAttr
01836    *   New attribute
01837    *
01838    * @exception Exception
01839    *   - Index not found in Stateset (id 60)
01840    *   - Cannot cast attribute (id 63)
01841    */
01842   virtual void StateAttribute(Idx index, const Type& rAttr);
01843 
01844   /** 
01845    * State attribute lookup. 
01846    * In a context where the attribute type is known, 
01847    * you may prefer the TaGenerator method.
01848    *
01849    * @param index
01850    *   State index
01851    *
01852    * @return Ref to attribute of state
01853    */
01854   virtual const AttributeVoid& StateAttribute(Idx index) const;
01855 
01856   /** 
01857    * State attribute pointer to access Attribute methods.
01858    * If there are no attributes (plain vGenerator) this method
01859    * returns 0. If there are attributes, an explicit default value
01860    * may be inserted. 
01861    * In a context where the attribute type is known, 
01862    * you may prefer the TaGenerator method.
01863    *
01864    * @param index
01865    *   State index
01866    *
01867    * @return Pointer to attribute of state
01868    */
01869   virtual AttributeVoid* StateAttributep(Idx index);
01870 
01871   /**
01872    * Clear transition attributes
01873    */
01874   virtual void ClearTransAttributes(void);
01875 
01876   /**
01877    * Set attribute for existing transition.
01878    * This version uses a dynamic cast
01879    * to test the actual type of the provided attribute. An exception is
01880    * thrown for an invalid attribute type. 
01881    * In a context where
01882    * the attribute type is known, you may prefer the TaGenerator method.
01883    *
01884    * @param rTrans
01885    *   Transition
01886    * @param rAttr
01887    *   New attribute
01888    *
01889    * @exception Exception
01890    *   - Transition not found in transition relation(id 60)
01891    *   - Cannot cast attribute (id 63)
01892    */
01893    virtual void TransAttribute(const Transition& rTrans, const Type& rAttr);
01894 
01895 
01896   /**
01897    * Clear attribute for existing transition
01898    *
01899    * @param rTrans
01900    *   transition
01901    */
01902   virtual void ClrTransAttribute(const Transition& rTrans);
01903 
01904   /**
01905    * Transition attribute lookup.
01906    * In a context where the attribute type is known, 
01907    * you may prefer the TaGenerator method.
01908    *
01909    * @return 
01910    *   Attribute
01911    *
01912    */
01913   virtual const AttributeVoid& TransAttribute(const Transition& rTrans) const;
01914 
01915   /**
01916    * Transition attribute pointer to access Attribute methods.
01917    * If there are no attributes (plain vGenerator) this method
01918    * returns 0. If there are attributes, an explicit default value
01919    * may be inserted. 
01920    * In a context where the attribute type is known, 
01921    * you may prefer the TaGenerator method.
01922    *
01923    * @return 
01924    *   Attribute pointer
01925    *
01926    */
01927   virtual AttributeVoid* TransAttributep(const Transition& rTrans);
01928 
01929   /**
01930    * Clear global attribute
01931    */
01932   virtual void ClearGlobalAttribute(void);
01933 
01934   /** 
01935    * Set global attribute. 
01936    * The vGenerator does not have attributes, so this function throws an exception for
01937    * any specified attribute different to AttributeVoid.
01938    * The TaGenarator provides a re-implementation to actually set the global attribute.
01939    *
01940    * @param rAttr
01941    *   Attribute
01942    * @exception Exception
01943    *   - Cannot cast attribute (id 63)
01944    */
01945   virtual void GlobalAttribute(const Type& rAttr);
01946 
01947   /** 
01948    * Set global attribute. 
01949    * The vGenerator does not have attributes, so this function does nothing.
01950    * The TaGenarator provides a re-implementation to actually set the global attribute.
01951    *
01952    * @param rAttr
01953    *   Attribute
01954    */
01955   virtual void GlobalAttributeTry(const Type& rAttr);
01956 
01957   /** 
01958    * Global attribute lookup.
01959    * In a context where the attribute type is known, 
01960    * you may prefer the TaGenerator method.
01961    */
01962   virtual const AttributeVoid& GlobalAttribute(void) const;
01963 
01964 
01965   /** 
01966    * Get attribute pointer 
01967    * The global attribute allways exits. For the vGenerator its of
01968    * type AttributeVoid, the TaGenerator sets a nontrivial type.
01969    * In a context where the attribute type is known, 
01970    * you may prefer the TaGenerator method.
01971    */
01972   virtual AttributeVoid* GlobalAttributep(void);
01973 
01974 
01975   /** @} doxygen group */
01976 
01977 
01978 
01979   /*****************************************
01980    *****************************************
01981    *****************************************
01982    *****************************************/
01983 
01984   /** @name Reachability */
01985   /** @{ doxygen group */
01986 
01987 
01988   /**
01989    * Compute set of accessible states
01990    */
01991   StateSet AccessibleSet(void) const;
01992 
01993   /**
01994    * Make generator accessible
01995    *
01996    * @return
01997    *   True if generator contains at least one initial state
01998    */
01999   bool Accessible(void);
02000 
02001   /**
02002    * Check if generator is accessible
02003    *
02004    * @return
02005    *   True if generator is accesssible
02006    */
02007   bool IsAccessible(void) const;
02008 
02009   /**
02010    * Compute set of Coaccessible states
02011    */
02012   StateSet CoaccessibleSet(void) const;
02013 
02014   /**
02015    * Make generator Coaccessible
02016    *
02017    * @return
02018    *   True if generator contains at least one marked state
02019    */
02020   bool Coaccessible(void);
02021 
02022   /**
02023    * Check if generator is Coaccessible
02024    *
02025    * @return
02026    *   True if generator is coaccessible
02027    */
02028   bool IsCoaccessible(void) const;
02029 
02030   /**
02031    * Computer set of trim states
02032    */
02033   StateSet TrimSet(void) const;
02034 
02035   /**
02036    * Make generator trim
02037    *
02038    * @return 
02039    *   True if resulting generator contains at least one initial state and at least one marked state.
02040    */
02041   bool Trim(void);
02042 
02043   /**
02044    * Check if generator is trim
02045    *
02046    * @return
02047    *   True if generator is trim
02048    */
02049   bool IsTrim(void) const;
02050 
02051 
02052   /**
02053    * Compute set of blocking states.
02054    *
02055    * A state is considered blocking it is reachable but not coreachable.
02056    */
02057   StateSet BlockingStates(void) const;
02058 
02059 
02060   /**
02061    * Check if generator is complete.
02062    *
02063    * A generator is considered complete, if each state has at least
02064    * one successor state. If the generator is trim, completeness
02065    * is equivalent to completeness of the markede language, ie 
02066    * forall s in Lm(G) there exists r in Lm(G) with s<r
02067    * @return
02068    *   True if generator is complete
02069    */
02070   bool IsComplete(void) const;
02071 
02072   /**
02073    * Check if generator is complete.
02074    *
02075    * Same as IsComplete(void), however, only the specified
02076    * states are considered. The rational is to e.g. apply the test
02077    * to reachable states only. In that case, the test is equivalent
02078    * to completeness of the generated language.
02079    *
02080    * @param rStates
02081    *   Set of state indices to restrict the completeness test
02082    * @return
02083    *   True if generator is relatively complete
02084    */
02085   bool IsComplete(const StateSet& rStates) const;
02086 
02087   /**
02088    * Compute set of terminal states.
02089    *
02090    * A terminal state is a state with no successor state.
02091    * If and only if the set of terminal states is empty, the generator is complete.
02092    * @return
02093    *   Set of terminal states.
02094    */
02095   StateSet TerminalStates(void) const;
02096 
02097 
02098   /**
02099    * Compute set of terminal states.
02100    *
02101    * A terminal state is a state with no successor state.
02102    * This function returns the the set terminal states contained
02103    * in the specified state ste.
02104    *
02105    * @param rStates
02106    *   Set of state indices to restrict the search
02107    * @return
02108    *   Set of terminal states.
02109    */
02110   StateSet TerminalStates(const StateSet& rStates) const;
02111 
02112 
02113   
02114 
02115 
02116   /** @} doxygen group */
02117 
02118   /*****************************************
02119    *****************************************
02120    *****************************************
02121    *****************************************/
02122 
02123   /** @name File IO */
02124   /** @{ doxygen group */
02125  
02126   /**
02127    * Write generators alphabet to console
02128    */
02129   void WriteAlphabet(void) const;
02130 
02131   /**
02132    * Write generators alphabet to string
02133    *
02134    * @return
02135    *   std::string
02136    * @exception Exception
02137    *   - IO errors (id 2)
02138    */
02139   std::string AlphabetToString(void) const;
02140 
02141   /**
02142    * Write generators alphabet to tokenwriter
02143    *
02144    * @param rTw
02145    *   Reference to TokenWriter
02146    *
02147    * @exception Exception
02148    *   - IO errors (id 2)
02149    */
02150   void WriteAlphabet(TokenWriter& rTw) const;
02151 
02152   /**
02153    * Write a stateset to console (no re-indexing).
02154    * Uses WriteStateSet(TokenWriter& rTw, const StateSet&) const to write
02155    * the specified state set to console  referring to this generators state names.
02156    *
02157    * @param rStateSet
02158    *   Reference to stateset
02159    */
02160   void WriteStateSet(const StateSet& rStateSet) const;
02161 
02162   /**
02163    * Write a stateset to string (no re-indexing). 
02164    * Uses WriteStateSet(TokenWriter& rTw, const StateSet&) const to write
02165    * the specified state set to a string  referring to this generators state names.
02166    *
02167    * @param rStateSet
02168    *   Reference to stateset
02169    * @return
02170    *   std::string
02171    * @exception Exception
02172    *   - IO errors (id 2)
02173    */
02174   std::string StateSetToString(const StateSet& rStateSet) const;
02175 
02176   /**
02177    * Write a stateset to formated text (no re-indexing). 
02178    * Uses WriteStateSet(TokenWriter& rTw, const StateSet&) const to write
02179    * the specified state set to a string  referring to this generators state names.
02180    *
02181    * @param rStateSet
02182    *   Reference to stateset
02183    * @return
02184    *   std::string
02185    * @exception Exception
02186    *   - IO errors (id 2)
02187    */
02188   std::string StateSetToText(const StateSet& rStateSet) const;
02189 
02190   /**
02191    * Write a stateset to TokenWriter. 
02192    * All output of state sets done with this function.
02193    * Recall that a StateSet technically is a set of plain indices, no reference
02194    * to symbolic names. Thus, it is only the context of a Generator that provides
02195    * the symbolic names for file output. 
02196    * 
02197    * Output of state sets always uses the mMinStateIndexMap to re-index states. 
02198    * However, this map is only set up automatically for file output. If You require
02199    * re-indexed output to eg a string, you must set up the map by calling SetMinStateIndexMap().
02200    * To ensure that no re-indexing takes place, call ClearMinStateIndexMap().
02201    *
02202    * @param rTw
02203    *   Reference to TokenWriter
02204    * @param rStateSet
02205    *   Reference to stateset
02206    *
02207    * @exception Exception
02208    *   - IO errors (id 2)
02209    */
02210   void WriteStateSet(TokenWriter& rTw, const StateSet& rStateSet) const;
02211 
02212   /**
02213    * Write a stateset to TokenWriter (debug version, no re-indexing)
02214    * 
02215    * @param rTw
02216    *   Reference to TokenWriter
02217    * @param rStateSet
02218    *   Reference to stateset
02219    *
02220    * @exception Exception
02221    *   - IO errors (id 2)
02222    */
02223    void DWriteStateSet(TokenWriter& rTw, const StateSet& rStateSet) const;
02224 
02225 
02226   /**
02227    * Write stateset of this generator to a string (no  re-indexing)
02228    *
02229    * @return
02230    *   std::string
02231    * @exception Exception
02232    *   - IO errors (id 2)
02233    */
02234   std::string StatesToString(void) const;
02235 
02236   /**
02237    * Write stateset of this generator to formated text (no  re-indexing)
02238    *
02239    * @return
02240    *   std::string
02241    * @exception Exception
02242    *   - IO errors (id 2)
02243    */
02244   std::string StatesToText(void) const;
02245 
02246   /**
02247    * Write set of marked states to a string (no  re-indexing)
02248    *
02249    * @return
02250    *   std::string
02251    * @exception Exception
02252    *   - IO errors (id 2)
02253    */
02254   std::string MarkedStatesToString(void) const;
02255 
02256   /**
02257    * Write set of initial states to a string (no  re-indexing)
02258    *
02259    * @return
02260    *   std::string
02261    * @exception Exception
02262    *   - IO errors (id 2)
02263    */
02264   std::string InitStatesToString(void) const;
02265 
02266   /**
02267    * Write transition relation to console (no re-indexing)
02268    */
02269   void WriteTransRel(void) const;
02270 
02271   /**
02272    * Write transition relation to string (no re-indexing)
02273    */
02274   std::string TransRelToString(void) const;
02275 
02276   /**
02277    * Write transition relation to formated text (no re-indexing)
02278    */
02279   std::string TransRelToText(void) const;
02280 
02281   /**
02282    * Write transition relation to tokenwriter (no  re-indexing).
02283    * Re-indexing and symbolic state names are handled in the same way
02284    * as with state sets: this function refers to the generators state symboltable to
02285    * obtain state names and  uses the mMinStateIndexMap to re-index the output.
02286    *
02287    * @param rTw
02288    *   Reference to TokenWriter
02289    *
02290    * @exception Exception
02291    *   - IO errors (id 2)
02292    */
02293   void WriteTransRel(TokenWriter& rTw) const;
02294 
02295   /**
02296    * Write transition relation to tokenwriter (debug version)
02297    * @param rTw
02298    *   Reference to TokenWriter
02299    *
02300    * @exception Exception
02301    *   - IO errors (id 2)
02302    */
02303   void DWriteTransRel(TokenWriter& rTw) const;
02304 
02305  
02306   /**
02307    * Writes generator to dot input format.
02308    * The dot file format is specified by the graphiz package; see http://www.graphviz.org.
02309    * The package includes the dot command line tool to generate a graphical 
02310    * representation of the generators graph. See also GraphWrite().
02311    * This functions sets the re-indexing to minimal indices.
02312    *
02313    * @param rFileName
02314    *   File to write
02315    *
02316    * @exception Exception
02317    *   - IO errors (id 2)
02318    */
02319   virtual void DotWrite(const std::string& rFileName) const;
02320 
02321   /**
02322    * Writes generator to dot input format (no re-indexing).
02323    * Variant of DotWrite() without re-indexing.
02324    *
02325    * @param rFileName
02326    *   File to write
02327    *
02328    * @exception Exception
02329    *   - IO errors (id 2)
02330    */
02331   virtual void DDotWrite(const std::string& rFileName) const;
02332 
02333   /**
02334    * Writes generator to dot input format for export to VioLib.
02335    * Variant of DotWrite() using strategic state and event names
02336    * to simplify import to VioLib (qt widget for graphical representation
02337    * of FAUDES generators).
02338    *
02339    * @param rFileName
02340    *   File to write
02341    * @exception Exception
02342    *   - IO errors (id 2)
02343    */
02344   virtual void XDotWrite(const std::string& rFileName) const;
02345 
02346   /**
02347    * Read a state set.
02348    * Refer to the generators state symboltable while reading a state set.
02349    * Ignore any attributes.
02350    *
02351    * @param rTr
02352    *   Reference to TokenReader
02353    * @param rLabel
02354    *   Label of set in source
02355    * @param rStateSet
02356    *   Destination state set 
02357    *
02358    * @exception Exception
02359    *   - IO errors (id 1)
02360    *   - token mismatch (id 50, 51, 52, 80, 85)
02361    */
02362   void ReadStateSet(TokenReader& rTr, const std::string& rLabel, StateSet& rStateSet) const;
02363 
02364 
02365   /** @} doxygen group */
02366 
02367 
02368   /*****************************************
02369    *****************************************
02370    *****************************************
02371    *****************************************/
02372 
02373   /** @name Misc */
02374   /** @{ doxygen group */
02375 
02376   /**
02377    * Return used events (executed in transitions)
02378    *
02379    * @return EventSet
02380    */
02381   EventSet UsedEvents(void) const;
02382 
02383   /**
02384    * Return unused events
02385    *
02386    * @return EventSet
02387    */
02388   EventSet UnusedEvents(void) const;
02389 
02390   /**
02391    * Set the alphabet to used events
02392    */
02393   void MinimizeAlphabet(void);
02394 
02395   /**
02396    * Return active event set at state x1
02397    *
02398    * @param x1
02399    *   Index of x1
02400    *
02401    * @return EventSet
02402    */
02403   EventSet ActiveEventSet(Idx x1) const;
02404 
02405   /**
02406    * Return active transition set at state x1
02407    *
02408    * @param x1
02409    *   Index of x1
02410    *
02411    * @return EventSet
02412    */
02413   TransSet ActiveTransSet(Idx x1) const;
02414 
02415   /**
02416    * Return the states covered by transitions
02417    *
02418    * @return StateSet
02419    */
02420   StateSet TransRelStateSpace(void) const;
02421 
02422   /**
02423    * Return the successor states of state x1
02424    *
02425    * @return StateSet
02426    */
02427   StateSet TransRelStateSpace(Idx x1) const;
02428 
02429   /**
02430    * Check if generator is deterministic.
02431    * We insict in exactly one initial state and for each state and event at most 
02432    * one transition (to some successor state). This definition matches the situation
02433    * where a generator is defined to have one inital state as opposed to a set set of initial
02434    * states (which may be empty). In particular, the generated language of a determinitstic 
02435    * generator allways includes the empty string and therefor is not the empty set. When
02436    * focus is on the marked language only, this issue does not exists.
02437    *
02438    * @return
02439    *   True if generator is deterministic
02440    */
02441   bool IsDeterministic(void) const;
02442 
02443   /**
02444    * Set minimal index map for file io of generator states
02445    *
02446    * This function is implemented as fake-const to allow for
02447    * const Write function.
02448    *
02449    */
02450   void SetMinStateIndexMap(void) const;
02451 
02452   /**
02453    * Clear minimal index map for 1:1 file io 
02454    *
02455    */
02456   void ClearMinStateIndexMap(void) const;
02457 
02458   /**
02459    * Get state index as is it will be written to file
02460    *
02461    * @param index
02462    *   state index
02463    * @return
02464    *   minimal index
02465    */
02466   Idx MinStateIndex(Idx index) const;
02467 
02468 
02469   /**
02470    * Get state index translation map
02471    *
02472    * @return
02473    *   minimal index map
02474    */
02475   const std::map<Idx,Idx>& MinStateIndexMap(void) const;
02476 
02477 
02478   /**
02479    * Pretty printable event name for index (eg for debugging).
02480    *
02481    * @param index
02482    *   Event index
02483    *
02484    * @return
02485    *   std::string
02486    */
02487   std::string EStr(Idx index) const;
02488 
02489   /**
02490    * Return pretty printable state name for index (eg for debugging)
02491    *
02492    * @param index
02493    *   State index
02494    *
02495    * @return
02496    *   std::string
02497    */
02498   std::string SStr(Idx index) const;
02499 
02500   
02501   /**
02502    * Return pretty printable transition (eg for debugging)
02503    *
02504    * @param rTrans
02505    *   Transition
02506    *
02507    * @return
02508    *   std::string
02509    */
02510   std::string TStr(const Transition& rTrans) const;
02511 
02512   
02513   /**
02514    * Produce graphical representation of this generator.
02515    * This method calls the generator's DotWrite function and then processes the output
02516    * with the dot tool from graphiz package.  If no output format is given,
02517    * try to guess from filename extension.  See also ProcessDot().
02518    *
02519    * @param rFileName
02520    *   Name of output file
02521    * @param rOutFormat
02522    *   Graphics file format, eg "png", "jpg", "svg"
02523    * @param rDotExec
02524    *   path/name of executable
02525    * @exception Exception
02526    *   - IO errors (id 2)
02527    *   - error during systemcall for dot (id 3)
02528    */
02529   void GraphWrite(const std::string& rFileName, const std::string& rOutFormat="", 
02530     const std::string& rDotExec="dot") const;
02531 
02532   /** 
02533    * Order for sorting containers of generators 
02534    */
02535   bool operator < (const vGenerator& rOtherGen) const {
02536     return (mId < rOtherGen.mId);
02537   }
02538 
02539  
02540   /** @} doxygen group */
02541 
02542 
02543  protected:
02544 
02545   /** Name of generator */
02546   std::string mMyName;
02547 
02548   /** Number of generator */
02549   Idx mId;
02550 
02551   /** Number of generator objects */
02552   static Idx msObjectCount;
02553 
02554   /** State symbol table (local per Generator)*/
02555   SymbolTable mStateSymbolTable;
02556 
02557   /** Pointer to State symbol table */
02558   SymbolTable* mpStateSymbolTable;
02559 
02560   /** Pointer to Event symbol table */
02561   SymbolTable* mpEventSymbolTable;
02562 
02563   /** Automatic state names */
02564   bool mStateNamesEnabled;
02565   
02566   /** Default for automatic statenames */
02567   static bool msStateNamesEnabledDefault;
02568 
02569   /** Pointer to alphabet (actual type depends on attributes) */
02570   EventSet* mpAlphabet;
02571 
02572   /** Pointer to state set (actual type depends on attributes) */
02573   StateSet* mpStates;
02574 
02575   /** Pointer to ransition relation (actual type depends on attributes) */
02576   TransSet* mpTransRel;
02577 
02578   /** Pointer to lobal attribute (actual type depends on attributes) */
02579   AttributeVoid* mpGlobalAttribute;
02580 
02581   /** Pointer to alphabet prototype (incl. attribute type) */
02582   const EventSet* pAlphabetPrototype;
02583 
02584   /** Pointer to state set prototype (incl. attribute type) */
02585   const StateSet* pStatesPrototype;
02586 
02587   /** Pointer to transition relation prototype (incl. attribute type) */
02588   const TransSet* pTransRelPrototype;
02589 
02590   /** Pointer to global attribute prototype (configures global attribute type) */
02591   const AttributeVoid* pGlobalPrototype;
02592 
02593   /** Static default alphabet prototype (incl. attribute type) */
02594   static const EventSet msAlphabetVoid;
02595 
02596   /** Static default state set prototype (incl. attribute type) */
02597   static const StateSet msStatesVoid;
02598 
02599   /** Static default transition relation prototype (incl. attribute type) */
02600   static const TransSet msTransRelVoid;
02601 
02602   /** Static default global attribute prototype (configures global attribute type) */
02603   static const AttributeVoid msGlobalVoid;
02604 
02605   /** Initial states */
02606   StateSet mInitStates;
02607 
02608   /** Marked states */
02609   StateSet mMarkedStates;
02610 
02611   /** Map State indices to consecutive indices */
02612   std::map<Idx,Idx> mMinStateIndexMap;
02613 
02614   /** Allocate my heap members (attribute dependent types) */
02615   virtual void NewCore(void);
02616   
02617   /** Free my heap members (attribute dependent types) */
02618   virtual void DeleteCore(void);
02619 
02620   /** Callback for core update */
02621   virtual void UpdateCore(void);
02622 
02623   /** Configure attribute types */
02624   void ConfigureAttributeTypes(const AttributeVoid* pNewGlobalPrototype, 
02625     const StateSet* pNewStatesPrototype, const EventSet* pNewAlphabetPrototype, 
02626     const TransSet* pNewTransRelPrototype);
02627 
02628   /**
02629    * Read generator object from TokenReader, see Type::Read for public wrappers.
02630    *
02631    * Virtual function for std token io interface. Context is ignored,
02632    * label defaults to "Generator".
02633    *
02634    * @param rTr
02635    *   TokenReader to read from
02636    * @param rLabel
02637    *   Section to read
02638    * @param pContext
02639    *   Read context to provide contextual information (ignored)
02640    *
02641    * @exception Exception
02642    *   - token mismatch (id 50, 51, 52, 80, 85)
02643    *   - IO error (id 1)
02644    */
02645   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
02646  
02647   /**
02648    * Write generator to TokenWriter, see Type::Write for public wrappers.
02649    *
02650    * Virtual function for std token io interface. Context is ignored,
02651    * label defaults to "Generator". If the tokenwriter writes to a file,
02652    * state indices will be re-indext to start from 1.
02653    *
02654    * @param rTw
02655    *   Reference to TokenWriter
02656    * @param rLabel
02657    *   Label of section to write
02658    * @param pContext
02659    *   Write context to provide contextual information (ignored)
02660    *
02661    * @exception Exception 
02662    *   - IO errors (id 2)
02663    */
02664   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
02665 
02666   /**
02667    * Write generator in debugging format to TokenWriter, see Type::DWrite for public wrappers.
02668    *
02669    * Reimplement this method in derived classes to provide the std token io
02670    * interface defined in the public section of Type.
02671    *
02672    * @param rTw
02673    *   Reference to TokenWriter
02674    * @param rLabel
02675    *   Label of section to write
02676    * @param pContext
02677    *   Write context to provide contextual information (ignored)
02678    *
02679    * @exception Exception 
02680    *   - IO errors (id 2)
02681    */
02682   virtual void DoDWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
02683 
02684   /**
02685    * Write generator statistics as comment to TokenWriter, see Type::SWrite for public wrappers.
02686    *
02687    * Reimplement this method in derived classes to provide the std token io
02688    * interface defined in the public section of Type.
02689    *
02690    * @param rTw
02691    *   Reference to TokenWriter
02692    *
02693    * @exception Exception 
02694    *   - IO errors (id 2)
02695    */
02696   virtual void DoSWrite(TokenWriter& rTw) const;
02697 
02698   /**
02699    * Read the generator's name from a file
02700    * 
02701    * @param rFileName
02702    *   File to read from
02703    *
02704    * @exception Exception
02705    *   - IO errors (id 1)
02706    *   - token mismatch (id 50, 51, 52)
02707    */
02708   void ReadGeneratorName(const std::string& rFileName);
02709 
02710   /**
02711    * Read the generator's name from a TokenReader
02712    * 
02713    * @param rTr
02714    *   Reference to TokenReader
02715    *
02716    * @exception Exception
02717    *   - IO errors (id 1)
02718    *   - token mismatch (id 50, 51, 52)
02719    */
02720   void ReadGeneratorName(TokenReader& rTr);
02721 
02722   /**
02723    * Read the generator's alphabet from a file.
02724    *
02725    * @param rFileName
02726    *   File to read from
02727    *
02728    * @exception Exception
02729    *   - IO errors (id 1)
02730    *   - token mismatch (id 50, 51, 52)
02731    */
02732   void ReadAlphabet(const std::string& rFileName);
02733 
02734   /**
02735    * Read the generator's alphabet from a TokenReader
02736    *
02737    * @param rTr
02738    *   Reference to TokenReader
02739    *
02740    * @exception Exception
02741    *   - IO errors (id 1)
02742    *   - token mismatch (id 50, 51, 52)
02743    */
02744   void ReadAlphabet(TokenReader& rTr);
02745 
02746   /**
02747    * Read the generator's state set from a file. 
02748    * This sets up the StateSymbolTable.
02749    *
02750    * @param rFileName
02751    *   File to read from
02752    *
02753    * @exception Exception
02754    *   - IO errors (id 1)
02755    *   - token mismatch (id 50, 51, 52)
02756    */
02757   void ReadStates(const std::string& rFileName);
02758 
02759   /**
02760    * Read the generator's stateset from a TokenReader. 
02761    * This sets up the StateSymbolTable
02762    *
02763    * @param rTr
02764    *   Reference to TokenReader
02765    *
02766    * @exception Exception
02767    *   - IO errors (id 1)
02768    *   - token mismatch (id 50, 51, 52)
02769    */
02770   void ReadStates(TokenReader& rTr);
02771 
02772   /**
02773    * Read the generator's transition relation from a file. 
02774    *
02775    * @param rFileName
02776    *   File to read from
02777    *
02778    * @exception Exception
02779    *   - IO errors (id 1)
02780    *   - token mismatch (id 50, 51, 52)
02781    */
02782   void ReadTransRel(const std::string& rFileName);
02783 
02784   /**
02785    * Read the generator's transition relation from a TokenReader. 
02786    *
02787    * @param rTr
02788    *   Reference to TokenReader
02789    *
02790    * @exception Exception
02791    *   - IO errors (id 1)
02792    *   - token mismatch (id 50, 51, 52)
02793    */
02794   void ReadTransRel(TokenReader& rTr);
02795 
02796   /**
02797    * Get accessible states by filling accessibleset recursive
02798    *
02799    * @param accessibleset
02800    *   Reference to StateSet with accessibel states
02801    * @param startState
02802    *   State index to start with
02803    */
02804   void CheckAccessible(StateSet& accessibleset, Idx startState) const;
02805 
02806   /**
02807    * Get Coaccessible states by filling Coaccessibleset recursive
02808    *
02809    * @param Coaccessibleset
02810    *   Reference to StateSet with coaccessibel states
02811    * @param rtrel
02812    *   Reverse transition relation where x1 <-> x2
02813    * @param startState
02814    *   State index to start with
02815    */
02816   void CheckCoaccessible(StateSet& Coaccessibleset, const TransSetX2EvX1& rtrel, Idx startState) const;
02817 
02818 
02819 };
02820 
02821 /** 
02822  * Plain generator, api typedef for generator with no attributes. 
02823  * \ingroup GeneratorClasses
02824  */
02825 typedef vGenerator Generator; 
02826 
02827 /** Convenience typedef for generator vectors
02828  * \ingroup GeneratorClasses
02829  */
02830 typedef  TBaseVector<Generator> GeneratorVector;  
02831 
02832 
02833 /** 
02834  * RTI wrapper function. See also vGenerator::IsAccessible().
02835  * \ingroup GeneratorFunctions
02836  */
02837 void IsAccessible(const vGenerator& rGen, bool& rRes);
02838 
02839 /** 
02840  * RTI wrapper function. See also vGenerator::IsCoaccessible().
02841  * \ingroup GeneratorFunctions
02842  */
02843 void IsCoaccessible(const vGenerator& rGen, bool& rRes);
02844 
02845 /** 
02846  * RTI wrapper function. See also vGenerator::IsTrim().
02847  * \ingroup GeneratorFunctions
02848  */
02849 void IsTrim(const vGenerator& rGen, bool& rRes);
02850 
02851 /** 
02852  * RTI wrapper function. See also vGenerator::IsComplete().
02853  * \ingroup GeneratorFunctions
02854  */
02855 void IsComplete(const vGenerator& rGen, bool& rRes);
02856 
02857 /** 
02858  * RTI wrapper function. See also vGenerator::IsDeterministic().
02859  * \ingroup GeneratorFunctions
02860  */
02861 void IsDeterministic(const vGenerator& rGen, bool& rRes);
02862 
02863 
02864 /** 
02865  * RTI wrapper function. See also vGenerator::Accessible().
02866  * \ingroup GeneratorFunctions
02867  */
02868 void Accessible(vGenerator& rGen);
02869 
02870 /** 
02871  * RTI wrapper function. See also vGenerator::Accessible().
02872  * \ingroup GeneratorFunctions
02873  */
02874 void Accessible(const vGenerator& rGen, vGenerator& rRes);
02875 
02876 /** 
02877  * RTI wrapper function. See also vGenerator::Coaccessible().
02878  * \ingroup GeneratorFunctions 
02879  */
02880 void Coaccessible(vGenerator& rGen);
02881 
02882 /** 
02883  * RTI wrapper function. See also vGenerator::Coaccessible().
02884  * \ingroup GeneratorFunctions
02885  */
02886 void Coaccessible(const vGenerator& rGen, vGenerator& rRes);
02887 
02888 /** 
02889  * RTI wrapper function. See also vGenerator::Trim().
02890  * \ingroup GeneratorFunctions
02891  */
02892 void Trim(vGenerator& rGen);
02893 
02894 /** 
02895  * RTI wrapper function. See also vGenerator::Trim().
02896  * \ingroup GeneratorFunctions
02897  */
02898 void Trim(const vGenerator& rGen, vGenerator& rRes);
02899 
02900 /** 
02901  * RTI wrapper function. 
02902  * \ingroup GeneratorFunctions
02903  */
02904 void MarkAllStates(vGenerator& rGen);
02905 
02906 
02907 } // namespace faudes
02908 
02909 /*
02910 
02911 #define FAUDES_GENERATOR_DECLARATION(gtype,GlobalAttr,StateAttr,EventAttr,TransAttr) \
02912   public:                                                                     \
02913   virtual void EventAttribute(Idx index, const EventAttr& rAttr);             \
02914   virtual void EventAttributes(const TaEventSet<EventAttr>& rEventSet);       \
02915   virtual const EventAttr& EventAttribute(Idx index) const;                   \
02916   virtual const EventAttr& EventAttribute(const std::string& rName) const;    \
02917   virtual EventAttr* EventAttributep(Idx index);                              \
02918   virtual EventAttr* EventAttributep(const std::string& rName);               \
02919   virtual void StateAttribute(Idx index, const StateAttr& rAttr);             \
02920   virtual const StateAttr& StateAttribute(Idx index) const;                   \
02921   virtual StateAttr* StateAttributep(Idx index);                              \
02922   virtual void TransAttribute(const Transition& rTrans, const TransAttr& rAttr); \
02923   virtual const TransAttr& TransAttribute(const Transition& rTrans) const;     \
02924   virtual TransAttr* TransAttributep(const Transition& rTrans);               \
02925   virtual void GlobalAttribute(const GlobalAttr& rAttr);                      \
02926   virtual void GlobalAttributeTry(const Type& rAttr);                         \
02927   virtual const GlobalAttr& GlobalAttribute(void) const;                      \
02928   virtual GlobalAttr* GlobalAttributep(void);                       
02929 
02930 #define FAUDES_GENERATOR_IMPLEMENTATION(gtype,GlobalAttr,StateAttr,EventAttr,TransAttr) \
02931   public:                                                                     \
02932   virtual void EventAttribute(Idx index, const EventAttr& rAttr);             \
02933   virtual void EventAttributes(const TaEventSet<EventAttr>& rEventSet);       \
02934   virtual const EventAttr& EventAttribute(Idx index) const;                   \
02935   virtual const EventAttr& EventAttribute(const std::string& rName) const;    \
02936   virtual EventAttr* EventAttributep(Idx index);                              \
02937   virtual EventAttr* EventAttributep(const std::string& rName);               \
02938   virtual void StateAttribute(Idx index, const StateAttr& rAttr);             \
02939   virtual const StateAttr& StateAttribute(Idx index) const;                   \
02940   virtual StateAttr* StateAttributep(Idx index);                              \
02941   virtual void TransAttribute(const Transition& rTrans, const TransAttr& rAttr); \
02942   virtual const TransAttr& TransAttribute(const Transition& rTrans) const;     \
02943   virtual TransAttr* TransAttributep(const Transition& rTrans);               \
02944   virtual void GlobalAttribute(const GlobalAttr& rAttr);                      \
02945   virtual void GlobalAttributeTry(const Type& rAttr);                         \
02946   virtual const GlobalAttr& GlobalAttribute(void) const;                      \
02947   virtual GlobalAttr* GlobalAttributep(void);                       
02948 
02949 */
02950 
02951 
02952 #endif
02953 

libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6