CallPath.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.data.graph;
00002 import java.util.Vector;
00003 
00004 import edu.rice.cs.hpc.data.experiment.scope.CallSiteScope;
00005 import edu.rice.cs.hpc.data.experiment.scope.ProcedureScope;
00006 import edu.rice.cs.hpc.data.experiment.scope.RootScope;
00007 import edu.rice.cs.hpc.data.experiment.scope.Scope;
00008 
00009 public class CallPath
00010 {
00011 
00013     private Scope leafScope;
00014     
00016     private int maxDepth;
00017     
00019     public static final String NULL_FUNCTION = "-Outside Timeline-";
00020     
00021     public CallPath(Scope _leafScope, int _maxDepth, Scope _currentDepthScope, int _currentDepth)
00022     {
00023         leafScope = _leafScope;
00024         maxDepth = _maxDepth;
00025     }
00026     
00027     public CallPath(Scope _leafScope, int _maxDepth)
00028     {
00029         this(_leafScope, _maxDepth, null, _maxDepth);
00030     }
00031     
00033     public Scope getScopeAt(int depth)
00034     {
00035         if (depth < 0)
00036             return null;
00037         
00038         int cDepth = maxDepth;
00039         Scope cDepthScope = leafScope;
00040 
00041         while(!(cDepthScope.getParentScope() instanceof RootScope) && 
00042                 (cDepth > depth || !(cDepthScope instanceof CallSiteScope || cDepthScope instanceof ProcedureScope)))
00043         {
00044             cDepthScope = cDepthScope.getParentScope();
00045             if((cDepthScope instanceof CallSiteScope) || (cDepthScope instanceof ProcedureScope))
00046                 cDepth--;
00047         }
00048         
00049         assert (cDepthScope instanceof CallSiteScope || cDepthScope instanceof ProcedureScope);
00050 
00051         return cDepthScope;
00052     }
00053     
00054     
00055     /*************************************
00056      * retrieve the list of function names of this call path
00057      * 
00058      * @return vector of procedure names
00059      ************************************/
00060     public Vector<String> getFunctionNames()
00061     {
00062         final Vector<String> functionNames = new Vector<String>();
00063         if (functionNames.isEmpty())
00064         {
00065             Scope currentScope = leafScope;
00066             int depth = maxDepth;
00067             while(depth > 0)
00068             {
00069                 if ((currentScope instanceof CallSiteScope) || (currentScope instanceof ProcedureScope))
00070                 {
00071                     functionNames.add(0, currentScope.getName());
00072                     depth--;
00073                 }
00074                 currentScope = currentScope.getParentScope();
00075             }
00076         }
00077         return functionNames;
00078     }
00079     
00080     
00081     /*******************************
00082      * Retrieve the maximum depth of this call path
00083      * 
00084      * @return the max depth
00085      *******************************/
00086     public int getMaxDepth()
00087     {
00088         return maxDepth;
00089     }
00090 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1