FWPDS.hpp

Go to the documentation of this file.
00001 #ifndef wali_wpds_fwpds_FWPDS_GUARD
00002 #define wali_wpds_fwpds_FWPDS_GUARD 1
00003 
00004 /**
00005  * @author Nicholas Kidd
00006  * @author Akash Lal
00007  *
00008  */
00009 
00010 #include "wali/Common.hpp"
00011 #include "wali/wpds/WPDS.hpp"
00012 #include "wali/wpds/Wrapper.hpp"
00013 
00014 #include "wali/wpds/ewpds/EWPDS.hpp"
00015 
00016 #include "wali/graph/GraphCommon.hpp"
00017 #include "wali/graph/InterGraph.hpp"
00018 
00019 namespace wali {
00020 
00021   namespace wfa {
00022     class WFA;
00023     class Trans;
00024   }
00025 
00026   namespace graph {
00027     class InterGraph;
00028   }
00029 
00030   namespace wpds {
00031 
00032     class Wrapper;
00033     class rule_t;
00034 
00035     namespace fwpds 
00036     {
00037 
00038 
00039       class FWPDS : public ewpds::EWPDS 
00040       {
00041         public:
00042           /**
00043            * For parsing XML FWPDSs.
00044            * @shadow wali::wpds::ewpds::EPDS::XMLTag
00045            */
00046           static const std::string XMLTag;
00047 
00048         public:
00049           FWPDS();
00050           FWPDS(ref_ptr<Wrapper> wrapper);
00051           FWPDS( const FWPDS& f );
00052 
00053           ////////////
00054           // add rules
00055           ////////////
00056 
00057           // Inherited from EWPDS
00058 
00059           ///////////
00060           // pre*
00061           ///////////
00062           virtual void prestar( wfa::WFA const & input, wfa::WFA & output );
00063 
00064           virtual wfa::WFA prestar( wfa::WFA const & input) {
00065               return this->EWPDS::prestar(input);
00066           }
00067 
00068 
00069           ///////////
00070           // post*
00071           ///////////
00072           virtual void poststar( wfa::WFA const & input, wfa::WFA & output );
00073 
00074           virtual wfa::WFA poststar( wfa::WFA const & input) {
00075               return this->EWPDS::poststar(input);
00076           }
00077 
00078           void poststarIGR( wfa::WFA const & input, wfa::WFA & output );
00079 
00080           ///////////////////////
00081           // FWPDS Settings
00082           //////////////////////
00083 
00084           /** @brief Sets evaluation strategy for RegExp after InterGraph
00085            * saturation is complete, i.e., during the time when
00086            * transition weights are calculated. It is true by default,
00087            * but setting it to false seems to be far more efficient
00088            * while using BDD-based weight domain (Moped)
00089            */
00090           static void topDownEval(bool f);
00091 
00092         private:
00093           void prestar_handle_call(
00094               wfa::ITrans *t1,
00095               wfa::ITrans *t2,
00096               rule_t &r,
00097               sem_elem_t delta
00098               );
00099 
00100           void prestar_handle_trans(
00101               wfa::ITrans * t,
00102               wfa::WFA & ca  ,
00103               rule_t & r,
00104               sem_elem_t delta );
00105 
00106           void poststar_handle_eps_trans(
00107               wfa::ITrans *teps, 
00108               wfa::ITrans *tprime,
00109               sem_elem_t delta);
00110 
00111           void poststar_handle_trans(
00112               wfa::ITrans * t ,
00113               wfa::WFA & ca   ,
00114               rule_t & r,
00115               sem_elem_t delta
00116               );
00117 
00118           void update(
00119               wali::Key from
00120               , wali::Key stack
00121               , wali::Key to
00122               , sem_elem_t se
00123               , Config * cfg
00124               );
00125 
00126           wfa::ITrans * update_prime(
00127               Key from, //<! Guaranteed to be a generated state
00128               wfa::ITrans* call, //<! The call transition
00129               rule_t r, //<! The push rule
00130               sem_elem_t delta, //<! Delta change on the call transition
00131               sem_elem_t wWithRule //<! delta \extends r->weight()
00132               );
00133 
00134           void operator()( wfa::ITrans const * orig );
00135 
00136           ///////////
00137           // helpers
00138           ///////////
00139           bool checkResults( wfa::WFA const & input, bool poststar );
00140 
00141         protected:
00142           sem_elem_t wghtOne;
00143           graph::InterGraphPtr interGr;
00144           bool checkingPhase;
00145 
00146       }; // class FWPDS
00147 
00148     } // namespace fwpds
00149 
00150   } // namespace wpds
00151 
00152 } // namespace wali
00153 
00154 #endif  // wali_wpds_fwpds_FWPDS_GUARD
00155