AbstractFinalizeMetricVisitor.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.data.experiment.scope.visitors;
00002
00003 import edu.rice.cs.hpc.data.experiment.metric.AggregateMetric;
00004 import edu.rice.cs.hpc.data.experiment.metric.BaseMetric;
00005 import edu.rice.cs.hpc.data.experiment.scope.CallSiteScope;
00006 import edu.rice.cs.hpc.data.experiment.scope.FileScope;
00007 import edu.rice.cs.hpc.data.experiment.scope.GroupScope;
00008 import edu.rice.cs.hpc.data.experiment.scope.LineScope;
00009 import edu.rice.cs.hpc.data.experiment.scope.LoadModuleScope;
00010 import edu.rice.cs.hpc.data.experiment.scope.LoopScope;
00011 import edu.rice.cs.hpc.data.experiment.scope.ProcedureScope;
00012 import edu.rice.cs.hpc.data.experiment.scope.RootScope;
00013 import edu.rice.cs.hpc.data.experiment.scope.Scope;
00014 import edu.rice.cs.hpc.data.experiment.scope.ScopeVisitType;
00015 import edu.rice.cs.hpc.data.experiment.scope.StatementRangeScope;
00016
00017 public abstract class AbstractFinalizeMetricVisitor implements IScopeVisitor {
00018 private BaseMetric metrics[];
00019
00020 public AbstractFinalizeMetricVisitor(BaseMetric _metrics[]) {
00021 this.metrics = _metrics;
00022 }
00023
00024 public void visit(LineScope scope, ScopeVisitType vt) { process(scope, vt); }
00025 public void visit(StatementRangeScope scope, ScopeVisitType vt) {process(scope, vt); }
00026 public void visit(LoopScope scope, ScopeVisitType vt) { process(scope, vt);}
00027 public void visit(CallSiteScope scope, ScopeVisitType vt) { process(scope, vt); }
00028 public void visit(ProcedureScope scope, ScopeVisitType vt) { process(scope, vt); }
00029 public void visit(FileScope scope, ScopeVisitType vt) { process(scope, vt); }
00030 public void visit(GroupScope scope, ScopeVisitType vt) { process(scope, vt); }
00031 public void visit(LoadModuleScope scope, ScopeVisitType vt) { process(scope, vt); }
00032 public void visit(RootScope scope, ScopeVisitType vt) { process(scope, vt); }
00033 public void visit(Scope scope, ScopeVisitType vt) { process(scope, vt); }
00034
00035
00036
00037 private void process( Scope scope, ScopeVisitType vt) {
00038 if (vt == ScopeVisitType.PreVisit ) {
00039 this.setValue(scope);
00040 }
00041 }
00042
00043
00044 protected void setValue_internal ( Scope scope) {
00045 for (int i=0; i<this.metrics.length; i++ ) {
00046 if (metrics[i] instanceof AggregateMetric) {
00047 AggregateMetric agg = (AggregateMetric) metrics[i];
00048 agg.finalize(scope);
00049 }
00050 }
00051 }
00052
00053 protected abstract void setValue( Scope scope );
00054
00055 }