00001 #ifndef wali_wpds_WRAPPER_GUARD 00002 #define wali_wpds_WRAPPER_GUARD 1 00003 00004 /** 00005 * @author Nicholas Kidd 00006 */ 00007 00008 #include "wali/Common.hpp" 00009 #include "wali/Countable.hpp" 00010 #include "wali/SemElem.hpp" 00011 #include "wali/MergeFn.hpp" 00012 00013 namespace wali 00014 { 00015 namespace wfa { 00016 class ITrans; 00017 } 00018 00019 namespace wpds 00020 { 00021 class Rule; 00022 00023 namespace ewpds { 00024 class ERule; 00025 } 00026 00027 /** 00028 * @class Wrapper 00029 * 00030 * This class defines the interface used to "wrap" 00031 * weights on rules and transitions. A Wrapper can be passed 00032 * to a WPDS when it is created for adding functionality, e.g. 00033 * Witnesses. The base class Wrapper is simply the identity wrapper. 00034 * It returns the weight on the Rule and Trans when wrap is invoked and 00035 * the same weight when unwrap is invoked. 00036 * 00037 * Wrappers can be chained together. It is up to the Wrapper definer 00038 * (i.e., the user) to take care of proper chaining. WALi assumes that 00039 * unwrap will return an element from the user defined weight domain. 00040 */ 00041 class Wrapper : public Countable 00042 { 00043 public: 00044 Wrapper() : Countable() {} 00045 00046 virtual ~Wrapper() {} 00047 00048 virtual sem_elem_t wrap( wfa::ITrans const & t ); 00049 00050 virtual sem_elem_t wrap( wpds::Rule const & r ); 00051 00052 /** 00053 * Wrapping of a rule's weight happens before wrapping 00054 * of its merge function. Thus, the weight 00055 * 00056 * r->weight() 00057 * 00058 * has already been wrapped. For example, see how 00059 * this is handled in wali::witness::WitnessWrapper. 00060 * 00061 * @see wali::witness::WitnessWrapper 00062 */ 00063 virtual merge_fn_t wrap( wpds::ewpds::ERule const & r, merge_fn_t user_merge); 00064 00065 virtual sem_elem_t unwrap( sem_elem_t se ); 00066 00067 virtual merge_fn_t unwrap( merge_fn_t mf ); 00068 00069 protected: 00070 00071 }; // class Wrapper 00072 00073 } // namespace wpds 00074 00075 } // namespace wali 00076 00077 #endif // wali_wpds_WRAPPER_GUARD 00078