Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/23/09 16:43:34 (15 years ago)
Author:
swagner
Message:

Refactored cloning (#806)

Location:
trunk/sources/HeuristicLab.Operators/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs

    r2520 r2526  
    8787    /// (System.Collections.Generic.IDictionary<System.Guid, object>)"/>
    8888    /// of base class <see cref="DelegatingOperator"/>.<br/>
    89     /// Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     89    /// Deep clone through <see cref="cloner.Clone"/> method of helper class
    9090    /// <see cref="Auxiliary"/>.</remarks>
    9191    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    9292    /// <returns>The cloned object as <see cref="CombinedOperator"/>.</returns>
    93     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    94       CombinedOperator clone = (CombinedOperator)base.Clone(clonedObjects);
     93    public override IItem Clone(ICloner cloner) {
     94      CombinedOperator clone = (CombinedOperator)base.Clone(cloner);
    9595      clone.myDescription = Description;
    96       clone.myOperatorGraph = (IOperatorGraph)Auxiliary.Clone(OperatorGraph, clonedObjects);
     96      clone.myOperatorGraph = (IOperatorGraph)cloner.Clone(OperatorGraph);
    9797      return clone;
    9898    }
  • trunk/sources/HeuristicLab.Operators/3.3/DelegatingOperator.cs

    r1530 r2526  
    3131  /// </summary>
    3232  public abstract class DelegatingOperator : OperatorBase {
     33    private Guid myGuid;
     34    protected Guid Guid {
     35      get { return myGuid; }
     36    }
     37
     38    protected DelegatingOperator()
     39      : base() {
     40      myGuid = Guid.NewGuid();
     41    }
     42
     43    public override IItem Clone(ICloner cloner) {
     44      DelegatingOperator clone = (DelegatingOperator)base.Clone(cloner);
     45      clone.myGuid = Guid;
     46      return clone;
     47    }
     48
    3349    /// <summary>
    3450    /// Executes the specified operator in the given <paramref name="scope"/>.
  • trunk/sources/HeuristicLab.Operators/3.3/VariableInjector.cs

    r2520 r2526  
    5353    /// Clones the current instance (deep clone).
    5454    /// </summary>
    55     /// <remarks>Deep clone performed with <see cref="Auxiliary.Clone"/> of helper class
     55    /// <remarks>Deep clone performed with <see cref="cloner.Clone"/> of helper class
    5656    /// <see cref="Auxiliary"/>.</remarks>
    5757    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    5858    /// <returns>The cloned object as <see cref="VariableInjector"/>.</returns>
    59     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     59    public override IItem Clone(ICloner cloner) {
    6060      VariableInjector clone = new VariableInjector();
    61       clonedObjects.Add(Guid, clone);
     61      cloner.RegisterClonedObject(this, clone);
    6262      clone.Name = Name;
    6363      foreach (IVariable variable in Variables)
    64         clone.AddVariable((IVariable)Auxiliary.Clone(variable, clonedObjects));
     64        clone.AddVariable((IVariable)cloner.Clone(variable));
    6565      return clone;
    6666    }
Note: See TracChangeset for help on using the changeset viewer.