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