Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1886 fixed cloning and made helper classes items

File size: 2.4 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    private ResultCollection resultsCol;
33    private string chartName;
34    private string dataRowName;
35    private DataRow dtRow;
36
37    [StorableConstructor]
38    private DataTableHelper(bool deserializing) : base(deserializing) { }
39    private DataTableHelper(DataTableHelper original, Cloner cloner)
40      : base(original, cloner) {
41      resultsCol = original.resultsCol;
42      chartName = original.chartName;
43      dataRowName = original.dataRowName;
44      dtRow = (DataRow)original.dtRow.Clone(cloner);
45    }
46    public DataTableHelper() : base() { }
47
48    public override IDeepCloneable Clone(Cloner cloner) {
49      return new DataTableHelper(this, cloner);
50    }
51
52    public void InitializeChart(ResultCollection results, string chartName, string dataRowName) {
53      if (!results.ContainsKey(chartName)) {
54        this.resultsCol = results;
55        this.chartName = chartName;
56        this.dataRowName = dataRowName;
57
58        DataTable dt = new DataTable(chartName);
59        dtRow = new DataRow(dataRowName);
60        dt.Rows.Add(dtRow);
61        results.Add(new Result(chartName, dt));
62      }
63    }
64
65    public void AddPoint(double point) {
66      dtRow.Values.Add(point);
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.