00001 #ifndef wali_nwa_TransitionStorage_GUARD 00002 #define wali_nwa_TransitionStorage_GUARD 1 00003 00004 /** 00005 * @author Amanda Burton 00006 */ 00007 00008 #include "opennwa/NwaFwd.hpp" 00009 00010 // ::wali 00011 #include "wali/Printable.hpp" 00012 #include "wali/Key.hpp" 00013 #include "wali/KeyContainer.hpp" 00014 #include "opennwa/details/StateStorage.hpp" 00015 #include "opennwa/details/TransitionInfo.hpp" 00016 00017 // std::c++ 00018 #include <iostream> 00019 #include <set> 00020 #include <assert.h> 00021 00022 namespace opennwa 00023 { 00024 namespace details 00025 { 00026 00027 /** 00028 * 00029 * This class is used to keep track of the transitions of an NWA. 00030 * 00031 */ 00032 class TransitionStorage : public wali::Printable 00033 { 00034 public: 00035 typedef std::set<State> States; 00036 00037 DEPRECATE("Use (captial-S) StateIterator, not that you should be using this one anyway") 00038 typedef States::const_iterator stateIterator; 00039 typedef States::const_iterator StateIterator; 00040 00041 typedef TransitionInfo::Call Call; 00042 typedef TransitionInfo::Internal Internal; 00043 typedef TransitionInfo::Return Return; 00044 00045 typedef TransitionInfo::Calls Calls; 00046 typedef TransitionInfo::Internals Internals; 00047 typedef TransitionInfo::Returns Returns; 00048 00049 DEPRECATE("Use capitalized version (CallIterator) instead. (Not that you should be using it from TransitionStorage in the first place.)") 00050 typedef Calls::const_iterator callIterator; 00051 DEPRECATE("Use capitalized version (InternalIterator) instead. (Not that you should be using it from TransitionStorage in the first place.)") 00052 typedef Internals::const_iterator internalIterator; 00053 DEPRECATE("Use capitalized version (ReturnIterator) instead. (Not that you should be using it from TransitionStorage in the first place.)") 00054 typedef Returns::const_iterator returnIterator; 00055 00056 typedef Calls::const_iterator CallIterator; 00057 typedef Internals::const_iterator InternalIterator; 00058 typedef Returns::const_iterator ReturnIterator; 00059 00060 // The following macro fakes static data declarations with 00061 // initializers in a template class to work around C++ being 00062 // dumb. Static data in a template class is almost useless 00063 // because you have to explicitly define it for every 00064 // instantiation. Instead, make a static member function that 00065 // returns the value. (In this case, it's stored as a 00066 // function-static variable, but this is somewhat irrelevant. 00067 #define DEFINE_FAKE_STATIC_DATA(name, value) \ 00068 static std::string const & name() { \ 00069 static std::string ret = value; \ 00070 return ret; \ 00071 } 00072 00073 DEFINE_FAKE_STATIC_DATA(XMLFromAttr, "from"); 00074 DEFINE_FAKE_STATIC_DATA(XMLPredAttr, "call"); 00075 DEFINE_FAKE_STATIC_DATA(XMLSymbolAttr, "symbol"); 00076 DEFINE_FAKE_STATIC_DATA(XMLToAttr, "to"); 00077 00078 DEFINE_FAKE_STATIC_DATA(InternalXMLTag, "InternalTrans"); 00079 DEFINE_FAKE_STATIC_DATA(CallXMLTag, "CallTrans"); 00080 DEFINE_FAKE_STATIC_DATA(ReturnXMLTag, "ReturnTrans"); 00081 00082 #undef DEFINE_FAKE_STATIC_DATA 00083 00084 typedef TransitionInfo Info; 00085 00086 // 00087 // Methods 00088 // 00089 00090 public: 00091 00092 //Constructors and Destructor 00093 TransitionStorage & operator=( const TransitionStorage & other ); 00094 00095 00096 //Component Accessors 00097 00098 /** 00099 * 00100 * @brief access the call site of the given call transition 00101 * 00102 * This method provides access to the call site of the given call transition. 00103 * 00104 * @param - callTrans: the call transition whose call site to access 00105 * @return the call site of the given call transition 00106 * 00107 */ 00108 inline 00109 static State getCallSite( const Call & callTrans ) 00110 { 00111 return callTrans.first; 00112 } 00113 00114 /** 00115 * 00116 * @brief access the symbol of the given call transition 00117 * 00118 * This method provides access to the symbol of the given call transition. 00119 * 00120 * @param - callTrans: the call transition whose symbol to access 00121 * @return the symbol of the given call transition 00122 * 00123 */ 00124 inline 00125 static Symbol getCallSym( const Call & callTrans ) 00126 { 00127 return callTrans.second; 00128 } 00129 00130 /** 00131 * 00132 * @brief access the entry point of the given call transition 00133 * 00134 * This method provides access to the entry point of the given call transition. 00135 * 00136 * @param - callTrans: the call transition whose entry point to access 00137 * @return the entry point of the given call transition 00138 * 00139 */ 00140 inline 00141 static State getEntry( const Call & callTrans ) 00142 { 00143 return callTrans.third; 00144 } 00145 00146 /** 00147 * 00148 * @brief access the source of the given internal transition 00149 * 00150 * This method provides access to the source of the given internal transition. 00151 * 00152 * @param - internalTrans: the internal transition whose source to access 00153 * @return the source of the given internal transition 00154 * 00155 */ 00156 inline 00157 static State getSource( const Internal & internalTrans ) 00158 { 00159 return internalTrans.first; 00160 } 00161 00162 /** 00163 * 00164 * @brief access the symbol of the given internal transition 00165 * 00166 * This method provides access to the symbol of the given internal transition. 00167 * 00168 * @param - internalTrans: the internal transition whose symbol to access 00169 * @return the symbol of the given internal transition 00170 * 00171 */ 00172 inline 00173 static Symbol getInternalSym( const Internal & internalTrans ) 00174 { 00175 return internalTrans.second; 00176 } 00177 00178 /** 00179 * 00180 * @brief access the target of the given internal transition 00181 * 00182 * This method provides access to the target of the given internal transition. 00183 * 00184 * @param - internalTrans: the internal transition whose target to access 00185 * @return the target of the given internal transition 00186 * 00187 */ 00188 inline 00189 static State getTarget( const Internal & internalTrans ) 00190 { 00191 return internalTrans.third; 00192 } 00193 00194 /** 00195 * 00196 * @brief access the exit point of the given return transition 00197 * 00198 * This method provides access to the exit point of the given return transition. 00199 * 00200 * @param - returnTrans: the return transition whose exit point to access 00201 * @return the exit point of the given return transition 00202 * 00203 */ 00204 inline 00205 static State getExit( const Return & returnTrans ) 00206 { 00207 return returnTrans.first; 00208 } 00209 00210 /** 00211 * 00212 * @brief access the call site of the given return transition 00213 * 00214 * This method provides access to the call site of the given return transition. 00215 * 00216 * @param - returnTrans: the return transition whose call site to access 00217 * @return the call site of the given return transition 00218 * 00219 */ 00220 inline 00221 static State getCallSite( const Return & returnTrans ) 00222 { 00223 return returnTrans.second; 00224 } 00225 00226 /** 00227 * 00228 * @brief access the symbol of the given return transition 00229 * 00230 * This method provides access to the symbol of the given return transition. 00231 * 00232 * @param - returnTrans: the return transition whose symbol to access 00233 * @return the symbol of the given return transition 00234 * 00235 */ 00236 inline 00237 static Symbol getReturnSym( const Return & returnTrans ) 00238 { 00239 return returnTrans.third; 00240 } 00241 00242 /** 00243 * 00244 * @brief access the return site of the given return transition 00245 * 00246 * This method provides access to the return site of the given return transition. 00247 * 00248 * @param - returnTrans: the return transition whose return site to access 00249 * @return the return site of the given return transition 00250 * 00251 */ 00252 inline 00253 static State getReturnSite( const Return & returnTrans ) 00254 { 00255 return returnTrans.fourth; 00256 } 00257 00258 #ifdef LABEL 00259 /** 00260 * 00261 * @brief access the call site of the given call transition 00262 * 00263 * This method provides access to the call site of the given call transition. 00264 * 00265 * @param - callTrans: the call transition whose call site to access 00266 * @return the call site of the given call transition 00267 * 00268 */ 00269 inline 00270 static St getCallSite( const Info::Cal & callTrans ) 00271 { 00272 return callTrans.first; 00273 } 00274 00275 /** 00276 * 00277 * @brief access the symbol of the given call transition 00278 * 00279 * This method provides access to the symbol of the given call transition. 00280 * 00281 * @param - callTrans: the call transition whose symbol to access 00282 * @return the symbol of the given call transition 00283 * 00284 */ 00285 inline 00286 static Sym getCallSym( const Info::Cal & callTrans ) 00287 { 00288 return (callTrans.second).getAnySymbol(); 00289 } 00290 00291 /** 00292 * 00293 * @brief access the symbols of the given call transition 00294 * 00295 * This method provides access to the symbols of the given call transition. 00296 * 00297 * @param - callTrans: the call transition whose symbols to access 00298 * @return the symbols of the given call transition 00299 * 00300 */ 00301 inline 00302 static Label getCallLabel( const Info::Cal & callTrans ) 00303 { 00304 return callTrans.second; 00305 } 00306 00307 /** 00308 * 00309 * @brief access the entry point of the given call transition 00310 * 00311 * This method provides access to the entry point of the given call transition. 00312 * 00313 * @param - callTrans: the call transition whose entry point to access 00314 * @return the entry point of the given call transition 00315 * 00316 */ 00317 inline 00318 static St getEntry( const Info::Cal & callTrans ) 00319 { 00320 return callTrans.third; 00321 } 00322 00323 /** 00324 * 00325 * @brief access the source of the given internal transition 00326 * 00327 * This method provides access to the source of the given internal transition. 00328 * 00329 * @param - internalTrans: the internal transition whose source to access 00330 * @return the source of the given internal transition 00331 * 00332 */ 00333 inline 00334 static St getSource( const Info::Int & internalTrans ) 00335 { 00336 return internalTrans.first; 00337 } 00338 00339 /** 00340 * 00341 * @brief access the symbol of the given internal transition 00342 * 00343 * This method provides access to the symbol of the given internal transition. 00344 * 00345 * @param - internalTrans: the internal transition whose symbol to access 00346 * @return the symbol of the given internal transition 00347 * 00348 */ 00349 inline 00350 static Sym getInternalSym( const Info::Int & internalTrans ) 00351 { 00352 return (internalTrans.second).getAnySymbol(); 00353 } 00354 00355 /** 00356 * 00357 * @brief access the symbols of the given internal transition 00358 * 00359 * This method provides access to the symbols of the given internal transition. 00360 * 00361 * @param - internalTrans: the internal transition whose symbols to access 00362 * @return the symbols of the given internal transition 00363 * 00364 */ 00365 inline 00366 static Label getInternalLabel( const Info::Int & internalTrans ) 00367 { 00368 return internalTrans.second; 00369 } 00370 00371 /** 00372 * 00373 * @brief access the target of the given internal transition 00374 * 00375 * This method provides access to the target of the given internal transition. 00376 * 00377 * @param - internalTrans: the internal transition whose target to access 00378 * @return the target of the given internal transition 00379 * 00380 */ 00381 inline 00382 static St getTarget( const Info::Int & internalTrans ) 00383 { 00384 return internalTrans.third; 00385 } 00386 00387 /** 00388 * 00389 * @brief access the exit point of the given return transition 00390 * 00391 * This method provides access to the exit point of the given return transition. 00392 * 00393 * @param - returnTrans: the return transition whose exit point to access 00394 * @return the exit point of the given return transition 00395 * 00396 */ 00397 inline 00398 static St getExit( const Info::Ret & returnTrans ) 00399 { 00400 return returnTrans.first; 00401 } 00402 00403 /** 00404 * 00405 * @brief access the call site of the given return transition 00406 * 00407 * This method provides access to the call site of the given return transition. 00408 * 00409 * @param - returnTrans: the return transition whose call site to access 00410 * @return the call site of the given return transition 00411 * 00412 */ 00413 inline 00414 static St getCallSite( const Info::Ret & returnTrans ) 00415 { 00416 return returnTrans.second; 00417 } 00418 00419 /** 00420 * 00421 * @brief access the symbol of the given return transition 00422 * 00423 * This method provides access to the symbol of the given return transition. 00424 * 00425 * @param - returnTrans: the return transition whose symbol to access 00426 * @return the symbol of the given return transition 00427 * 00428 */ 00429 inline 00430 static Sym getReturnSym( const Info::Ret & returnTrans ) 00431 { 00432 return (returnTrans.third).getAnySymbol(); 00433 } 00434 00435 /** 00436 * 00437 * @brief access the symbol of the given return transition 00438 * 00439 * This method provides access to the symbol of the given return transition. 00440 * 00441 * @param - returnTrans: the return transition whose symbol to access 00442 * @return the symbol of the given return transition 00443 * 00444 */ 00445 inline 00446 static Label getReturnLabel( const Info::Ret & returnTrans ) 00447 { 00448 return returnTrans.third; 00449 } 00450 00451 /** 00452 * 00453 * @brief access the return site of the given return transition 00454 * 00455 * This method provides access to the return site of the given return transition. 00456 * 00457 * @param - returnTrans: the return transition whose return site to access 00458 * @return the return site of the given return transition 00459 * 00460 */ 00461 inline 00462 static St getReturnSite( const Info::Ret & returnTrans ) 00463 { 00464 return returnTrans.fourth; 00465 } 00466 #endif 00467 00468 //Transition Accessors 00469 00470 /** 00471 * 00472 * @brief finds the symbol on any transition whose source is 'from' and 00473 * whose target is 'to' 00474 * 00475 * This method return the symbol on any transition whose source is 'from' 00476 * and whose target is 'to'. 00477 * 00478 * @param - from: the source of the transition 00479 * @param - to: the target of the transition 00480 * @return true if there exists some transition with the given source and 00481 * target, false otherwise 00482 * 00483 */ 00484 bool getSymbol( State from, State to, Symbol & sym ) const; 00485 00486 /** 00487 * 00488 * @brief tests whether there exists a transition whose source is 'from', 00489 * whose symbol is 'sym', and whose target is 'to' 00490 * 00491 * This method determines whether there exists a transition (internal, call, 00492 * or return) whose source is 'from', whose symbol is 'sym', and whose target 00493 * is 'to'. 00494 * 00495 * @param - from: the source of the transition 00496 * @param - sym: the symbol that labels the transition 00497 * @param - to: the target of the transition 00498 * @return true if such a transition exists, false otherwise 00499 * 00500 */ 00501 bool findTrans( State from, Symbol sym, State to ) const; 00502 00503 /** 00504 * 00505 * @brief returns all return sites that correspond with the given call site 00506 * 00507 * This method returns the set of all return sites that correspond with the 00508 * given call site. 00509 * 00510 * @param - callSite: the call site whose return sites to look for 00511 * @return the set of all return sites that correspond with the given call site 00512 * 00513 */ 00514 const States getReturnSites( State callSite ) const; 00515 00516 /** 00517 * 00518 * @brief returns all return sites that correspond with the given exit and call site 00519 * 00520 * This method returns the set of all return sites that correspond with the 00521 * given exit and call site. 00522 * 00523 * @param - exit: the exit whose return sites to look for 00524 * @param - callSite: the call site whose return sites to look for 00525 * @return the set of all return sites that correspond with the given exit and call site 00526 * 00527 */ 00528 States getReturnSites( State exit, State callSite ) const; 00529 00530 /** 00531 * 00532 * @brief returns all call sites that correspond with the given exit - return site pair 00533 * 00534 * This method returns the set of all call sites that correspond with the given 00535 * exit - return site pair. 00536 * 00537 * @param - exitSite: the exit of the pair whose call sites to look for 00538 * @param = returnSite: the return site of the pair whose call sites to look for 00539 * @return the set of all call sites that correspond with the exit - return site pair 00540 * 00541 */ 00542 const States getCallSites( State exitSite, State returnSite ) const; 00543 00544 /** 00545 * 00546 * @brief returns all entry sites that correspond with the given call site 00547 * 00548 * This method returns the set of all entry sites that correspond with the 00549 * given call site. 00550 * 00551 * @param - callSite: the call site whose entry sites to look for 00552 * @return the set of all entry sites that correspond with the given call site 00553 * 00554 */ 00555 const States getEntries( State callSite ) const; 00556 00557 /** 00558 * 00559 * @brief returns all targets that correspond with the given source 00560 * 00561 * This method returns the set of all targets that correspond with the 00562 * given source . 00563 * 00564 * @param - source: the source whose targets to look for 00565 * @return the set of all targets that correspond with the given source 00566 * 00567 */ 00568 const States getTargets( State source ) const; 00569 00570 /** 00571 * 00572 * @brief creates transitions for 'dup' mirroring 'orig' outgoing transitions 00573 * 00574 * This method creates a transition using 'dup' in the place of 'orig' for 00575 * each outgoing transition involving 'orig'. Do not duplicate selfloops. 00576 * 00577 * @param - orig: the state that is being duplicated 00578 * @param - dup: the state that is duplicating 'orig' 00579 * 00580 */ 00581 void dupTransOutgoing( State orig, State dup ); 00582 00583 /** 00584 * 00585 * @brief creates transitions for 'dup' mirroring 'orig' transitions 00586 * 00587 * This method creates a transition using 'dup' in the place of 'orig' for 00588 * each transition involving 'orig'. In addition, for any transition involving a 00589 * self-loop on 'orig', two(three in the case of a return transition with exit, 00590 * pred, and ret all 'orig') transitions are added (using 'dup' for 'orig' in each 00591 * position while retaining 'orig' in all other positions). 00592 * 00593 * @param - orig: the state that is being duplicated 00594 * @param - dup: the state that is duplicating 'orig' 00595 * 00596 */ 00597 void dupTrans( State orig, State dup ); 00598 00599 /** 00600 * 00601 * @brief removes all transitions from this collection of transitions 00602 * 00603 * This method removes all transitions from this collection of transitions. 00604 * 00605 */ 00606 void clear( ); 00607 00608 /** 00609 * 00610 * @brief get all call transitions in this collection of transitions 00611 * 00612 * This method provides access to all call transitions in this collection of 00613 * transitions. 00614 * 00615 * @return all call transitions in this collection of transitions 00616 * 00617 */ 00618 const Calls & getCalls() const; 00619 00620 /** 00621 * 00622 * @brief get all internal transitions in this collection of transitions 00623 * 00624 * This method provides access to all internal transitions in this collection 00625 * of transitions. 00626 * 00627 * @return all internal transitions in the collection of transitions 00628 * 00629 */ 00630 const Internals & getInternals() const; 00631 00632 /** 00633 * 00634 * @brief get all return transitions in the collection of transitions 00635 * 00636 * This method provides access to all return transitions in the collection 00637 * of transitions associated with the NWA. 00638 * 00639 * @return all return transitions in the collection of transitions 00640 * 00641 */ 00642 const Returns & getReturns() const; 00643 00644 /** 00645 * 00646 * @brief add a call transition to the NWA 00647 * 00648 * This method creates a call transition with the given edge and label information 00649 * and adds it to the transition set for the NWA. If the call transition already 00650 * exists in the NWA, false is returned. Otherwise, true is returned. 00651 * 00652 * @param - from: the state the edge departs from 00653 * @param - sym: the symbol labeling the edge 00654 * @param - to: the state the edge arrives to 00655 * @return false if the call transition already exists in the NWA 00656 * 00657 */ 00658 bool addCall( State from, Symbol sym, State to ); 00659 00660 /** 00661 * 00662 * @brief add the given call transition to the collection of transitions 00663 * 00664 * This method adds the given call transition to this collection of 00665 * transitions. If this exact call transition already exists, false is 00666 * returned. Otherwise, true is returned. 00667 * 00668 * @param - addTrans: the call transition to add to the collection of transitions 00669 * @return false if the call transition already exists in the collection 00670 * 00671 */ 00672 bool addCall( const Call & addTrans ); 00673 00674 /** 00675 * 00676 * @brief add an internal transition to the NWA 00677 * 00678 * This method creates an internal transition with the given edge and label 00679 * information and adds it to the transition set for the NWA. If the internal 00680 * transition already exists in the NWA, false is returned. Otherwise, true is 00681 * returned. 00682 * 00683 * @param - from: the state the edge departs from 00684 * @param - sym: the symbol labeling the edge 00685 * @param - to: the state the edge arrives to 00686 * @return false if the internal transition already exists in the NWA 00687 * 00688 */ 00689 bool addInternal( State from, Symbol sym, State to ); 00690 00691 /** 00692 * 00693 * @brief add the given internal transition to the collection of transitions 00694 * 00695 * This method adds the given internal transition to the collection of 00696 * transitions. If this exact internal transition already exists, false is 00697 * returned. Otherwise, true is returned. 00698 * 00699 * @param - addTrans: the internal transition to add to the collection of transitions 00700 * @return false if the internal transition already exists in the collection 00701 * 00702 */ 00703 bool addInternal( const Internal & addTrans ); 00704 00705 /** 00706 * 00707 * @brief add a return transition to the NWA 00708 * 00709 * This method creates a return transition with the given edge and label information 00710 * and adds it to the transition set for the NWA. If the return transition already 00711 * exists in the NWA, false is returned. Otherwise, true is returned. 00712 * 00713 * @param - from: the state the edge departs from 00714 * @param - pred: the state from which the call was initiated 00715 * @param - sym: the symbol labeling the edge 00716 * @param - to: the state the edge arrives to 00717 * @return false if the return transition already exists in the NWA 00718 * 00719 */ 00720 bool addReturn( State from, State pred, Symbol sym, State to ); 00721 00722 /** 00723 * 00724 * @brief add the given return transition to the collection of transitions 00725 * 00726 * This method adds the given return transition to the collection of 00727 * transitions. If this exact return transition already exists, false is 00728 * returned. Otherwise, true is returned. 00729 * 00730 * @param - addTrans: the return transition to add to the collection of transitions 00731 * @return false if the return transition already exists in the collection 00732 * 00733 */ 00734 bool addReturn( const Return & addTrans ); 00735 00736 /** 00737 * 00738 * @brief add all transitions in the given collection of transitions to this 00739 * collection of transitions 00740 * 00741 * This method adds all of the transitions in the given collection of 00742 * transitions to this collection of transitions. 00743 * 00744 * @param - addTransitionStorage: the collection of transitions to add to this 00745 * collection of transitions 00746 * 00747 */ 00748 void addAllTrans( TransitionStorage addTransitionStorage ); 00749 00750 /** 00751 * 00752 * @brief remove a call transition from the NWA 00753 * 00754 * This method checks for the call transition with the given edge and label 00755 * information in the transition set. If the transition is found, it is removed 00756 * from the transition set and true is returned. Otherwise, false is returned. 00757 * 00758 * @param - from: the state the edge departs from 00759 * @param - sym: the symbol labeling the edge 00760 * @param - to: the state the edge arrives to 00761 * @return false if the call transition does not exist in the NWA 00762 * 00763 */ 00764 bool removeCall( State from, Symbol sym, State to ); 00765 00766 /** 00767 * 00768 * @brief remove the given call transition from this collection of 00769 * transitions 00770 * 00771 * This method removes the given call transition from this collection 00772 * of transitions. If the given call transition does not exust in 00773 * this collection of transitions false is returned. Otherwise, 00774 * true is returned. 00775 * 00776 * @param - removeTrans: the call transition to remove from the collection 00777 * @return false if the given call transition does not exist in the 00778 * collection, true otherwise. 00779 * 00780 */ 00781 bool removeCall( const Call & removeTrans ); 00782 00783 /** 00784 * 00785 * @brief remove an internal transition from the NWA 00786 * 00787 * This method checks for the internal transition with the given edge and label 00788 * information in the transition set. If the transition is found, it is removed 00789 * from the transition set and true is returned. Otherwise, false is returned. 00790 * 00791 * @param - from: the state the edge departs from 00792 * @param - sym: the symbol labeling the edge 00793 * @param - to: the state the edge arrives to 00794 * @return false if the internal transition does not exist in the NWA 00795 * 00796 */ 00797 bool removeInternal( State from, Symbol sym, State to ); 00798 00799 /** 00800 * 00801 * @brief remove the given internal transition from the collection of 00802 * transitions 00803 * 00804 * This method removes the given internal transition from the collection 00805 * of transitions. If the given internal transition does not exist in 00806 * this collection of transitions false is returned. Otherwise, 00807 * true is returned. 00808 * 00809 * @param - removeTrans: the internal transition to remove from the collection 00810 * @return false if the given internal transition does not exist in the 00811 * collection, true otherwise. 00812 * 00813 */ 00814 bool removeInternal( const Internal & removeTrans ); 00815 00816 /** 00817 * 00818 * @brief remove a return transition from the NWA 00819 * 00820 * This method checks for the return transition with the given edge and label 00821 * information in the transition set. If the transition is found, it is removed 00822 * from the transition set and true is returned. Otherwise, false is returned. 00823 * 00824 * @param - from: the state the edge departs from 00825 * @param - pred: the state from which the call was initiated 00826 * @param - sym: the symbol labeling the edge 00827 * @param - to: the state the edge arrives to 00828 * @return false if the return transition does not exist in the NWA 00829 * 00830 */ 00831 bool removeReturn( State from, State pred, Symbol sym, State to ); 00832 00833 /** 00834 * 00835 * @brief remove the given return transition from the collection of 00836 * transitions 00837 * 00838 * This method removes the given return transition from the collection 00839 * of transitions. If the given return transition does not exist in 00840 * this collection of transitions false is returned. Otherwise, true 00841 * is returned. 00842 * 00843 * @param - removeTrans: the return transition to remove from the collection 00844 * @return false if the given return transition does not exist in the 00845 * collection, true otherwise. 00846 * 00847 */ 00848 bool removeReturn( const Return & removeTrans ); 00849 00850 /** 00851 * 00852 * @brief test whether the given call transition is in this collection of 00853 * transitions 00854 * 00855 * This method tests whether the given call transition is in this collection 00856 * of transitions. 00857 * 00858 * @param - from: the state the edge departs from 00859 * @param - sym: the symbol labeling the edge 00860 * @param - to: the state the edge arrives to 00861 * @return true if the given call transition is in this collection of 00862 * transitions 00863 * 00864 */ 00865 bool isCall( State from, Symbol sym, State to ) const; 00866 00867 /** 00868 * 00869 * @brief test whether the given call transition is in this collection of 00870 * transitions 00871 * 00872 * This method tests whether the given call transition is in this collection 00873 * of transitions. 00874 * 00875 * @param - trans: the call transition to check 00876 * @return true if the given call transition is in this collection of 00877 * transitions 00878 * 00879 */ 00880 bool isCall( const Call & trans ) const; 00881 00882 /** 00883 * 00884 * @brief test whether the given internal transition is in this collection of 00885 * transitions 00886 * 00887 * This method tests whether the given internal transition is in this 00888 * collection of transitions. 00889 * 00890 * @param - from: the state the edge departs from 00891 * @param - sym: the symbol labeling the edge 00892 * @param - to: the state the edge arrives to 00893 * @return true if the given internal transition is in this collection of 00894 * transitions associated with the NWA 00895 * 00896 */ 00897 bool isInternal( State from, Symbol sym, State to ) const; 00898 00899 /** 00900 * 00901 * @brief test whether the given internal transition is in this collection of 00902 * transitions 00903 * 00904 * This method tests whether the given internal transition is in this 00905 * collection of transitions. 00906 * 00907 * @param - trans: the internal transition to check 00908 * @return true if the given internal transition is in this collection of 00909 * transitions associated with the NWA 00910 * 00911 */ 00912 bool isInternal( const Internal & trans ) const; 00913 00914 /** 00915 * 00916 * @brief test whether the given return transition is in this collection of 00917 * transitions 00918 * 00919 * This method tests whether the given return transition is in this 00920 * collection of transitions. 00921 * 00922 * @param - from: the state the edge departs from 00923 * @param - pred: the state from which the call was initiated 00924 * @param - sym: the symbol labeling the edge 00925 * @param - to: the state the edge arrives to 00926 * @return true if the given return transition is in this collection of 00927 * transitions 00928 * 00929 */ 00930 bool isReturn( State from, State pred, Symbol sym, State to ) const; 00931 00932 /** 00933 * 00934 * @brief test whether the given return transition is in this collection of 00935 * transitions 00936 * 00937 * This method tests whether the given return transition is in this 00938 * collection of transitions. 00939 * 00940 * @param - trans: the return transition to check 00941 * @return true if the given return transition is in this collection of 00942 * transitions 00943 * 00944 */ 00945 bool isReturn( const Return & trans ) const; 00946 00947 00948 //Utilities 00949 00950 /** 00951 * 00952 * @brief print the collection of transitions 00953 * 00954 * This method prints out the transition set to the output stream 00955 * provided. 00956 * 00957 * @param - o: the output stream to print to 00958 * @return the output stream that was printed to 00959 * 00960 */ 00961 std::ostream & print( std::ostream & o ) const; 00962 00963 /* 00964 * 00965 * @brief print the collection of transitions in dot format 00966 * 00967 * This method prints out the transition set in dot format to the 00968 * output stream provided. 00969 * 00970 * @param - o: the output stream to print to 00971 * @return the output stream that was printed to 00972 * 00973 */ 00974 std::ostream & print_dot( std::ostream & o ) const; 00975 00976 /** 00977 * 00978 * @brief tests whether this collection of transitions is equivalent 00979 * to the collection of transitions 'other' 00980 * 00981 * This method tests the equivalence of this set of transitions and 00982 * the set of transitions 'other'. 00983 * 00984 * @param - other: the TransitionStorage to compare this TransitionStorage to 00985 * @return true if this TransitionStorage is equivalent to the TransitionStorage 'other' 00986 * 00987 */ 00988 bool operator==( const TransitionStorage & other ) const; 00989 00990 /** 00991 * 00992 * @brief provides access to the call transitions in the collection 00993 * through an iterator 00994 * 00995 * This method provides access to the call transitions in the collection 00996 * of transitions through an iterator. 00997 * 00998 * @return the starting point of an iterator through the call transitions 00999 * in the collection of transitions 01000 * 01001 */ 01002 CallIterator beginCall( ) const; 01003 01004 /** 01005 * 01006 * @brief provides access to the internal transitions in the collection 01007 * through an iterator 01008 * 01009 * This method provides access to the internal transitions in the collection 01010 * of transitions through an iterator. 01011 * 01012 * @return the starting point of an iterator through the internal transitions 01013 * in the collection of transitions 01014 * 01015 */ 01016 InternalIterator beginInternal( ) const; 01017 01018 /** 01019 * 01020 * @brief provides access to the return transitions in the collection 01021 * through an iterator 01022 * 01023 * This method provides access to the return transitions in the collection 01024 * of transitions through an iterator. 01025 * 01026 * @return the starting point of an iterator through the return transitions 01027 * in the collection of transitions 01028 * 01029 */ 01030 ReturnIterator beginReturn( ) const; 01031 01032 /** 01033 * 01034 * @brief provides access to the call transitions in the collection 01035 * through an iterator 01036 * 01037 * This method provides access to the call transitions in the collection 01038 * of transitions through an iterator. 01039 * 01040 * @return the exit point of an iterator through the call transitions in 01041 * the collection of transitions 01042 * 01043 */ 01044 CallIterator endCall( ) const; 01045 01046 /** 01047 * 01048 * @brief provides access to the internal transitions in the collection 01049 * through an iterator 01050 * 01051 * This method provides access to the internal transitions in the collection 01052 * of transitions through an iterator. 01053 * 01054 * @return the exit point of an iterator through the internal transitions in 01055 * the collection of transitions 01056 * 01057 */ 01058 InternalIterator endInternal( ) const; 01059 01060 /** 01061 * 01062 * @brief provides access to the return transitions in the collection 01063 * through an iterator 01064 * 01065 * This method provides access to the return transitions in the collection 01066 * of transitions through an iterator. 01067 * 01068 * @return the exit point of an iterator through the return transitions in 01069 * the collection of transitions 01070 * 01071 */ 01072 ReturnIterator endReturn( ) const; 01073 01074 /** 01075 * 01076 * @brief returns the number of call transitions in this collection of 01077 * transitions 01078 * 01079 * This method returns the number of call transitions in the collection 01080 * of transitions associated with the NWA. 01081 * 01082 * @return the number of call transitions in this collection of transitions 01083 * 01084 */ 01085 size_t sizeCall( ) const; 01086 01087 /** 01088 * 01089 * @brief returns the number of internal transitions in this collection of 01090 * transitions 01091 * 01092 * This method returns the number of internal transitions in this collection 01093 * of transitions. 01094 * 01095 * @return the number of internal transitions in this collection of transitions 01096 * 01097 */ 01098 size_t sizeInternal( ) const; 01099 01100 /** 01101 * 01102 * @brief returns the number of return transitions in this collection of 01103 * transitions 01104 * 01105 * This method returns the number of return transitions in this collection 01106 * of transitions associated with the NWA. 01107 * 01108 * @return the number of return transitions in this collection of transitions 01109 * 01110 */ 01111 size_t sizeReturn( ) const; 01112 01113 /** 01114 * 01115 * @brief returns the total number of transitions (call, internal, and return) in 01116 * this collection of transitions 01117 * 01118 * This method returns the total number of transitions (call, internal, and return) 01119 * in this collection of transitions. 01120 * 01121 * @return the total number of transitions in this collection of transitions 01122 * 01123 */ 01124 size_t size( ) const; 01125 01126 /** 01127 * 01128 * @brief returns all outgoing internal transitions for the given state 01129 * 01130 * This method returns all internal transitions with the given state as 01131 * the source. 01132 * 01133 * @param - state: the source state 01134 * @return the set of all outgoing internal transitions for the given state 01135 * 01136 */ 01137 const Internals & getTransFrom( State state ) const; 01138 01139 /** 01140 * 01141 * @brief retuans all incoming internal transitions for the given state 01142 * 01143 * This method returns all internal transitions with the given state as 01144 * the target. 01145 * 01146 * @param - state: the target state 01147 * @return the set of all incoming internal transitions for the given state 01148 * 01149 */ 01150 const Internals & getTransTo( State state ) const; 01151 01152 /** 01153 * 01154 * @brief returns all call transitions for the given call site 01155 * 01156 * This method returns all call transitions with the given state as 01157 * the call site. 01158 * 01159 * @param - state: the call site 01160 * @return the set of all call transitions for the given call site 01161 * 01162 */ 01163 const Calls & getTransCall( State state ) const; 01164 01165 /** 01166 * 01167 * @brief returns all call transitions for the given entry point 01168 * 01169 * This method returns all call transitions with the given state as 01170 * the entry point. 01171 * 01172 * @param - state: the entry point 01173 * @return the set of all call transitions for the given entry point 01174 * 01175 */ 01176 const Calls & getTransEntry( State state ) const; 01177 01178 /** 01179 * 01180 * @brief returns all return transitions for the given exit point 01181 * 01182 * This method returns all return transitions with the given state as 01183 * the exit point. 01184 * 01185 * @param - state: the exit point 01186 * @return the set of all return transitions for the given exit point 01187 * 01188 */ 01189 const Returns & getTransExit( State state ) const; 01190 01191 /** 01192 * 01193 * @brief returns all return transitions for the given call predecessor 01194 * 01195 * This method returns all return transitions with the given state as 01196 * the call predecessor. 01197 * 01198 * @param - state: the call predecessor 01199 * @return the set of all return transitions for the given call predecessor 01200 * 01201 */ 01202 const Returns & getTransPred( State state ) const; 01203 01204 /** 01205 * 01206 * @brief returns all return transitions for the given return site 01207 * 01208 * This method returns all return transitions with the given state as 01209 * the return site. 01210 * 01211 * @param - state: the return site 01212 * @return the set of all return transitions for the given return site 01213 * 01214 */ 01215 const Returns & getTransRet( State state ) const; 01216 01217 /** 01218 * 01219 * @brief tests whether the given state is the source of any internal 01220 * transition 01221 * 01222 * This method determines whether the given state is the source of any 01223 * internal transition. 01224 * 01225 * @param - state: the state to test 01226 * @return true if the given state is the source of some internal 01227 * transition, false otherwise 01228 * 01229 */ 01230 bool isFrom( State state ) const; 01231 01232 /** 01233 * 01234 * @brief tests whether the given state is the target of any internal 01235 * transition 01236 * 01237 * This method determines whether the given state is the target of any 01238 * internal transition. 01239 * 01240 * @param - state: the state to test 01241 * @return true if the given state is the target of some internal 01242 * transition, false otherwise 01243 * 01244 */ 01245 bool isTo( State state ) const; 01246 01247 /** 01248 * 01249 * @brief tests whether the given state is the call site of any call 01250 * transition 01251 * 01252 * This method determines whether the given state is the call site of 01253 * any call transition. 01254 * 01255 * @param - state: the state to test 01256 * @return true if the given state is the call site of some call 01257 * transition, false otherwise 01258 * 01259 */ 01260 bool isCall( State state ) const; 01261 01262 /** 01263 * 01264 * @brief tests whether the given state is the entry point of any call 01265 * transition 01266 * 01267 * This method determines whether the given state is the entry point 01268 * of any call transition. 01269 * 01270 * @param - state: the state to test 01271 * @return true if the given state is the entry point of some call 01272 * transition, false otherwise 01273 * 01274 */ 01275 bool isEntry( State state ) const; 01276 01277 /** 01278 * 01279 * @brief tests whether the given state is the exit point of any return 01280 * transition 01281 * 01282 * This method determines whether the given state is the exit point of 01283 * any return transition. 01284 * 01285 * @param - state: the state to test 01286 * @return true if the given state is the exit point of some return 01287 * transition, false otherwise 01288 * 01289 */ 01290 bool isExit( State state ) const; 01291 01292 /** 01293 * 01294 * @brief tests whether the given state is the call predecessor for any 01295 * return transition 01296 * 01297 * This methos determines whether the given state is the call predecessor 01298 * for any return transition. 01299 * 01300 * @param - state: the state to test 01301 * @return true if the given state is the call predecessor of some return 01302 * transition, false otherwise 01303 * 01304 */ 01305 bool isPred( State state ) const; 01306 01307 /** 01308 * 01309 * @brief tests whether the given state is the return site of any return 01310 * transition 01311 * 01312 * This method determines whether the given state is the return site of any 01313 * return transition. 01314 * 01315 * @param - state: the state to test 01316 * @return true if the given state is the return site of some return 01317 * transition, false otherwise 01318 * 01319 */ 01320 bool isRet( State state ) const; 01321 01322 /** 01323 * 01324 * @brief removes all transitions involving the given state 01325 * 01326 * This method removes all transitions involving the given state 01327 * If no transitions exist involving this state false is returned. 01328 * Otherwise, true is returned. 01329 * 01330 * @param - state: the state whose transitions to remove 01331 * @return false if no transitions were removed, true otherwise 01332 * 01333 */ 01334 bool removeTransWith( State state ); 01335 01336 /** 01337 * 01338 * @brief removes all transitions with the given symbol 01339 * 01340 * This method removes all transitions with the given symbol. 01341 * If no transitions exist with the given symbol false is 01342 * returned. Otherwise, true is returned. 01343 * 01344 * @param - sym: the symbol whose transitions to remove 01345 * @return false if no transitions were removed, true otherwise 01346 * 01347 */ 01348 bool removeTransSym( Symbol sym ); 01349 01350 /** 01351 * 01352 * @brief test if there exists a call transition with the given from state 01353 * and symbol in this collection of transitions 01354 * 01355 * This method tests whether there exists a call transition with the given 01356 * from state and symbol in this collection of transitions. 01357 * 01358 * @param - from: the desired from state for the call transition 01359 * @param - sym: the desired symbol for the call transition 01360 * @return true if there exists a call transition with the given from state and 01361 * symbol in this collection of transitions 01362 * 01363 */ 01364 bool callExists( State from, Symbol sym ) const; 01365 01366 /** 01367 * 01368 * @brief provides access to all call transitions with the given from state 01369 * and symbol in this collection of transitions 01370 * 01371 * This method provides access to all call transitions with the given from 01372 * state and symbol in this collection of transitions. 01373 * 01374 * @param - from: the desired from state for the call transitions 01375 * @param - sym: the desired symbol for the call transitions 01376 * @return the set of call transitions with the given from state and symbol 01377 * 01378 */ 01379 const Calls getCalls( State from, Symbol sym ) const; 01380 01381 /** 01382 * 01383 * @brief test if there exists an internal transition with the given from state 01384 * and symbol in this collection of transitions 01385 * 01386 * This method tests whether there exists an internal transition with the given 01387 * from state and symbol in this collection of transitions. 01388 * 01389 * @param - from: the desired from state for the internal transition 01390 * @param - sym: the desired symbol for the internal transition 01391 * @return true if there exists an internal transition with the given from state and 01392 * symbol in this collection of transitions 01393 * 01394 */ 01395 bool internalExists( State from, Symbol sym ) const; 01396 01397 /** 01398 * 01399 * @brief provides access to all internal transitions with the given from 01400 * state and symbol in this collection of transitions 01401 * 01402 * This method provides access to all internal transitions with the given 01403 * from state and symbol in this collection of transitions. 01404 * 01405 * @param - from: the desired from state for the internal transitions 01406 * @param - sym: the desired symbol for the internal transitions 01407 * @return the set of internal transitions with the given from state and symbol 01408 * 01409 */ 01410 const Internals getInternals( State from, Symbol sym ) const; 01411 01412 /** 01413 * TODO this is redundant 01414 * @brief provides access to all internal transitions with the given 01415 * from state in this collection of transitions 01416 * 01417 * This method provides access to all internal transitions with the given 01418 * from state in this collection of transitions. 01419 * 01420 * @param - from: the desired from state for the internal transitions 01421 * @return the set of internal transitions with the given from state 01422 * 01423 */ 01424 const Internals getInternalsFrom( State from ) const; 01425 01426 /** 01427 * 01428 * @brief test if there exists a return transition with the given from state, 01429 * predecessor state, and symbol in this collection of transitions 01430 * 01431 * This method tests whether there exists a return transition with the given 01432 * from state, predecessor state, and symbol in this collection of transitions. 01433 * 01434 * @param - from: the desired from state for the return transition 01435 * @param - pred: the desired predecessor state for the return transition 01436 * @param - sym: the desired symbol for the return transition 01437 * @return true if there exists a return transition with the given from state and 01438 * symbol in this collection of transitions 01439 * 01440 */ 01441 bool returnExists( State from, State pred, Symbol sym ) const; 01442 01443 /** 01444 * 01445 * @brief provides access to all return transitions with the given from 01446 * state and symbol in this collection of transitions 01447 * 01448 * This method provides access to all return transitions with the given from 01449 * state and symbol in this collection of transitions. 01450 * 01451 * @param - from: the desired from state for the return transitions 01452 * @param - sym: the desired symbol for the return transitions 01453 * @return the set of return transitions with the given from state and symbol 01454 * 01455 */ 01456 const Returns getReturns( State from, Symbol sym ) const; 01457 01458 protected: 01459 01460 /** 01461 * 01462 * @brief removes all call transitions to or from the given state 01463 * 01464 * This method removes all call transitions to or from the given state 01465 * If no call transitions exist to or from this state false is returned. 01466 * Otherwise, true is returned. 01467 * 01468 * @param - state: the state whose transitions to remove 01469 * @return false if no transitions were removed, true otherwise 01470 * 01471 */ 01472 bool removeCallTransWith( State state ); 01473 01474 /** 01475 * 01476 * @brief removes all internal transitions to or from the given state 01477 * 01478 * This method removes all internal transitions to or from the given 01479 * state. If no internal transitions exist to or from this state, 01480 * false is returned. Otherwise, true is returned. 01481 * 01482 * @param - state: the state whose transitions to remove 01483 * @return false if no transitions were removed, true otherwise 01484 * 01485 */ 01486 bool removeInternalTransWith( State state ); 01487 01488 /** 01489 * 01490 * @brief removes all return transitions to or from the given state 01491 * as well as return transitions corresponding to calls from 01492 * that state 01493 * 01494 * This method removes all return transitions to or from the given 01495 * state as well as return transitions corresponding to calls from 01496 * that state. If no return transitions exist to or from this state, 01497 * or having this state as a call predecessor, false is returned. 01498 * Otherwise, true is returned. 01499 * 01500 * @param - state: the state whose transitions to remove 01501 * @return false if no transitions were removed, true otherwise 01502 * 01503 */ 01504 bool removeReturnTransWith( State state ); 01505 01506 /** 01507 * 01508 * @brief removes all call transitions with the given symbol 01509 * 01510 * This method removes all call transitions with the given symbol. 01511 * If no call transitions exist with the given symbol false is 01512 * returned. Otherwise, true is returned. 01513 * 01514 * @param - sym: the symbol whose transitions to remove 01515 * @return false if no transitions were removed, true otherwise 01516 * 01517 */ 01518 bool removeCallTransSym( Symbol sym ); 01519 01520 /** 01521 * 01522 * @brief removes all internal transitions with the given symbol 01523 * 01524 * This method removes all internal transitions with the given symbol. 01525 * If no internal transitions exist with the given symbol false is 01526 * returned. Otherwise, true is returned. 01527 * 01528 * @param - sym: the symbol whose transitions to remove 01529 * @return false if no transitions were removed, true otherwise 01530 * 01531 */ 01532 bool removeInternalTransSym( Symbol sym ); 01533 01534 /** 01535 * 01536 * @brief removes all return transitions with the given symbol 01537 * 01538 * This method removes all return transitions with the given symbol. 01539 * If no return transitions exist with the given symbol false is 01540 * returned. Otherwise, true is returned. 01541 * 01542 * @param - sym: the symbol whose transitions to remove 01543 * @return false if no transitions were removed, true otherwise 01544 * 01545 */ 01546 bool removeReturnTransSym( Symbol sym ); 01547 01548 // 01549 // Variables 01550 // 01551 01552 protected: 01553 01554 Calls callTrans; 01555 Internals internalTrans; 01556 Returns returnTrans; 01557 01558 Info T_info; 01559 }; 01560 01561 01562 } 01563 } 01564 #endif