Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/02/08 21:10:17 (16 years ago)
Author:
gkronber
Message:

Refactored cloning in all plugins except: HL.Communication, HL.Hive, HL.GP, HL.Routing, HL.Scheduling, HL.SimOpt, HL.Visualization

#285 (Cloning could be improved by creating objects at the bottom of the cloning chain with 'new' instead of the top with Activator.CreateInstance())

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactorBranch/HeuristicLab.Logging/Linechart.cs

    r2 r887  
    5959    }
    6060
     61    /// <summary>
     62    /// Copy constructor to create deep clones.
     63    /// </summary>
     64    /// <param name="original">The instance to be cloned.</param>
     65    public Linechart(Linechart original) : this(original, new Dictionary<Guid, object>()) { }
    6166
     67
     68    /// <summary>
     69    /// Copy constructor for DistributedEngine clones (deep clone) reusing already cloned object references
     70    /// </summary>
     71    /// <remarks>Calls the copy constructor of the base class <see cref="EngineBase"/></remarks>
     72    /// <param name="original">Instance to be cloned</param>
     73    /// <param name="clonedObjects">Already cloned object reference</param>
     74    protected Linechart(Linechart original, IDictionary<Guid, object> clonedObjects)
     75      : base(original, clonedObjects) {
     76      this.myNumberOfLines = (IntData)Auxiliary.Clone(original.myNumberOfLines,clonedObjects);
     77      this.myValues = (ItemList)Auxiliary.Clone(original.Values, clonedObjects);
     78    }
     79
     80    /// <summary>
     81    /// Creates a deep clone with the copy constructor reusing already cloned
     82    /// object references.
     83    /// </summary>
     84    /// <param name="clonedObjects">Already cloned objects (for referential integrity).</param>
     85    /// <returns>The cloned instance.</returns>
    6286    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    63       Linechart clone = (Linechart)base.Clone(clonedObjects);
    64       clone.myNumberOfLines = (IntData)Auxiliary.Clone(myNumberOfLines, clonedObjects);
    65       clone.myValues = (ItemList)Auxiliary.Clone(Values, clonedObjects);
    66       return clone;
     87      return new Linechart(this, clonedObjects);
    6788    }
    6889
Note: See TracChangeset for help on using the changeset viewer.