Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (13 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Data/3.3/BoolArray.cs

    r3431 r4722  
    2929  [StorableClass]
    3030  public class BoolArray : ValueTypeArray<bool>, IStringConvertibleArray {
     31    [StorableConstructor]
     32    protected BoolArray(bool deserializing) : base(deserializing) { }
     33    protected BoolArray(BoolArray original, Cloner cloner)
     34      : base(original, cloner) {
     35    }
    3136    public BoolArray() : base() { }
    3237    public BoolArray(int length) : base(length) { }
     
    3439
    3540    public override IDeepCloneable Clone(Cloner cloner) {
    36       BoolArray clone = new BoolArray(array);
    37       cloner.RegisterClonedObject(this, clone);
    38       clone.readOnly = readOnly;
    39       return clone;
     41      return new BoolArray(this, cloner);
    4042    }
    4143
  • trunk/sources/HeuristicLab.Data/3.3/BoolMatrix.cs

    r3431 r4722  
    3030  [StorableClass]
    3131  public class BoolMatrix : ValueTypeMatrix<bool>, IStringConvertibleMatrix {
     32    [StorableConstructor]
     33    protected BoolMatrix(bool deserializing) : base(deserializing) { }
     34    protected BoolMatrix(BoolMatrix original, Cloner cloner)
     35      : base(original, cloner) {
     36    }
    3237    public BoolMatrix() : base() { }
    3338    public BoolMatrix(int rows, int columns) : base(rows, columns) { }
     
    3944
    4045    public override IDeepCloneable Clone(Cloner cloner) {
    41       BoolMatrix clone = new BoolMatrix();
    42       cloner.RegisterClonedObject(this, clone);
    43       clone.matrix = (bool[,])matrix.Clone();
    44       clone.columnNames = new List<string>(columnNames);
    45       clone.rowNames = new List<string>(rowNames);
    46       clone.sortableView = sortableView;
    47       clone.readOnly = readOnly;
    48       return clone;
     46      return new BoolMatrix(this, cloner);
    4947    }
    5048
  • trunk/sources/HeuristicLab.Data/3.3/BoolValue.cs

    r4477 r4722  
    3535    }
    3636
     37    protected BoolValue(BoolValue original, Cloner cloner)
     38      : base(original, cloner) {
     39    }
    3740    public BoolValue() : base() { }
    38     public BoolValue(bool value) : base(value) { }
     41    [StorableConstructor]
     42    public BoolValue(bool value)
     43      : base(value) {
     44      //mkommend: Be aware that the base call refers to the storable ctor => the value is set explicitly in the ctor body.
     45      //          This should not affect the persistence, because first the ctor is called and afterwards the values are set by reflection.
     46      this.value = value;
     47    }
    3948
    4049    public override IDeepCloneable Clone(Cloner cloner) {
    41       BoolValue clone = new BoolValue(value);
    42       cloner.RegisterClonedObject(this, clone);
    43       clone.readOnly = readOnly;
    44       return clone;
     50      return new BoolValue(this, cloner);
    4551    }
    4652
  • trunk/sources/HeuristicLab.Data/3.3/Comparison.cs

    r3431 r4722  
    3434    }
    3535
     36    [StorableConstructor]
     37    protected Comparison(bool deserializing) : base(deserializing) { }
     38    protected Comparison(Comparison original, Cloner cloner)
     39      : base(original, cloner) {
     40    }
    3641    public Comparison() : base() { }
    3742    public Comparison(ComparisonType value) : base(value) { }
    3843
    3944    public override IDeepCloneable Clone(Cloner cloner) {
    40       Comparison clone = new Comparison(value);
    41       cloner.RegisterClonedObject(this, clone);
    42       clone.readOnly = readOnly;
    43       return clone;
     45      return new Comparison(this, cloner);
    4446    }
    4547
  • trunk/sources/HeuristicLab.Data/3.3/DateTimeValue.cs

    r3431 r4722  
    2929  [StorableClass]
    3030  public class DateTimeValue : ValueTypeValue<DateTime>, IComparable, IStringConvertibleValue {
     31    [StorableConstructor]
     32    protected DateTimeValue(bool deserializing) : base(deserializing) { }
     33    protected DateTimeValue(DateTimeValue original, Cloner cloner)
     34      : base(original, cloner) {
     35    }
    3136    public DateTimeValue() : base() { }
    3237    public DateTimeValue(DateTime value) : base(value) { }
    3338
    3439    public override IDeepCloneable Clone(Cloner cloner) {
    35       DateTimeValue clone = new DateTimeValue(value);
    36       cloner.RegisterClonedObject(this, clone);
    37       clone.readOnly = readOnly;
    38       return clone;
     40      return new DateTimeValue(this, cloner);
    3941    }
    4042
  • trunk/sources/HeuristicLab.Data/3.3/DoubleArray.cs

    r3431 r4722  
    2929  [StorableClass]
    3030  public class DoubleArray : ValueTypeArray<double>, IStringConvertibleArray {
     31    [StorableConstructor]
     32    protected DoubleArray(bool deserializing) : base(deserializing) { }
     33    protected DoubleArray(DoubleArray original, Cloner cloner)
     34      : base(original, cloner) {
     35    }
    3136    public DoubleArray() : base() { }
    3237    public DoubleArray(int length) : base(length) { }
     
    3439
    3540    public override IDeepCloneable Clone(Cloner cloner) {
    36       DoubleArray clone = new DoubleArray(array);
    37       cloner.RegisterClonedObject(this, clone);
    38       clone.readOnly = readOnly;
    39       return clone;
     41      return new DoubleArray(this, cloner);
    4042    }
    4143
  • trunk/sources/HeuristicLab.Data/3.3/DoubleMatrix.cs

    r3431 r4722  
    3030  [StorableClass]
    3131  public class DoubleMatrix : ValueTypeMatrix<double>, IStringConvertibleMatrix {
     32    [StorableConstructor]
     33    protected DoubleMatrix(bool deserializing) : base(deserializing) { }
     34    protected DoubleMatrix(DoubleMatrix original, Cloner cloner)
     35      : base(original, cloner) {
     36    }
    3237    public DoubleMatrix() : base() { }
    3338    public DoubleMatrix(int rows, int columns) : base(rows, columns) { }
     
    3944
    4045    public override IDeepCloneable Clone(Cloner cloner) {
    41       DoubleMatrix clone = new DoubleMatrix();
    42       cloner.RegisterClonedObject(this, clone);
    43       clone.matrix = (double[,])matrix.Clone();
    44       clone.columnNames = new List<string>(columnNames);
    45       clone.rowNames = new List<string>(rowNames);
    46       clone.sortableView = sortableView;
    47       clone.readOnly = readOnly;
    48       return clone;
     46      return new DoubleMatrix(this, cloner);
    4947    }
    5048
  • trunk/sources/HeuristicLab.Data/3.3/DoubleValue.cs

    r4477 r4722  
    3535    }
    3636
     37    [StorableConstructor]
     38    protected DoubleValue(bool deserializing) : base(deserializing) { }
     39    protected DoubleValue(DoubleValue original, Cloner cloner)
     40      : base(original, cloner) {
     41    }
    3742    public DoubleValue() : base() { }
    3843    public DoubleValue(double value) : base(value) { }
    3944
    4045    public override IDeepCloneable Clone(Cloner cloner) {
    41       DoubleValue clone = new DoubleValue(value);
    42       cloner.RegisterClonedObject(this, clone);
    43       clone.readOnly = readOnly;
    44       return clone;
     46      return new DoubleValue(this, cloner);
    4547    }
    4648
  • trunk/sources/HeuristicLab.Data/3.3/IntArray.cs

    r4477 r4722  
    2929  [StorableClass]
    3030  public class IntArray : ValueTypeArray<int>, IStringConvertibleArray {
     31    [StorableConstructor]
     32    protected IntArray(bool deserializing) : base(deserializing) { }
     33    protected IntArray(IntArray original, Cloner cloner)
     34      : base(original, cloner) {
     35    }
    3136    public IntArray() : base() { }
    3237    public IntArray(int length) : base(length) { }
     
    3439
    3540    public override IDeepCloneable Clone(Cloner cloner) {
    36       IntArray clone = new IntArray(array);
    37       cloner.RegisterClonedObject(this, clone);
    38       clone.readOnly = readOnly;
    39       return clone;
     41      return new IntArray(this, cloner);
    4042    }
    4143
  • trunk/sources/HeuristicLab.Data/3.3/IntMatrix.cs

    r4477 r4722  
    3030  [StorableClass]
    3131  public class IntMatrix : ValueTypeMatrix<int>, IStringConvertibleMatrix {
     32    [StorableConstructor]
     33    protected IntMatrix(bool deserializing) : base(deserializing) { }
     34    protected IntMatrix(IntMatrix original, Cloner cloner)
     35      : base(original, cloner) {
     36    }
    3237    public IntMatrix() : base() { }
    3338    public IntMatrix(int rows, int columns) : base(rows, columns) { }
     
    3944
    4045    public override IDeepCloneable Clone(Cloner cloner) {
    41       IntMatrix clone = new IntMatrix();
    42       cloner.RegisterClonedObject(this, clone);
    43       clone.matrix = (int[,])matrix.Clone();
    44       clone.columnNames = new List<string>(columnNames);
    45       clone.rowNames = new List<string>(rowNames);
    46       clone.sortableView = sortableView;
    47       clone.readOnly = readOnly;
    48       return clone;
     46      return new IntMatrix(this, cloner);
    4947    }
    5048
  • trunk/sources/HeuristicLab.Data/3.3/IntValue.cs

    r4477 r4722  
    3535    }
    3636
     37    [StorableConstructor]
     38    protected IntValue(bool deserializing) : base(deserializing) { }
     39    protected IntValue(IntValue original, Cloner cloner)
     40      : base(original, cloner) {
     41    }
    3742    public IntValue() : base() { }
    3843    public IntValue(int value) : base(value) { }
    3944
    4045    public override IDeepCloneable Clone(Cloner cloner) {
    41       IntValue clone = new IntValue(value);
    42       cloner.RegisterClonedObject(this, clone);
    43       clone.readOnly = readOnly;
    44       return clone;
     46      return new IntValue(this, cloner);
    4547    }
    4648
  • trunk/sources/HeuristicLab.Data/3.3/PercentValue.cs

    r4068 r4722  
    2828  [StorableClass]
    2929  public class PercentValue : DoubleValue {
     30    [StorableConstructor]
     31    protected PercentValue(bool deserializing) : base(deserializing) { }
     32    protected PercentValue(PercentValue original, Cloner cloner)
     33      : base(original, cloner) {
     34    }
    3035    public PercentValue() : base() { }
    3136    public PercentValue(double value) : base(value) { }
    3237
    3338    public override IDeepCloneable Clone(Cloner cloner) {
    34       PercentValue clone = new PercentValue(value);
    35       cloner.RegisterClonedObject(this, clone);
    36       clone.readOnly = readOnly;
    37       return clone;
     39      return new PercentValue(this, cloner);
    3840    }
    3941
  • trunk/sources/HeuristicLab.Data/3.3/StringArray.cs

    r4068 r4722  
    7070    }
    7171
     72    [StorableConstructor]
     73    protected StringArray(bool deserializing) : base(deserializing) { }
     74    protected StringArray(StringArray original, Cloner cloner)
     75      : base(original, cloner) {
     76      this.array = (string[])original.array.Clone();
     77      this.readOnly = original.readOnly;
     78    }
    7279    public StringArray() {
    7380      array = new string[0];
     
    8996
    9097    public override IDeepCloneable Clone(Cloner cloner) {
    91       StringArray clone = new StringArray();
    92       cloner.RegisterClonedObject(this, clone);
    93       clone.array = (string[])array.Clone();
    94       clone.readOnly = readOnly;
    95       return clone;
     98      return new StringArray(this, cloner);
    9699    }
    97100
  • trunk/sources/HeuristicLab.Data/3.3/StringMatrix.cs

    r3431 r4722  
    134134    }
    135135
     136    [StorableConstructor]
     137    protected StringMatrix(bool deserializing) : base(deserializing) { }
     138    protected StringMatrix(StringMatrix original, Cloner cloner)
     139      : base(original, cloner) {
     140      this.matrix = (string[,])original.matrix.Clone();
     141      this.columnNames = new List<string>(original.columnNames);
     142      this.rowNames = new List<string>(original.rowNames);
     143      this.sortableView = original.sortableView;
     144      this.readOnly = original.readOnly;
     145    }
    136146    public StringMatrix() {
    137147      matrix = new string[0, 0];
     
    182192
    183193    public override IDeepCloneable Clone(Cloner cloner) {
    184       StringMatrix clone = new StringMatrix();
    185       cloner.RegisterClonedObject(this, clone);
    186       clone.matrix = (string[,])matrix.Clone();
    187       clone.columnNames = new List<string>(columnNames);
    188       clone.rowNames = new List<string>(rowNames);
    189       clone.sortableView = sortableView;
    190       clone.readOnly = readOnly;
    191       return clone;
     194      return new StringMatrix(this, cloner);
    192195    }
    193196
  • trunk/sources/HeuristicLab.Data/3.3/StringValue.cs

    r4477 r4722  
    5555    }
    5656
     57    [StorableConstructor]
     58    protected StringValue(bool deserializing) : base(deserializing) { }
     59    protected StringValue(StringValue original, Cloner cloner)
     60      : base(original, cloner) {
     61      this.value = original.value != null ? original.value : string.Empty;
     62      this.readOnly = original.readOnly;
     63    }
    5764    public StringValue() {
    5865      this.value = string.Empty;
     
    6572
    6673    public override IDeepCloneable Clone(Cloner cloner) {
    67       StringValue clone = new StringValue(value);
    68       cloner.RegisterClonedObject(this, clone);
    69       clone.readOnly = readOnly;
    70       return clone;
     74      return new StringValue(this, cloner);
    7175    }
    7276
  • trunk/sources/HeuristicLab.Data/3.3/TimeSpanValue.cs

    r3431 r4722  
    3030  [StorableClass]
    3131  public class TimeSpanValue : ValueTypeValue<TimeSpan>, IComparable, IStringConvertibleValue {
     32    [StorableConstructor]
     33    protected TimeSpanValue(bool deserializing) : base(deserializing) { }
     34    protected TimeSpanValue(TimeSpanValue original, Cloner cloner)
     35      : base(original, cloner) {
     36    }
    3237    public TimeSpanValue() : base() { }
    3338    public TimeSpanValue(TimeSpan value) : base(value) { }
    3439
    3540    public override IDeepCloneable Clone(Cloner cloner) {
    36       TimeSpanValue clone = new TimeSpanValue(value);
    37       cloner.RegisterClonedObject(this, clone);
    38       clone.readOnly = readOnly;
    39       return clone;
     41      return new TimeSpanValue(this, cloner);
    4042    }
    4143
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeArray.cs

    r3822 r4722  
    6868    }
    6969
     70    [StorableConstructor]
     71    protected ValueTypeArray(bool deserializing) : base(deserializing) { }
     72    protected ValueTypeArray(ValueTypeArray<T> original, Cloner cloner)
     73      : base(original, cloner) {
     74      this.array = (T[])original.array.Clone();
     75      this.readOnly = original.readOnly;
     76    }
    7077    protected ValueTypeArray() {
    7178      array = new T[0];
     
    8087      array = (T[])elements.Clone();
    8188      readOnly = false;
    82     }
    83 
    84     public override IDeepCloneable Clone(Cloner cloner) {
    85       ValueTypeArray<T> clone = (ValueTypeArray<T>)base.Clone(cloner);
    86       clone.array = (T[])array.Clone();
    87       clone.readOnly = readOnly;
    88       return clone;
    8989    }
    9090
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrix.cs

    r3822 r4722  
    132132    }
    133133
     134    [StorableConstructor]
     135    protected ValueTypeMatrix(bool deserializing) : base(deserializing) { }
     136    protected ValueTypeMatrix(ValueTypeMatrix<T> original, Cloner cloner)
     137      : base(original, cloner) {
     138      this.matrix = (T[,])original.matrix.Clone();
     139      this.columnNames = new List<string>(original.columnNames);
     140      this.rowNames = new List<string>(original.rowNames);
     141      this.sortableView = original.sortableView;
     142      this.readOnly = original.readOnly;
     143    }
    134144    protected ValueTypeMatrix() {
    135145      matrix = new T[0, 0];
     
    169179      : this(elements,columnNames) {
    170180      RowNames = rowNames;
    171     }
    172 
    173     public override IDeepCloneable Clone(Cloner cloner) {
    174       ValueTypeMatrix<T> clone = (ValueTypeMatrix<T>)base.Clone(cloner);
    175       clone.matrix = (T[,])matrix.Clone();
    176       clone.columnNames = new List<string>(columnNames);
    177       clone.rowNames = new List<string>(rowNames);
    178       clone.sortableView = sortableView;
    179       clone.readOnly = readOnly;
    180       return clone;
    181181    }
    182182
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeValue.cs

    r3822 r4722  
    5353    }
    5454
     55    [StorableConstructor]
     56    protected ValueTypeValue(bool deserializing) : base(deserializing) { }
     57    protected ValueTypeValue(ValueTypeValue<T> original, Cloner cloner)
     58      : base(original, cloner) {
     59      this.value = original.value;
     60      this.readOnly = original.readOnly;
     61    }
    5562    protected ValueTypeValue() {
    5663      this.value = default(T);
     
    6067      this.value = value;
    6168      this.readOnly = false;
    62     }
    63 
    64     public override IDeepCloneable Clone(Cloner cloner) {
    65       ValueTypeValue<T> clone = (ValueTypeValue<T>)base.Clone(cloner);
    66       clone.value = value;
    67       clone.readOnly = readOnly;
    68       return clone;
    6969    }
    7070
Note: See TracChangeset for help on using the changeset viewer.