BaseExperiment.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.data.experiment;
00002
00003 import java.io.File;
00004 import java.io.InputStream;
00005
00006 import edu.rice.cs.hpc.data.experiment.extdata.TraceAttribute;
00007 import edu.rice.cs.hpc.data.experiment.scope.RootScope;
00008 import edu.rice.cs.hpc.data.experiment.scope.RootScopeType;
00009 import edu.rice.cs.hpc.data.experiment.scope.Scope;
00010 import edu.rice.cs.hpc.data.experiment.scope.visitors.DisposeResourcesVisitor;
00011 import edu.rice.cs.hpc.data.experiment.scope.visitors.FilterScopeVisitor;
00012 import edu.rice.cs.hpc.data.filter.IFilterData;
00013 import edu.rice.cs.hpc.data.util.IUserData;
00014
00015
00016
00017
00018
00019
00020
00021
00022 public abstract class BaseExperiment implements IExperiment
00023 {
00025 protected ExperimentConfiguration configuration;
00026
00027 protected RootScope rootScope;
00028
00030 protected String version;
00031
00032 private TraceAttribute attribute;
00033
00034 protected IDatabaseRepresentation databaseRepresentation;
00035
00036
00037
00038
00039
00040
00041 public void setRootScope(Scope rootScope) {
00042 this.rootScope = (RootScope) rootScope;
00043 }
00044
00045
00046
00047
00048
00049
00050
00051 public Scope getRootScope() {
00052 return rootScope;
00053 }
00054
00055
00056
00057
00058
00059
00060
00061 public RootScope getCallerTreeRoot() {
00062 RootScope root = (RootScope) getRootScope();
00063 if (root.getSubscopeCount()==3) {
00064
00065 Scope scope = root.getSubscope(1);
00066 if (scope instanceof RootScope)
00067 return (RootScope) scope;
00068
00069 }
00070 return null;
00071 }
00072
00073
00074
00075 public Object[] getRootScopeChildren() {
00076 RootScope root = (RootScope) getRootScope();
00077
00078 if (root != null)
00079 return root.getChildren();
00080 else
00081 return null;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 public void open(File fileExperiment, IUserData<String, String> userData, boolean need_metric)
00094 throws Exception
00095 {
00096 databaseRepresentation = new LocalDatabaseRepresentation(fileExperiment, this, userData, need_metric);
00097 databaseRepresentation.open();
00098 open_finalize();
00099 }
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 public void open(InputStream expStream, IUserData<String, String> userData,
00111 String name) throws Exception {
00112 databaseRepresentation = new RemoteDatabaseRepresentation(this, expStream, userData, name);
00113 databaseRepresentation.open();
00114 open_finalize();
00115 }
00116
00117
00118
00119
00120
00121
00122 public void reopen() throws Exception
00123 {
00124 if (databaseRepresentation != null)
00125 {
00126 databaseRepresentation.open();
00127 open_finalize();
00128 } else {
00129 throw new Exception("Database has not been opened.");
00130 }
00131 }
00132
00133 public void setVersion (String v)
00134 {
00135 this.version = v;
00136 }
00137
00138 public void setTraceAttribute(TraceAttribute _attribute) {
00139 this.attribute = _attribute;
00140 }
00141
00142
00143 public TraceAttribute getTraceAttribute() {
00144 return this.attribute;
00145 }
00146
00147
00148
00149
00150
00151
00152 public String getName()
00153 {
00154 return configuration.getName(ExperimentConfiguration.NAME_EXPERIMENT);
00155 }
00156
00157
00158
00159
00160
00161
00162
00163
00164 public void setConfiguration(ExperimentConfiguration configuration)
00165 {
00166 this.configuration = configuration;
00167 }
00168
00169 public ExperimentConfiguration getConfiguration()
00170 {
00171 return this.configuration;
00172 }
00173
00174
00175
00176
00177
00178
00179 public File getDefaultDirectory()
00180 {
00181 return getXMLExperimentFile().getParentFile();
00182 }
00183
00184 public File getXMLExperimentFile() {
00185 return databaseRepresentation.getXMLFile().getFile();
00186 }
00187
00188
00189
00190
00191
00192 public void dispose()
00193 {
00194 DisposeResourcesVisitor visitor = new DisposeResourcesVisitor();
00195 rootScope.dfsVisitScopeTree(visitor);
00196 this.rootScope = null;
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206 public void filter(IFilterData filter)
00207 {
00208
00209 final RootScope rootCCT = (RootScope) rootScope.getChildAt(0);
00210
00211
00212 FilterScopeVisitor visitor = new FilterScopeVisitor(rootCCT, filter);
00213 rootCCT.dfsVisitFilterScopeTree(visitor);
00214
00215 if (rootCCT.getType() == RootScopeType.CallingContextTree) {
00216 filter_finalize(rootCCT, filter);
00217 }
00218 }
00219
00220
00221
00222
00223
00224
00225
00226
00227 abstract protected void filter_finalize(RootScope rootMain, IFilterData filter);
00228
00229 abstract protected void open_finalize();
00230
00231 }