Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/DataTableHelper.cs @ 8515

Last change on this file since 8515 was 8515, checked in by ascheibe, 12 years ago

#1886 fixed cloning and resetting of the scatter plot helper

File size: 2.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Optimization;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26
27namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
28  [Item("DataTableHelper", "Helper class for creating datatables.")]
29  [StorableClass]
30  public class DataTableHelper : Item {
31
32    [Storable]
33    private ResultCollection resultsCol;
34    [Storable]
35    private string chartName;
36    [Storable]
37    private string dataRowName;
38    [Storable]
39    private DataRow dtRow;
40
41    [StorableConstructor]
42    private DataTableHelper(bool deserializing) : base(deserializing) { }
43    private DataTableHelper(DataTableHelper original, Cloner cloner)
44      : base(original, cloner) { }
45    public DataTableHelper() : base() { }
46
47    public override IDeepCloneable Clone(Cloner cloner) {
48      return new DataTableHelper(this, cloner);
49    }
50
51    public void InitializeChart(ResultCollection results, string chartName, string dataRowName) {
52      if (!results.ContainsKey(chartName)) {
53        this.resultsCol = results;
54        this.chartName = chartName;
55        this.dataRowName = dataRowName;
56
57        DataTable dt = new DataTable(chartName);
58        dtRow = new DataRow(dataRowName);
59        dt.Rows.Add(dtRow);
60        results.Add(new Result(chartName, dt));
61      }
62    }
63
64    public void AddPoint(double point) {
65      dtRow.Values.Add(point);
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.