#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections; using System.Collections.Generic; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Problems.DataAnalysis; namespace HeuristicLab.DataPreprocessing { [Item("EditableDataset", "Represents a editable dataset containing data that should be analyzed.")] [StorableClass] public class EditableDataset : Dataset { [StorableConstructor] private EditableDataset(bool deserializing) : base(deserializing) { } private EditableDataset(Dataset original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new EditableDataset(this, cloner); } public EditableDataset() : base() { } public EditableDataset(IEnumerable variableNames, IEnumerable variableValues) : base(variableNames, variableValues) { } public EditableDataset(IEnumerable variableNames, double[,] variableValues) : base(variableNames, variableValues) { } #region IStringConvertibleMatrix Members public override bool ReadOnly { get { return false; } } public override bool SetValue(string value, int rowIndex, int columnIndex) { var values = variableValues[variableNames[columnIndex]]; object insertValue = null; if (values is List) insertValue = Double.Parse(value); else if (values is List) insertValue = value; else if (values is List) insertValue = DateTime.Parse(value); else throw new ArgumentException("The variable values must be of type double, string or DateTime"); variableValues[variableNames[columnIndex]][rowIndex] = insertValue; return true; } #endregion } }