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

    r438 r887  
    4747      }
    4848    }
     49
     50    /// <summary>
     51    /// Default constructor
     52    /// </summary>
     53    public DistributedEngine() { }
     54
     55    /// <summary>
     56    /// Copy constructor to create deep clones.
     57    /// </summary>
     58    /// <param name="original">The instance to be cloned.</param>
     59    public DistributedEngine(DistributedEngine original) : this(original, new Dictionary<Guid, object>()) { }
     60
     61    /// <summary>
     62    /// Copy constructor for DistributedEngine clones (deep clone) reusing already cloned object references
     63    /// </summary>
     64    /// <remarks>Calls the copy constructor of the base class <see cref="EngineBase"/></remarks>
     65    /// <param name="original">Instance to be cloned</param>
     66    /// <param name="clonedObjects">Already cloned object reference</param>
     67    protected DistributedEngine(DistributedEngine original, IDictionary<Guid, object> clonedObjects)
     68      : base(original, clonedObjects) {
     69      this.ServerAddress = original.ServerAddress;
     70    }
     71    /// <summary>
     72    /// Creates a deep clone with the copy constructor reusing already cloned
     73    /// object references.
     74    /// </summary>
     75    /// <param name="clonedObjects">Already cloned objects (for referential integrity).</param>
     76    /// <returns>The cloned instance.</returns>
    4977    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    50       DistributedEngine clone = (DistributedEngine)base.Clone(clonedObjects);
    51       clone.ServerAddress = serverAddress;
    52       return clone;
     78      return new DistributedEngine(this, clonedObjects);
    5379    }
    5480
     
    313339    }
    314340
     341
    315342    #region Persistence Methods
    316343    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
Note: See TracChangeset for help on using the changeset viewer.