Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/15/09 02:18:42 (15 years ago)
Author:
swagner
Message:

Refactoring of the operator architecture (#95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/CloneableBase.cs

    r2033 r2042  
    3131  /// </summary>
    3232  public abstract class CloneableBase : ICloneable {
    33     /// <summary>
    34     /// Gets a unique id (memory address) of the current instance. The id is used to
    35     /// detect, if an object has already been cloned or not.
    36     /// </summary>
    37     public long Id {
    38       get {
    39         GCHandle handle = new GCHandle();
    40         handle.Target = this;
    41         return GCHandle.ToIntPtr(handle).ToInt64();
    42       }
    43     }
    44 
    45     /// <summary>
    46     /// Clones the current instance (deep clone).
    47     /// </summary>
    48     /// <remarks>Uses the <see cref="Auxiliary.Clone"/> method of the class <see cref="Auxiliary"/>.</remarks>
    49     /// <returns>The clone.</returns>
    5033    public object Clone() {
    51       return Auxiliary.Clone(this, new Dictionary<long, object>());
     34      return Clone(new Cloner());
    5235    }
    5336    /// <summary>
     
    5740    /// <param name="clonedObjects">All already cloned objects.</param>
    5841    /// <returns>The clone.</returns>
    59     public virtual object Clone(IDictionary<long, object> clonedObjects) {
     42    public virtual ICloneable Clone(ICloner cloner) {
    6043      CloneableBase clone = (CloneableBase)Activator.CreateInstance(this.GetType());
    61       clonedObjects.Add(clone.Id, clone);
     44      cloner.AddClonedObject(this, clone);
    6245      return clone;
    6346    }
Note: See TracChangeset for help on using the changeset viewer.