filteredCFG.h

Go to the documentation of this file.
00001 #ifndef FILTEREDCFGVIEW_H
00002 #define FILTEREDCFGVIEW_H
00003 
00004 //#include "rose.h"
00005 #include "virtualCFG.h"
00006 #include <string>
00007 #include <vector>
00008 
00009 namespace VirtualCFG
00010 {
00011     // Function call node and edge filters
00012 
00013     template < typename FilterFunction > class FilteredCFGEdge;
00014 
00015     template < typename FilterFunction > class FilteredCFGNode
00016     {
00017         CFGNode n;
00018         FilterFunction filter;
00019 
00020       public:
00021         FilteredCFGNode(const CFGNode& n):n(n)
00022         {
00023         }
00024 
00026         FilteredCFGNode() : n()
00027         {
00028         }
00029         
00030         void setFilter(const FilterFunction& f)
00031         {
00032             filter = f;
00033         }
00034 
00035         const CFGNode& toNode() const
00036         {
00037             return n;
00038         }
00039         std::string toString() const
00040         {
00041                                                 std::string nToString= n.toString();
00042                                                 if (nToString.find('>',0)>0)
00043                                                 nToString.insert(nToString.find('>',0)+1,"\n");
00044             return nToString;
00045         }
00046         std::string toStringForDebugging() const
00047         {
00048             return n.toStringForDebugging();
00049         }
00050         std::string id() const
00051         {
00052             return n.id();
00053         }
00054         SgNode *getNode() const
00055         {
00056             return n.getNode();
00057         }
00058         unsigned int getIndex() const
00059         {
00060             return n.getIndex();
00061         }
00062         std::vector < FilteredCFGEdge < FilterFunction > >outEdges() const;
00063         std::vector < FilteredCFGEdge < FilterFunction > >inEdges() const;
00064         bool isInteresting() const
00065         {
00066             return true;
00067         }
00068         bool operator==(const FilteredCFGNode & o)const
00069         {
00070             return n == o.n;
00071         }
00072         bool operator!=(const FilteredCFGNode & o)const
00073         {
00074             return !(*this == o);
00075         }
00076         bool operator<(const FilteredCFGNode & o)const
00077         {
00078             return n < o.n;
00079         }
00080     };
00081 
00082     template < typename FilterFunction > class FilteredCFGEdge
00083     {
00084         CFGPath p;
00085         FilterFunction filter;
00086 
00087       public:
00088       FilteredCFGEdge(CFGPath p):p(p)
00089         {
00090         }
00091 
00093         FilteredCFGEdge()
00094         {
00095         }
00096         
00097         void setFilter(const FilterFunction& f)
00098         {
00099             filter = f;
00100         }
00101 
00102         std::string toString()const
00103         {
00104             return p.toString();
00105         }
00106         std::string toStringForDebugging() const
00107         {
00108             return p.toStringForDebugging();
00109         }
00110         std::string id() const
00111         {
00112             return p.id();
00113         }
00114         FilteredCFGNode < FilterFunction > source() const
00115         {
00116             return FilteredCFGNode < FilterFunction > (p.source());
00117         }
00118         FilteredCFGNode < FilterFunction > target() const
00119         {
00120             return FilteredCFGNode < FilterFunction > (p.target());
00121         }
00122         EdgeConditionKind condition() const
00123         {
00124             return p.condition();
00125         }
00126         SgExpression *caseLabel() const
00127         {
00128             return p.caseLabel();
00129         }
00130         std::vector < SgInitializedName * >scopesBeingExited() const
00131         {
00132             return p.scopesBeingExited();
00133         }
00134         std::vector < SgInitializedName * >scopesBeingEntered() const
00135         {
00136             return p.scopesBeingEntered();
00137         }
00138         bool operator==(const FilteredCFGEdge < FilterFunction > &o)const
00139         {
00140             return p == o.p;
00141         }
00142         bool operator!=(const FilteredCFGEdge < FilterFunction > &o)const
00143         {
00144             return p != o.p;
00145         }
00146         bool operator<(const FilteredCFGEdge < FilterFunction > &o)const
00147         {
00148             return p < o.p;
00149         }
00150         
00152         const CFGPath& getPath() const
00153         {
00154                 return p;
00155         }
00156     };
00157 
00158     template < typename FilterFunction > std::ostream & cfgToDot(std::ostream & o,
00159                                                                  std::string graphName,
00160                                                                  FilteredCFGNode <
00161                                                                  FilterFunction > start);
00162 }
00163 
00164 #include "filteredCFGImpl.h"
00165 #endif // XCFGVIEW_H

Generated on Tue Jan 31 05:31:37 2012 for ROSE by  doxygen 1.4.7