TraceLab Component Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
MetricComputation.cs
Go to the documentation of this file.
1 // TraceLab Component Library
2 // Copyright © 2012-2013 SEMERU
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 using TraceLabSDK;
18 using TraceLabSDK.Types.Contests;
19 
20 namespace TraceLab.Components.DevelopmentKit.Metrics
21 {
27  public abstract class MetricComputation : IMetricComputation
28  {
32  public abstract string Name
33  {
34  get;
35  }
36 
40  public abstract string Description
41  {
42  get;
43  }
44 
48  public SerializableDictionary<string, double> Results
49  {
50  get;
51  protected set;
52  }
53 
57  public bool HasRun
58  {
59  get;
60  private set;
61  }
62 
67  {
68  HasRun = false;
69  }
70 
74  public void Compute()
75  {
76  ComputeImplementation();
77  HasRun = true;
78  }
79 
83  protected abstract void ComputeImplementation();
84 
89  public Metric GenerateSummary()
90  {
91  if (!HasRun)
92  {
93  throw new DevelopmentKitException("Compute() method has not been run.");
94  }
95  return GenerateSummaryImplementation();
96  }
97 
102  protected abstract Metric GenerateSummaryImplementation();
103  }
104 }