Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2526 for trunk


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

Refactored cloning (#806)

Location:
trunk/sources
Files:
2 added
3 deleted
41 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.3/MainForm.cs

    r2520 r2526  
    4343    private class Task {
    4444      public string filename;
    45       public IStorable storable;
     45      public IItem item;
    4646      public IEditor editor;
    4747
    4848      private Task() { }
    49       public Task(string filename, IStorable storable, IEditor editor) {
     49      public Task(string filename, IItem item, IEditor editor) {
    5050        this.filename = filename;
    51         this.storable = storable;
     51        this.item = item;
    5252        this.editor = editor;
    5353      }
     
    156156      Task task = (Task)state;
    157157      try {
    158         task.storable = PersistenceManager.Load(task.filename);
     158        task.item = PersistenceManager.Load(task.filename);
    159159      } catch (FileNotFoundException fileNotFoundEx) {
    160160        MessageBox.Show("Sorry couldn't open file \"" + task.filename + "\".\nThe file or plugin \"" + fileNotFoundEx.FileName + "\" is not available.\nPlease make sure you have all necessary plugins installed.",
     
    177177      else {
    178178        IEditor editor = null;
    179         if (task.storable != null) {
    180           IEditable editable = task.storable as IEditable;
     179        if (task.item != null) {
     180          IEditable editable = task.item as IEditable;
    181181          if (editable != null)
    182182            editor = (IEditor)MainFormManager.CreateDefaultView(editable);
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorGraphView.cs

    r2524 r2526  
    221221        if (operatorsListView.SelectedItems.Count > 0) {
    222222          foreach (ListViewItem item in operatorsListView.SelectedItems)
    223             OperatorGraph.RemoveOperator(((IOperator)item.Tag).Guid);
     223            OperatorGraph.RemoveOperator((IOperator)item.Tag);
    224224        }
    225225      }
     
    261261      if (operatorsListView.SelectedItems.Count > 0) {
    262262        foreach (ListViewItem item in operatorsListView.SelectedItems)
    263           OperatorGraph.RemoveOperator(((IOperator)item.Tag).Guid);
     263          OperatorGraph.RemoveOperator((IOperator)item.Tag);
    264264      }
    265265    }
  • trunk/sources/HeuristicLab.Core/3.3/AtomicOperation.cs

    r1823 r2526  
    6969    /// </summary>
    7070    /// <remarks>The operator and the scope objects are cloned with the
    71     /// <see cref="HeuristicLab.Core.Auxiliary.Clone"/> method of the <see cref="Auxiliary"/> class.</remarks>
     71    /// <see cref="HeuristicLab.Core.cloner.Clone"/> method of the <see cref="Auxiliary"/> class.</remarks>
    7272    /// <param name="clonedObjects">All already cloned objects. (Needed to avoid cycles.)</param>
    7373    /// <returns>The cloned object as <see cref="AtomicOperation"/>.</returns>
    74     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     74    public override IItem Clone(ICloner cloner) {
    7575      AtomicOperation clone = new AtomicOperation();
    76       clonedObjects.Add(Guid, clone);
    77       clone.myOperator = (IOperator)Auxiliary.Clone(Operator, clonedObjects);
    78       clone.myScope = (IScope)Auxiliary.Clone(Scope, clonedObjects);
     76      cloner.RegisterClonedObject(this, clone);
     77      clone.myOperator = (IOperator)cloner.Clone(Operator);
     78      clone.myScope = (IScope)cloner.Clone(Scope);
    7979      return clone;
    8080    }
  • trunk/sources/HeuristicLab.Core/3.3/CompositeOperation.cs

    r1823 r2526  
    8181    /// </summary>
    8282    /// <remarks>All operations of the current instance are cloned, too (deep clone), with the
    83     /// <see cref="HeuristicLab.Core.Auxiliary.Clone"/> method of the class <see cref="Auxiliary"/>.</remarks>
     83    /// <see cref="HeuristicLab.Core.cloner.Clone"/> method of the class <see cref="Auxiliary"/>.</remarks>
    8484    /// <param name="clonedObjects">A dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    8585    /// <returns>The cloned operation as <see cref="CompositeOperation"/>.</returns>
    86     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     86    public override IItem Clone(ICloner cloner) {
    8787      CompositeOperation clone = new CompositeOperation();
    88       clonedObjects.Add(Guid, clone);
     88      cloner.RegisterClonedObject(this, clone);
    8989      clone.myExecuteInParallel = ExecuteInParallel;
    9090      for (int i = 0; i < Operations.Count; i++)
    91         clone.AddOperation((IOperation)Auxiliary.Clone(Operations[i], clonedObjects));
     91        clone.AddOperation((IOperation)cloner.Clone(Operations[i]));
    9292      return clone;
    9393    }
  • trunk/sources/HeuristicLab.Core/3.3/EngineBase.cs

    r2474 r2526  
    127127    /// Clones the current instance (deep clone).
    128128    /// </summary>
    129     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     129    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    130130    /// <see cref="Auxiliary"/>.</remarks>
    131131    /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
    132132    /// <returns>The cloned object as <see cref="EngineBase"/>.</returns>
    133     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    134       EngineBase clone = (EngineBase)base.Clone(clonedObjects);
    135       clone.myOperatorGraph = (IOperatorGraph)Auxiliary.Clone(OperatorGraph, clonedObjects);
    136       clone.myGlobalScope = (IScope)Auxiliary.Clone(GlobalScope, clonedObjects);
     133    public override IItem Clone(ICloner cloner) {
     134      EngineBase clone = (EngineBase)base.Clone(cloner);
     135      clone.myOperatorGraph = (IOperatorGraph)cloner.Clone(OperatorGraph);
     136      clone.myGlobalScope = (IScope)cloner.Clone(GlobalScope);
    137137      clone.myExecutionTime = ExecutionTime;
    138138      IOperation[] operations = new IOperation[ExecutionStack.Count];
    139139      ExecutionStack.CopyTo(operations, 0);
    140140      for (int i = operations.Length - 1; i >= 0; i--)
    141         clone.myExecutionStack.Push((IOperation)Auxiliary.Clone(operations[i], clonedObjects));
     141        clone.myExecutionStack.Push((IOperation)cloner.Clone(operations[i]));
    142142      clone.myRunning = Running;
    143143      clone.myCanceled = Canceled;
  • trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj

    r2524 r2526  
    9898  </ItemGroup>
    9999  <ItemGroup>
    100     <Compile Include="Auxiliary.cs" />
    101100    <Compile Include="AtomicOperation.cs" />
    102101    <Compile Include="CompositeOperation.cs" />
     102    <Compile Include="Cloner.cs" />
     103    <Compile Include="Interfaces\ICloner.cs" />
    103104    <Compile Include="Interfaces\IEditable.cs" />
    104105    <Compile Include="Interfaces\IOperation.cs" />
     
    119120    <Compile Include="Interfaces\IRandom.cs" />
    120121    <Compile Include="OperatorGraph.cs" />
    121     <Compile Include="StorableBase.cs" />
    122122    <Compile Include="Scope.cs" />
    123123    <Compile Include="EngineBase.cs" />
    124124    <Compile Include="Interfaces\IEngine.cs" />
    125125    <Compile Include="Interfaces\IOperator.cs" />
    126     <Compile Include="Interfaces\IStorable.cs" />
    127126    <Compile Include="PersistenceManager.cs" />
    128127    <Compile Include="HeuristicLabCorePlugin.cs" />
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IItem.cs

    r2520 r2526  
    2828  /// Interface to represent (almost) every HeuristicLab object (an object, an operator,...).
    2929  /// </summary>
    30   public interface IItem : IStorable {
     30  public interface IItem : ICloneable {
     31    /// <summary>
     32    /// Creates a deep clone of this item.
     33    /// </summary>
     34    /// <param name="cloner">The cloner which is responsible for keeping track of all already
     35    /// cloned objects.</param>
     36    /// <returns>A clone of this instance.</returns>
     37    IItem Clone(ICloner cloner);
     38
    3139    /// <summary>
    3240    /// Fires a new <c>Changed</c> event.
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IOperatorGraph.cs

    r2474 r2526  
    4949    /// </summary>
    5050    /// <param name="guid">The unique id of the operator to remove.</param>
    51     void RemoveOperator(Guid guid);
    52     /// <summary>
    53     /// Gets the operator with the specified <paramref name="guid"/>.
    54     /// </summary>
    55     /// <param name="guid">The unique id of the operator.</param>
    56     /// <returns>The searched operator.</returns>
    57     IOperator GetOperator(Guid guid);
     51    void RemoveOperator(IOperator op);
    5852    /// <summary>
    5953    /// Clears the current instance.
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IOperatorGroup.cs

    r776 r2526  
    2929  /// Interface to represent a group of operators.
    3030  /// </summary>
    31   public interface IOperatorGroup : IStorable {
     31  public interface IOperatorGroup : IItem {
    3232    /// <summary>
    3333    /// Gets or sets the name of the current instance.
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IScope.cs

    r2474 r2526  
    130130    void ReorderSubScopes(int[] sequence);
    131131    /// <summary>
    132     /// Gets the sub scope with the given <paramref name="guid"/>.
    133     /// </summary>
    134     /// <param name="guid">The unique identifier of the sub scope.</param>
    135     /// <returns>The sub scope with the given <paramref name="guid"/>.</returns>
    136     IScope GetScope(Guid guid);
    137     /// <summary>
    138132    /// Gets the sub scope with the given <paramref name="name"/>.
    139133    /// </summary>
  • trunk/sources/HeuristicLab.Core/3.3/ItemBase.cs

    r2520 r2526  
    3131  /// </summary>
    3232  [EmptyStorableClass]
    33   public abstract class ItemBase : StorableBase, IItem {
     33  public abstract class ItemBase : IItem {
     34    /// <summary>
     35    /// Creates a deep clone of this instance.
     36    /// </summary>
     37    /// <remarks>
     38    /// This method is the entry point for creating a deep clone of a whole object graph.
     39    /// </remarks>
     40    /// <returns>A clone of this instance.</returns>
     41    public object Clone() {
     42      return Clone(new Cloner());
     43    }
     44
     45    /// <summary>
     46    /// Creates a deep clone of this instance.
     47    /// </summary>
     48    /// <remarks>This method should not be called directly. It is used for creating clones of
     49    /// objects which are contained in the object that is currently cloned.</remarks>
     50    /// <param name="cloner">The cloner which is responsible for keeping track of all already
     51    /// cloned objects.</param>
     52    /// <returns>A clone of this instance.</returns>
     53    public virtual IItem Clone(ICloner cloner) {
     54      ItemBase clone = (ItemBase)Activator.CreateInstance(this.GetType());
     55      cloner.RegisterClonedObject(this, clone);
     56      return clone;
     57    }
     58
    3459    /// <summary>
    3560    /// Gets the string representation of the current instance.
  • trunk/sources/HeuristicLab.Core/3.3/OperatorBase.cs

    r2524 r2526  
    131131    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    132132    /// <returns>The cloned object as <see cref="OperatorBase"/>.</returns>
    133     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    134       OperatorBase clone = (OperatorBase)base.Clone(clonedObjects);
     133    public override IItem Clone(ICloner cloner) {
     134      OperatorBase clone = (OperatorBase)base.Clone(cloner);
    135135      clone.myName = Name;
    136136      clone.mySubOperators.Clear();
    137137      for (int i = 0; i < SubOperators.Count; i++)
    138         clone.AddSubOperator((IOperator)Auxiliary.Clone(SubOperators[i], clonedObjects));
     138        clone.AddSubOperator((IOperator)cloner.Clone(SubOperators[i]));
    139139      clone.myVariableInfos.Clear();
    140140      foreach (IVariableInfo variableInfo in myVariableInfos.Values)
    141         clone.AddVariableInfo((IVariableInfo)Auxiliary.Clone(variableInfo, clonedObjects));
     141        clone.AddVariableInfo((IVariableInfo)cloner.Clone(variableInfo));
    142142      clone.myVariables.Clear();
    143143      foreach (IVariable variable in myVariables.Values)
    144         clone.AddVariable((IVariable)Auxiliary.Clone(variable, clonedObjects));
     144        clone.AddVariable((IVariable)cloner.Clone(variable));
    145145      return clone;
    146146    }
  • trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs

    r2520 r2526  
    3434
    3535    [Storable]
    36     private IDictionary<Guid, IOperator> myOperators;
     36    private IDictionary<IOperator, IOperator> myOperators;
    3737    /// <summary>
    3838    /// Gets all operators of the current instance.
     
    6262    /// </summary>
    6363    public OperatorGraph() {
    64       myOperators = new Dictionary<Guid, IOperator>();
     64      myOperators = new Dictionary<IOperator, IOperator>();
    6565    }
    6666
     
    6868    /// Clones the current instance (deep clone).
    6969    /// </summary>
    70     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     70    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    7171    /// <see cref="Auxiliary"/>.</remarks>
    7272    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    7373    /// <returns>The cloned object as <see cref="OperatorGraph"/>.</returns>
    74     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     74    public override IItem Clone(ICloner cloner) {
    7575      OperatorGraph clone = new OperatorGraph();
    76       clonedObjects.Add(Guid, clone);
     76      cloner.RegisterClonedObject(this, clone);
    7777      foreach (IOperator op in Operators)
    78         clone.AddOperator((IOperator)Auxiliary.Clone(op, clonedObjects));
     78        clone.AddOperator((IOperator)cloner.Clone(op));
    7979      if (InitialOperator != null)
    80         clone.myInitialOperator = (IOperator)Auxiliary.Clone(InitialOperator, clonedObjects);
     80        clone.myInitialOperator = (IOperator)cloner.Clone(InitialOperator);
    8181      return clone;
    8282    }
     
    8585    /// <remarks>Calls <see cref="OnOperatorAdded"/>.</remarks>
    8686    public void AddOperator(IOperator op) {
    87       if (!myOperators.ContainsKey(op.Guid)) {
    88         myOperators.Add(op.Guid, op);
     87      if (!myOperators.ContainsKey(op)) {
     88        myOperators.Add(op, op);
    8989        OnOperatorAdded(op);
    9090
     
    9595    /// <inheritdoc/>
    9696    /// <remarks>Calls <see cref="OnOperatorRemoved"/>.</remarks>
    97     public void RemoveOperator(Guid guid) {
    98       IOperator op = GetOperator(guid);
    99       if (op != null) {
     97    public void RemoveOperator(IOperator op) {
     98      if (myOperators.ContainsKey(op)) {
    10099        foreach (IOperator o in Operators) {
    101100          int i = 0;
     
    109108        if (InitialOperator == op)
    110109          InitialOperator = null;
    111         myOperators.Remove(op.Guid);
     110        myOperators.Remove(op);
    112111        OnOperatorRemoved(op);
    113112      }
    114113    }
    115114    /// <inheritdoc/>
    116     public IOperator GetOperator(Guid guid) {
    117       IOperator op;
    118       if (myOperators.TryGetValue(guid, out op))
    119         return op;
    120       else
    121         return null;
    122     }
    123     /// <inheritdoc/>
    124115    public void Clear() {
    125       Guid[] guids = new Guid[Operators.Count];
     116      IOperator[] ops = new IOperator[Operators.Count];
    126117      int i = 0;
    127118      foreach (IOperator op in Operators) {
    128         guids[i] = op.Guid;
     119        ops[i] = op;
    129120        i++;
    130121      }
    131       for (int j = 0; j < guids.Length; j++)
    132         RemoveOperator(guids[j]);
     122      for (int j = 0; j < ops.Length; j++)
     123        RemoveOperator(ops[j]);
    133124    }
    134125
  • trunk/sources/HeuristicLab.Core/3.3/OperatorGroup.cs

    r1823 r2526  
    3030  /// Representation of a group of operators (can also include subgroups).
    3131  /// </summary>
    32   public class OperatorGroup : StorableBase, IOperatorGroup {
     32  public class OperatorGroup : ItemBase, IOperatorGroup {
    3333
    3434    [Storable]
     
    8080    /// Clones the current instance (deep clone).
    8181    /// </summary>
    82     /// <remarks>Deep clone with <see cref="Auxiliary.Clone"/> method of helper class
     82    /// <remarks>Deep clone with <see cref="cloner.Clone"/> method of helper class
    8383    /// <see cref="Auxiliary"/>.</remarks>
    8484    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    8585    /// <returns>The cloned object as <see cref="OperatorGroup"/>.</returns>
    86     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    87       OperatorGroup clone = (OperatorGroup)base.Clone(clonedObjects);
     86    public override IItem Clone(ICloner cloner) {
     87      OperatorGroup clone = (OperatorGroup)base.Clone(cloner);
    8888      clone.myName = Name;
    8989      foreach (IOperatorGroup group in SubGroups)
    90         clone.AddSubGroup((IOperatorGroup)Auxiliary.Clone(group, clonedObjects));
     90        clone.AddSubGroup((IOperatorGroup)cloner.Clone(group));
    9191      foreach (IOperator op in Operators)
    92         clone.AddOperator((IOperator)Auxiliary.Clone(op, clonedObjects));
     92        clone.AddOperator((IOperator)cloner.Clone(op));
    9393      return clone;
    9494    }
  • trunk/sources/HeuristicLab.Core/3.3/OperatorLibrary.cs

    r2520 r2526  
    5151    /// Clones the current instance (deep clone).
    5252    /// </summary>
    53     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     53    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    5454    /// <see cref="Auxiliary"/>.</remarks>
    5555    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    5656    /// <returns>The cloned object as <see cref="OperatorLibrary"/>.</returns>
    57     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     57    public override IItem Clone(ICloner cloner) {
    5858      OperatorLibrary clone = new OperatorLibrary();
    59       clonedObjects.Add(Guid, clone);
    60       clone.myGroup = (IOperatorGroup)Auxiliary.Clone(Group, clonedObjects);
     59      cloner.RegisterClonedObject(this, clone);
     60      clone.myGroup = (IOperatorGroup)cloner.Clone(Group);
    6161      return clone;
    6262    }
  • trunk/sources/HeuristicLab.Core/3.3/PersistenceManager.cs

    r1895 r2526  
    4141    /// <param name="instance">The object that should be saved.</param>
    4242    /// <param name="filename">The name of the file where the <paramref name="object"/> should be saved.</param>
    43     public static void Save(IStorable instance, string filename) {
     43    public static void Save(IItem instance, string filename) {
    4444      XmlGenerator.Serialize(instance, filename, 0);
    4545    }
    4646
    47     public static void SaveCompressed(IStorable instance, string filename) {
     47    public static void SaveCompressed(IItem instance, string filename) {
    4848      XmlGenerator.Serialize(instance, filename, 9);
    4949    }
     
    5555    /// <param name="instance">The object that should be saved.</param>
    5656    /// <param name="stream">The (file) stream where the object should be saved.</param>
    57     public static void Save(IStorable instance, Stream stream) {
     57    public static void Save(IItem instance, Stream stream) {
    5858      XmlGenerator.Serialize(instance, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()));     
    5959    }
     
    6565    /// <param name="filename">The filename of the file where the data is saved.</param>
    6666    /// <returns>The loaded object.</returns>
    67     public static IStorable Load(string filename) {
    68       return (IStorable)XmlParser.Deserialize(filename);
     67    public static IItem Load(string filename) {
     68      return (IItem)XmlParser.Deserialize(filename);
    6969    }
    7070    /// <summary>
     
    7575    /// <param name="stream">The stream from where to load the data.</param>
    7676    /// <returns>The loaded object.</returns>
    77     public static IStorable Load(Stream stream) {
    78       return (IStorable)XmlParser.Deserialize(stream);
     77    public static IItem Load(Stream stream) {
     78      return (IItem)XmlParser.Deserialize(stream);
    7979    }
    8080
  • trunk/sources/HeuristicLab.Core/3.3/Scope.cs

    r2520 r2526  
    217217    }
    218218    /// <inheritdoc/>
    219     public IScope GetScope(Guid guid) {
    220       if (Guid == guid) return this;
    221       else {
    222         for (int i = 0; i < mySubScopes.Count; i++) {
    223           IScope s = mySubScopes[i].GetScope(guid);
    224           if (s != null) return s;
    225         }
    226       }
    227       return null;
    228     }
    229     /// <inheritdoc/>
    230219    public IScope GetScope(string name) {
    231220      if (Name == name) return this;
     
    260249
    261250    /// <inheritdoc/>
    262     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    263       Scope clone = (Scope)base.Clone(clonedObjects);
     251    public override IItem Clone(ICloner cloner) {
     252      Scope clone = (Scope)base.Clone(cloner);
    264253      clone.myName = Name;
    265254
    266255      foreach (IVariable variable in myVariables.Values)
    267         clone.AddVariable((IVariable)Auxiliary.Clone(variable, clonedObjects));
     256        clone.AddVariable((IVariable)cloner.Clone(variable));
    268257      foreach (KeyValuePair<string, string> alias in myAliases)
    269258        clone.AddAlias(alias.Key, alias.Value);
    270259      for (int i = 0; i < SubScopes.Count; i++)
    271         clone.AddSubScope((IScope)Auxiliary.Clone(SubScopes[i], clonedObjects));
     260        clone.AddSubScope((IScope)cloner.Clone(SubScopes[i]));
    272261
    273262      return clone;
  • trunk/sources/HeuristicLab.Core/3.3/Variable.cs

    r2520 r2526  
    9595    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    9696    /// <returns>The cloned object as <see cref="Variable"/>.</returns>
    97     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     97    public override IItem Clone(ICloner cloner) {
    9898      Variable clone = new Variable();
    99       clonedObjects.Add(Guid, clone);
     99      cloner.RegisterClonedObject(this, clone);
    100100      clone.myName = Name;
    101101      if (Value != null)
    102         clone.myValue = (IItem)Auxiliary.Clone(Value, clonedObjects);
     102        clone.myValue = (IItem)cloner.Clone(Value);
    103103      return clone;
    104104    }
  • trunk/sources/HeuristicLab.Core/3.3/VariableInfo.cs

    r2520 r2526  
    136136    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    137137    /// <returns>The cloned object as <see cref="VariableInfo"/>.</returns>
    138     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     138    public override IItem Clone(ICloner cloner) {
    139139      VariableInfo clone = new VariableInfo();
    140       clonedObjects.Add(Guid, clone);
     140      cloner.RegisterClonedObject(this, clone);
    141141      clone.myActualName = ActualName;
    142142      clone.myFormalName = FormalName;
  • trunk/sources/HeuristicLab.Data/3.3/BoolData.cs

    r2520 r2526  
    6363    /// <param name="clonedObjects">Dictionary of all already cloned objects.</param>
    6464    /// <returns>The cloned instance as <see cref="BoolData"/>.</returns>
    65     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     65    public override IItem Clone(ICloner cloner) {
    6666      BoolData clone = new BoolData();
    67       clonedObjects.Add(Guid, clone);
     67      cloner.RegisterClonedObject(this, clone);
    6868      clone.Data = Data;
    6969      return clone;
  • trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs

    r2520 r2526  
    6464    /// <param name="clonedObjects">Dictionary of all already cloned objects.</param>
    6565    /// <returns>The cloned instance as <see cref="DoubleData"/>.</returns>
    66     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     66    public override IItem Clone(ICloner cloner) {
    6767      DoubleData clone = new DoubleData();
    68       clonedObjects.Add(Guid, clone);
     68      cloner.RegisterClonedObject(this, clone);
    6969      clone.Data = Data;
    7070      return clone;
  • trunk/sources/HeuristicLab.Data/3.3/IntData.cs

    r2520 r2526  
    6464    /// <param name="clonedObjects">Dictionary of all already cloned objects.</param>
    6565    /// <returns>The cloned instance as <see cref="IntData"/>.</returns>
    66     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     66    public override IItem Clone(ICloner cloner) {
    6767      IntData clone = new IntData();
    68       clonedObjects.Add(Guid, clone);
     68      cloner.RegisterClonedObject(this, clone);
    6969      clone.Data = Data;
    7070      return clone;
  • trunk/sources/HeuristicLab.Data/3.3/ItemDictionary_T.cs

    r2520 r2526  
    4646    /// <param name="clonedObjects">A dictionary of all already cloned objects.</param>
    4747    /// <returns>The cloned instance as <see cref="ItemDictionary&lt;K,V&gt;"/>.</returns>
    48     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     48    public override IItem Clone(ICloner cloner) {
    4949      ItemDictionary<K,V> clone = new ItemDictionary<K,V>();
    50       clonedObjects.Add(Guid, clone);
     50      cloner.RegisterClonedObject(this, clone);
    5151      foreach (KeyValuePair<K, V> item in dict) {
    52         clone.dict.Add((K) Auxiliary.Clone(item.Key, clonedObjects), (V) Auxiliary.Clone(item.Value, clonedObjects));
     52        clone.dict.Add((K) cloner.Clone(item.Key), (V) cloner.Clone(item.Value));
    5353      }
    5454      return clone;
     
    300300          return ((IObjectData) obj).Data.GetHashCode();
    301301        }
    302         return obj.Guid.GetHashCode();
     302        return obj.GetHashCode();
    303303      }
    304304    }
  • trunk/sources/HeuristicLab.Data/3.3/ItemList.cs

    r1529 r2526  
    3737    /// <param name="clonedObjects">A dictionary of all already cloned objects.</param>
    3838    /// <returns>The cloned instance as <see cref="ItemList"/>.</returns>
    39     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     39    public override IItem Clone(ICloner cloner) {
    4040      ItemList clone = new ItemList();
    41       clonedObjects.Add(Guid, clone);
    42       base.CloneElements(clone, clonedObjects);
     41      cloner.RegisterClonedObject(this, clone);
     42      base.CloneElements(cloner, clone);
    4343      return clone;
    4444    }
  • trunk/sources/HeuristicLab.Data/3.3/ItemList_T.cs

    r2520 r2526  
    5252    /// <param name="clonedObjects">A dictionary of all already cloned objects.</param>
    5353    /// <returns>The cloned instance as <see cref="ItemList&lt;T&gt;"/>.</returns>
    54     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     54    public override IItem Clone(ICloner cloner) {
    5555      ItemList<T> clone = new ItemList<T>();
    56       clonedObjects.Add(Guid, clone);
    57       CloneElements(clone, clonedObjects);
     56      cloner.RegisterClonedObject(this, clone);
     57      CloneElements(cloner, clone);
    5858      return clone;
    5959    }
     
    6666    /// <param name="destination">The <see cref="ItemList&lt;T&gt;"/> where to save the cloned objects.</param>
    6767    /// <param name="clonedObjects">A dictionary of all already cloned objects.</param>
    68     protected void CloneElements(ItemList<T> destination, IDictionary<Guid, object> clonedObjects) {
     68    protected void CloneElements(ICloner cloner, ItemList<T> destination) {
    6969      for (int i = 0; i < list.Count; i++)
    70         destination.list.Add((T) Auxiliary.Clone(list[i], clonedObjects));
     70        destination.list.Add((T)cloner.Clone(list[i]));
    7171    }
    7272
  • trunk/sources/HeuristicLab.Data/3.3/NullData.cs

    r1853 r2526  
    5555    /// <param name="clonedObjects">All already cloned objects.</param>
    5656    /// <returns>The cloned instance as <see cref="NullData"/>.</returns>
    57     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     57    public override IItem Clone(ICloner cloner) {
    5858      NullData clone = new NullData();
    59       clonedObjects.Add(Guid, clone);
     59      cloner.RegisterClonedObject(this, clone);
    6060      return clone;
    6161    }
  • trunk/sources/HeuristicLab.Data/3.3/ObjectData.cs

    r1842 r2526  
    5252    /// Clones the current instance.
    5353    /// </summary>
    54     /// <remarks>HeuristicLab data items are cloned with the <see cref="HeuristicLab.Core.Auxiliary.Clone"/> method of
     54    /// <remarks>HeuristicLab data items are cloned with the <see cref="HeuristicLab.Core.cloner.Clone"/> method of
    5555    /// class <see cref="Auxiliary"/> (deep copy), all other items (like basic data types)
    5656    /// are cloned with their own <c>Clone</c> methods (shadow copy).</remarks>
     
    5858    /// <param name="clonedObjects">A dictionary of all already cloned objects.</param>
    5959    /// <returns>The clone instance.</returns>
    60     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    61       ObjectData clone = (ObjectData)base.Clone(clonedObjects);
    62       if (Data is IStorable)
    63         clone.myData = Auxiliary.Clone((IStorable)Data, clonedObjects);
     60    public override IItem Clone(ICloner cloner) {
     61      ObjectData clone = (ObjectData)base.Clone(cloner);
     62      if (Data is IItem)
     63        clone.myData = cloner.Clone((IItem)Data);
    6464      else if (Data is ICloneable)
    6565        clone.myData = ((ICloneable)Data).Clone();
  • trunk/sources/HeuristicLab.Data/3.3/StringData.cs

    r2520 r2526  
    6464    /// <param name="clonedObjects">A dictionary of all already cloned objects.</param>
    6565    /// <returns>The coned instance as <see cref="StringData"/>.</returns>
    66     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     66    public override IItem Clone(ICloner cloner) {
    6767      StringData clone = new StringData();
    68       clonedObjects.Add(Guid, clone);
     68      cloner.RegisterClonedObject(this, clone);
    6969      clone.Data = Data;
    7070      return clone;
  • trunk/sources/HeuristicLab.Logging/3.3/Linechart.cs

    r2520 r2526  
    8585    /// Clones the current instance (deep clone).
    8686    /// </summary>
    87     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     87    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    8888    /// <see cref="Auxiliary"/>.</remarks>
    8989    /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
    9090    /// <returns>The cloned object as <see cref="Linechart"/>.</returns>
    91     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    92       Linechart clone = (Linechart)base.Clone(clonedObjects);
    93       clone.myNumberOfLines = (IntData)Auxiliary.Clone(myNumberOfLines, clonedObjects);
    94       clone.myValues = (ItemList)Auxiliary.Clone(Values, clonedObjects);
     91    public override IItem Clone(ICloner cloner) {
     92      Linechart clone = (Linechart)base.Clone(cloner);
     93      clone.myNumberOfLines = (IntData)cloner.Clone(myNumberOfLines);
     94      clone.myValues = (ItemList)cloner.Clone(Values);
    9595      return clone;
    9696    }
  • trunk/sources/HeuristicLab.Logging/3.3/Log.cs

    r2520 r2526  
    5959    /// Clones the current instance (deep clone).
    6060    /// </summary>
    61     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     61    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    6262    /// <see cref="Auxiliary"/>.</remarks>
    6363    /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
    6464    /// <returns>The cloned object as <see cref="Log"/>.</returns>
    65     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    66       Log clone = (Log)base.Clone(clonedObjects);
    67       clone.myItems = (ItemList)Auxiliary.Clone(Items, clonedObjects);
     65    public override IItem Clone(ICloner cloner) {
     66      Log clone = (Log)base.Clone(cloner);
     67      clone.myItems = (ItemList)cloner.Clone(Items);
    6868      return clone;
    6969    }
  • trunk/sources/HeuristicLab.Logging/3.3/PointXYChart.cs

    r2520 r2526  
    8787    /// Clones the current instance (deep clone).
    8888    /// </summary>
    89     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     89    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    9090    /// <see cref="Auxiliary"/>.</remarks>
    9191    /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
    9292    /// <returns>The cloned object as <see cref="PointXYChart"/>.</returns>
    93     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    94       PointXYChart clone = (PointXYChart)base.Clone(clonedObjects);
    95       clone.myValues = (ItemList)Auxiliary.Clone(Values, clonedObjects);
     93    public override IItem Clone(ICloner cloner) {
     94      PointXYChart clone = (PointXYChart)base.Clone(cloner);
     95      clone.myValues = (ItemList)cloner.Clone(Values);
    9696      return clone;
    9797    }
  • trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs

    r2520 r2526  
    149149    }
    150150
    151     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    152       ProgrammableOperator clone = (ProgrammableOperator)base.Clone(clonedObjects);
     151    public override IItem Clone(ICloner cloner) {
     152      ProgrammableOperator clone = (ProgrammableOperator)base.Clone(cloner);
    153153      clone.myDescription = Description;
    154154      clone.myCode = Code;
  • trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs

    r2520 r2526  
    8787    /// (System.Collections.Generic.IDictionary&lt;System.Guid, object&gt;)"/>
    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    }
  • trunk/sources/HeuristicLab.Permutation/3.3/Permutation.cs

    r1530 r2526  
    2424using System.Text;
    2525using System.Xml;
     26using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728
     
    5253    /// avoid cycles.)</param>
    5354    /// <returns>The cloned object as <see cref="Permutation"/>.</returns>
    54     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     55    public override IItem Clone(ICloner cloner) {
    5556      Permutation clone = new Permutation((int[])Data.Clone());
    56       clonedObjects.Add(Guid, clone);
     57      cloner.RegisterClonedObject(this, clone);
    5758      return clone;
    5859    }
  • trunk/sources/HeuristicLab.Random/3.3/MersenneTwister.cs

    r1823 r2526  
    8484    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    8585    /// <returns>The cloned object as <see cref="MersenneTwister"/>.</returns>
    86     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     86    public override IItem Clone(ICloner cloner) {
    8787      MersenneTwister clone = new MersenneTwister();
    88       clonedObjects.Add(Guid, clone);
     88      cloner.RegisterClonedObject(this, clone);
    8989      clone.state = (uint[])state.Clone();
    9090      clone.p = p;
  • trunk/sources/HeuristicLab.Random/3.3/NormalDistributedRandom.cs

    r1823 r2526  
    557557    /// Clones the current instance (deep clone).
    558558    /// </summary>
    559     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     559    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    560560    /// <see cref="Auxiliary"/>.</remarks>
    561561    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    562562    /// <returns>The cloned object as <see cref="NormalDistributedRandom"/>.</returns>
    563     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    564       NormalDistributedRandom clone = new NormalDistributedRandom((IRandom)Auxiliary.Clone(uniform, clonedObjects), mu, sigma);
    565       clonedObjects.Add(Guid, clone);
     563    public override IItem Clone(ICloner cloner) {
     564      NormalDistributedRandom clone = new NormalDistributedRandom((IRandom)cloner.Clone(uniform), mu, sigma);
     565      cloner.RegisterClonedObject(this, clone);
    566566      return clone;
    567567    }
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPTour.cs

    r2520 r2526  
    7474    /// Clones the current instance (deep clone).
    7575    /// </summary>
    76     /// <remarks>Uses <see cref="Auxiliary.Clone"/> method of class <see cref="Auxiliary"/> to clone
     76    /// <remarks>Uses <see cref="cloner.Clone"/> method of class <see cref="Auxiliary"/> to clone
    7777    /// the coordinates.</remarks>
    7878    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    7979    /// <returns>The cloned object as <see cref="TSPTour"/>.</returns>
    80     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    81       TSPTour clone = (TSPTour)base.Clone(clonedObjects);
    82       clone.myCoordinates = (DoubleMatrixData)Auxiliary.Clone(Coordinates, clonedObjects);
     80    public override IItem Clone(ICloner cloner) {
     81      TSPTour clone = (TSPTour)base.Clone(cloner);
     82      clone.myCoordinates = (DoubleMatrixData)cloner.Clone(Coordinates);
    8383      clone.myTour = Tour;
    8484      return clone;
  • trunk/sources/HeuristicLab.SGA/3.3/SGA.cs

    r2520 r2526  
    462462      set {
    463463        value.Name = "ProblemInjector";
    464         mySGA.OperatorGraph.RemoveOperator(ProblemInjector.Guid);
     464        mySGA.OperatorGraph.RemoveOperator(ProblemInjector);
    465465        mySGA.OperatorGraph.AddOperator(value);
    466466        myVariableInjection.AddSubOperator(value, 0);
     
    477477      set {
    478478        value.Name = "SolutionGenerator";
    479         mySGA.OperatorGraph.RemoveOperator(SolutionGenerator.Guid);
     479        mySGA.OperatorGraph.RemoveOperator(SolutionGenerator);
    480480        mySGA.OperatorGraph.AddOperator(value);
    481481        myPopulationInitialization.AddSubOperator(value, 0);
     
    490490      set {
    491491        value.Name = "Evaluator";
    492         mySGA.OperatorGraph.RemoveOperator(Evaluator.Guid);
     492        mySGA.OperatorGraph.RemoveOperator(Evaluator);
    493493        mySGA.OperatorGraph.AddOperator(value);
    494494        myPopulationInitialization.AddSubOperator(value, 1);
     
    507507      set {
    508508        value.Name = "Selector";
    509         mySGA.OperatorGraph.RemoveOperator(Selector.Guid);
     509        mySGA.OperatorGraph.RemoveOperator(Selector);
    510510        mySGA.OperatorGraph.AddOperator(value);
    511511        mySGAMain.AddSubOperator(value, 0);
     
    520520      set {
    521521        value.Name = "Crossover";
    522         mySGA.OperatorGraph.RemoveOperator(Crossover.Guid);
     522        mySGA.OperatorGraph.RemoveOperator(Crossover);
    523523        mySGA.OperatorGraph.AddOperator(value);
    524524        mySGAMain.AddSubOperator(value, 1);
     
    533533      set {
    534534        value.Name = "Mutator";
    535         mySGA.OperatorGraph.RemoveOperator(Mutator.Guid);
     535        mySGA.OperatorGraph.RemoveOperator(Mutator);
    536536        mySGA.OperatorGraph.AddOperator(value);
    537537        mySGAMain.AddSubOperator(value, 2);
     
    552552    /// Clones the current instance (deep clone).
    553553    /// </summary>
    554     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     554    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    555555    /// <see cref="Auxiliary"/>.</remarks>
    556556    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    557557    /// <returns>The cloned object as <see cref="SGA"/>.</returns>
    558     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     558    public override IItem Clone(ICloner cloner) {
    559559      SGA clone = new SGA();
    560       clonedObjects.Add(Guid, clone);
    561       clone.myEngine = (IEngine)Auxiliary.Clone(Engine, clonedObjects);
     560      cloner.RegisterClonedObject(this, clone);
     561      clone.myEngine = (IEngine)cloner.Clone(Engine);
    562562      return clone;
    563563    }
  • trunk/sources/HeuristicLab.ThreadParallelEngine/3.3/ThreadParallelEngine.cs

    r2520 r2526  
    7373    /// <inheritdoc/>
    7474    /// <returns>The cloned object as <see cref="ThreadParallelEngine"/>.</returns>
    75     public override object Clone(IDictionary<Guid, object> clonedObjects) {
    76       ThreadParallelEngine clone = (ThreadParallelEngine)base.Clone(clonedObjects);
     75    public override IItem Clone(ICloner cloner) {
     76      ThreadParallelEngine clone = (ThreadParallelEngine)base.Clone(cloner);
    7777      clone.myWorkers = Workers;
    7878      return clone;
Note: See TracChangeset for help on using the changeset viewer.