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/Log.cs

    r2 r887  
    4141    }
    4242
     43    /// <summary>
     44    /// Copy constructor to create deep clones.
     45    /// </summary>
     46    /// <param name="original">The instance to be cloned.</param>
     47    public Log(Log original) : this(original, new Dictionary<Guid, object>()) { }
     48    /// <summary>
     49    /// Copy constructor for DistributedEngine clones (deep clone) reusing already cloned object references
     50    /// </summary>
     51    /// <remarks>Calls the copy constructor of the base class <see cref="EngineBase"/></remarks>
     52    /// <param name="original">Instance to be cloned</param>
     53    /// <param name="clonedObjects">Already cloned object reference</param>
     54    protected Log(Log original, IDictionary<Guid, object> clonedObjects)
     55      : base(original, clonedObjects) {
     56      this.myItems = (ItemList)Auxiliary.Clone(original.Items, clonedObjects);
     57    }
    4358
     59    /// <summary>
     60    /// Creates a deep clone with the copy constructor reusing already cloned
     61    /// object references.
     62    /// </summary>
     63    /// <param name="clonedObjects">Already cloned objects (for referential integrity).</param>
     64    /// <returns>The cloned instance.</returns>
    4465    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    45       Log clone = (Log)base.Clone(clonedObjects);
    46       clone.myItems = (ItemList)Auxiliary.Clone(Items, clonedObjects);
    47       return clone;
     66      return new Log(this, clonedObjects);
    4867    }
    4968
Note: See TracChangeset for help on using the changeset viewer.