RuleFunctor.hpp

Go to the documentation of this file.
00001 #ifndef wali_wpds_RULE_FUNCTOR_GUARD
00002 #define wali_wpds_RULE_FUNCTOR_GUARD 1
00003 
00004 /**
00005  * @author Nicholas Kidd
00006  * @author Akash Lal
00007  */
00008 
00009 #include "wali/Common.hpp"
00010 #include "wali/ref_ptr.hpp"
00011 #include <iostream>
00012 #include <set>
00013 
00014 namespace wali
00015 {
00016   namespace wpds
00017   {
00018     class WPDS;
00019     class Wrapper;
00020     class Rule;
00021     class rule_t;
00022 
00023     /*! @class RuleFunctor
00024      *
00025      * This functor is used in WPDS::for_each.
00026      * This is a pure virtual class.
00027      *
00028      * @see WPDS
00029      */
00030     class RuleFunctor
00031     {
00032       public:
00033         virtual ~RuleFunctor() {}
00034         virtual void operator()( rule_t & r ) = 0;
00035     };
00036 
00037     /*! @class ConstRuleFunctor
00038      *
00039      * This functor is used in WPDS::for_each.
00040      * This is a pure virtual class.
00041      *
00042      * @see WPDS
00043      */
00044     class ConstRuleFunctor
00045     {
00046       public:
00047         virtual ~ConstRuleFunctor() {}
00048         virtual void operator()( const rule_t & r ) = 0;
00049     };
00050 
00051     /*!
00052      * @class RulePrinter
00053      * Prints rules to constructor param std::ostream o
00054      */
00055     class RulePrinter : public ConstRuleFunctor
00056     {
00057       std::ostream & os;
00058 
00059       public:
00060       RulePrinter( std::ostream & o );
00061       virtual ~RulePrinter();
00062 
00063       virtual void operator()( const rule_t & r );
00064 
00065     };
00066 
00067     /*!
00068      * @class RulePrinter
00069      * Marshalls rules to constructor param std::ostream o
00070      */
00071     class RuleMarshaller : public ConstRuleFunctor
00072     {
00073       std::ostream & os;
00074 
00075       public:
00076       RuleMarshaller( std::ostream & o );
00077       virtual ~RuleMarshaller();
00078 
00079       virtual void operator()( const rule_t & r );
00080 
00081     };
00082 
00083     class RuleDotty : public ConstRuleFunctor
00084     {
00085       std::ostream & os;
00086       bool print_states;
00087 
00088       public:
00089       RuleDotty( std::ostream & o, bool _print_states = false );
00090       virtual ~RuleDotty();
00091 
00092       virtual void operator()( const rule_t & r );
00093     };
00094 
00095     /*!
00096      * @class WpdsStackSymbols
00097      * Gets all stack symbols from the WPDS and classfies them
00098      * as entry and return points, as appropriate
00099      */
00100     class WpdsStackSymbols : public ConstRuleFunctor
00101     {
00102       public:
00103         std::set< Key > gamma;
00104         std::set< Key > callPoints;
00105         std::set< Key > returnPoints;
00106         std::set< Key > entryPoints;
00107         std::set< Key > pdsStates;
00108 
00109         WpdsStackSymbols( );
00110         virtual ~WpdsStackSymbols();
00111 
00112         virtual void operator()( const rule_t & r );
00113 
00114       private:
00115         void addPoint(Key k, std::set< Key > &s);
00116     };
00117 
00118     // @author Amanda Burton
00119     /**
00120      * 
00121      * @class WpdsRules
00122      *
00123      * Gets all rules from the WPDS and classifies them as
00124      * push rules, pop rules, and step rules, as appropriate.
00125      *
00126      */
00127     class WpdsRules: public ConstRuleFunctor
00128     {
00129       public:
00130         std::set< Rule > pushRules;
00131         std::set< Rule > popRules;
00132         std::set< Rule > stepRules;
00133         
00134         WpdsRules();
00135         virtual ~WpdsRules();
00136         
00137         virtual void operator() (const rule_t & r);
00138         
00139       private:
00140         void addRule(Rule r, std::set< Rule > &s);
00141     };
00142 
00143     class RuleCopier : public ConstRuleFunctor
00144     {
00145       public:
00146         WPDS& w;
00147         ref_ptr<Wrapper> wrapper;
00148         RuleCopier(WPDS& w,ref_ptr<Wrapper>);
00149         virtual void operator()( const rule_t & r);
00150     };
00151   } // end namespace wpds
00152 
00153 } // end namespace wali
00154 
00155 #endif  // wali_wpds_RULE_FUNCTOR_GUARD
00156