DGraphSolverDFP.hpp

Go to the documentation of this file.
00001 
00016 #ifndef DGraphSolverDFP_h
00017 #define DGraphSolverDFP_h
00018 
00019 //#ifndef DirectedGraph_h
00020 //#include <libs/support/graphs/directedGraph/DirectedGraph.h>
00021 //#endif
00022 // Going to attempt to use DGraph instead
00023 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00024 #include <OpenAnalysis/Utils/DGraph/DGraphInterface.hpp>
00025 #include <OpenAnalysis/Utils/DGraph/DGraphImplement.hpp>
00026 #include <OpenAnalysis/CFG/CFGInterface.hpp>
00027 #include <OpenAnalysis/CFG/CFG.hpp>
00028 #include <OpenAnalysis/DataFlow/WorkListPQueue.hpp>
00029 #include <OpenAnalysis/DataFlow/WorkListQueue.hpp>
00030 
00031 
00032 #include <iostream>
00033 
00034 #include <sys/times.h>
00035 
00036 #include <vector>
00037 
00038 #include <set>
00039 
00040 #include <queue>
00041 
00042 namespace OA {
00043   namespace DataFlow {
00044 
00045 
00046 enum DFPImplement { ITERATIVE = 0, WORKLIST_PRIORITY_QUEUE, WORKLIST_QUEUE };
00047 
00048 //*********************************************************************
00049 // class DGraphIterativeDFP
00050 //*********************************************************************
00051 
00052 class DGraphSolverDFP {
00053         
00054 public:
00055 
00056     DGraphSolverDFP();
00057     ~DGraphSolverDFP();
00058   //--------------------------------------------------------
00059   // Kildall iterative solver 
00060   //--------------------------------------------------------
00061   void solve(OA_ptr<DGraph::DGraphInterface> dg, 
00062              DGraph::DGraphEdgeDirection alongFlow,
00063              DFPImplement algorithm);
00064 
00065   int afterSolve_getNumIter() {return numIter;}
00066   
00067 private:
00068 
00069   int numIter;
00070 
00071   //--------------------------------------------------------
00072   // initialization callback
00073   //--------------------------------------------------------
00074   virtual void initialize(OA_ptr<DGraph::DGraphInterface> dg) = 0;
00075 
00076   //--------------------------------------------------------
00077   // solver callbacks 
00078   //--------------------------------------------------------
00079   //   atDGraphNode and atDGraphEdge return true if change
00080   //   in dataflow information at the graph element
00081 
00082   virtual bool atDGraphNode(OA_ptr<DGraph::NodeInterface>, 
00083                             DGraph::DGraphEdgeDirection);
00084 
00085   virtual bool atDGraphEdge(OA_ptr<DGraph::EdgeInterface>, 
00086                             DGraph::DGraphEdgeDirection);
00087 
00088   //--------------------------------------------------------
00089   // finalization callbacks
00090   //--------------------------------------------------------
00091   virtual void finalizeNode(OA_ptr<DGraph::NodeInterface> node);
00092 
00093   virtual void finalizeEdge(OA_ptr<DGraph::EdgeInterface> edge);
00094 
00095   void Iterative_Solve(OA_ptr<DGraph::DGraphInterface> dg,
00096              DGraph::DGraphEdgeDirection alongFlow);
00097 
00098 
00099   void WorkList_Solve(OA_ptr<DGraph::DGraphInterface> dg,
00100              DGraph::DGraphEdgeDirection alongFlow,
00101              DFPImplement algorithm);
00102 
00103   
00104 };
00105 
00106   } // end of DataFlow
00107 }  // end of OA namespace
00108 
00109 #endif