Changeset 2526 for trunk/sources
- Timestamp:
- 11/23/09 16:43:34 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 3 deleted
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.3/MainForm.cs
r2520 r2526 43 43 private class Task { 44 44 public string filename; 45 public I Storable storable;45 public IItem item; 46 46 public IEditor editor; 47 47 48 48 private Task() { } 49 public Task(string filename, I Storable storable, IEditor editor) {49 public Task(string filename, IItem item, IEditor editor) { 50 50 this.filename = filename; 51 this. storable = storable;51 this.item = item; 52 52 this.editor = editor; 53 53 } … … 156 156 Task task = (Task)state; 157 157 try { 158 task. storable= PersistenceManager.Load(task.filename);158 task.item = PersistenceManager.Load(task.filename); 159 159 } catch (FileNotFoundException fileNotFoundEx) { 160 160 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.", … … 177 177 else { 178 178 IEditor editor = null; 179 if (task. storable!= null) {180 IEditable editable = task. storableas IEditable;179 if (task.item != null) { 180 IEditable editable = task.item as IEditable; 181 181 if (editable != null) 182 182 editor = (IEditor)MainFormManager.CreateDefaultView(editable); -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorGraphView.cs
r2524 r2526 221 221 if (operatorsListView.SelectedItems.Count > 0) { 222 222 foreach (ListViewItem item in operatorsListView.SelectedItems) 223 OperatorGraph.RemoveOperator(( (IOperator)item.Tag).Guid);223 OperatorGraph.RemoveOperator((IOperator)item.Tag); 224 224 } 225 225 } … … 261 261 if (operatorsListView.SelectedItems.Count > 0) { 262 262 foreach (ListViewItem item in operatorsListView.SelectedItems) 263 OperatorGraph.RemoveOperator(( (IOperator)item.Tag).Guid);263 OperatorGraph.RemoveOperator((IOperator)item.Tag); 264 264 } 265 265 } -
trunk/sources/HeuristicLab.Core/3.3/AtomicOperation.cs
r1823 r2526 69 69 /// </summary> 70 70 /// <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> 72 72 /// <param name="clonedObjects">All already cloned objects. (Needed to avoid cycles.)</param> 73 73 /// <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) { 75 75 AtomicOperation clone = new AtomicOperation(); 76 clone dObjects.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); 79 79 return clone; 80 80 } -
trunk/sources/HeuristicLab.Core/3.3/CompositeOperation.cs
r1823 r2526 81 81 /// </summary> 82 82 /// <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> 84 84 /// <param name="clonedObjects">A dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 85 85 /// <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) { 87 87 CompositeOperation clone = new CompositeOperation(); 88 clone dObjects.Add(Guid, clone);88 cloner.RegisterClonedObject(this, clone); 89 89 clone.myExecuteInParallel = ExecuteInParallel; 90 90 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])); 92 92 return clone; 93 93 } -
trunk/sources/HeuristicLab.Core/3.3/EngineBase.cs
r2474 r2526 127 127 /// Clones the current instance (deep clone). 128 128 /// </summary> 129 /// <remarks>Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class129 /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class 130 130 /// <see cref="Auxiliary"/>.</remarks> 131 131 /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param> 132 132 /// <returns>The cloned object as <see cref="EngineBase"/>.</returns> 133 public override object Clone(IDictionary<Guid, object> clonedObjects) {134 EngineBase clone = (EngineBase)base.Clone(clone dObjects);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); 137 137 clone.myExecutionTime = ExecutionTime; 138 138 IOperation[] operations = new IOperation[ExecutionStack.Count]; 139 139 ExecutionStack.CopyTo(operations, 0); 140 140 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])); 142 142 clone.myRunning = Running; 143 143 clone.myCanceled = Canceled; -
trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj
r2524 r2526 98 98 </ItemGroup> 99 99 <ItemGroup> 100 <Compile Include="Auxiliary.cs" />101 100 <Compile Include="AtomicOperation.cs" /> 102 101 <Compile Include="CompositeOperation.cs" /> 102 <Compile Include="Cloner.cs" /> 103 <Compile Include="Interfaces\ICloner.cs" /> 103 104 <Compile Include="Interfaces\IEditable.cs" /> 104 105 <Compile Include="Interfaces\IOperation.cs" /> … … 119 120 <Compile Include="Interfaces\IRandom.cs" /> 120 121 <Compile Include="OperatorGraph.cs" /> 121 <Compile Include="StorableBase.cs" />122 122 <Compile Include="Scope.cs" /> 123 123 <Compile Include="EngineBase.cs" /> 124 124 <Compile Include="Interfaces\IEngine.cs" /> 125 125 <Compile Include="Interfaces\IOperator.cs" /> 126 <Compile Include="Interfaces\IStorable.cs" />127 126 <Compile Include="PersistenceManager.cs" /> 128 127 <Compile Include="HeuristicLabCorePlugin.cs" /> -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IItem.cs
r2520 r2526 28 28 /// Interface to represent (almost) every HeuristicLab object (an object, an operator,...). 29 29 /// </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 31 39 /// <summary> 32 40 /// Fires a new <c>Changed</c> event. -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IOperatorGraph.cs
r2474 r2526 49 49 /// </summary> 50 50 /// <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); 58 52 /// <summary> 59 53 /// Clears the current instance. -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IOperatorGroup.cs
r776 r2526 29 29 /// Interface to represent a group of operators. 30 30 /// </summary> 31 public interface IOperatorGroup : I Storable{31 public interface IOperatorGroup : IItem { 32 32 /// <summary> 33 33 /// Gets or sets the name of the current instance. -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IScope.cs
r2474 r2526 130 130 void ReorderSubScopes(int[] sequence); 131 131 /// <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>138 132 /// Gets the sub scope with the given <paramref name="name"/>. 139 133 /// </summary> -
trunk/sources/HeuristicLab.Core/3.3/ItemBase.cs
r2520 r2526 31 31 /// </summary> 32 32 [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 34 59 /// <summary> 35 60 /// Gets the string representation of the current instance. -
trunk/sources/HeuristicLab.Core/3.3/OperatorBase.cs
r2524 r2526 131 131 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 132 132 /// <returns>The cloned object as <see cref="OperatorBase"/>.</returns> 133 public override object Clone(IDictionary<Guid, object> clonedObjects) {134 OperatorBase clone = (OperatorBase)base.Clone(clone dObjects);133 public override IItem Clone(ICloner cloner) { 134 OperatorBase clone = (OperatorBase)base.Clone(cloner); 135 135 clone.myName = Name; 136 136 clone.mySubOperators.Clear(); 137 137 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])); 139 139 clone.myVariableInfos.Clear(); 140 140 foreach (IVariableInfo variableInfo in myVariableInfos.Values) 141 clone.AddVariableInfo((IVariableInfo) Auxiliary.Clone(variableInfo, clonedObjects));141 clone.AddVariableInfo((IVariableInfo)cloner.Clone(variableInfo)); 142 142 clone.myVariables.Clear(); 143 143 foreach (IVariable variable in myVariables.Values) 144 clone.AddVariable((IVariable) Auxiliary.Clone(variable, clonedObjects));144 clone.AddVariable((IVariable)cloner.Clone(variable)); 145 145 return clone; 146 146 } -
trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs
r2520 r2526 34 34 35 35 [Storable] 36 private IDictionary< Guid, IOperator> myOperators;36 private IDictionary<IOperator, IOperator> myOperators; 37 37 /// <summary> 38 38 /// Gets all operators of the current instance. … … 62 62 /// </summary> 63 63 public OperatorGraph() { 64 myOperators = new Dictionary< Guid, IOperator>();64 myOperators = new Dictionary<IOperator, IOperator>(); 65 65 } 66 66 … … 68 68 /// Clones the current instance (deep clone). 69 69 /// </summary> 70 /// <remarks>Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class70 /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class 71 71 /// <see cref="Auxiliary"/>.</remarks> 72 72 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 73 73 /// <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) { 75 75 OperatorGraph clone = new OperatorGraph(); 76 clone dObjects.Add(Guid, clone);76 cloner.RegisterClonedObject(this, clone); 77 77 foreach (IOperator op in Operators) 78 clone.AddOperator((IOperator) Auxiliary.Clone(op, clonedObjects));78 clone.AddOperator((IOperator)cloner.Clone(op)); 79 79 if (InitialOperator != null) 80 clone.myInitialOperator = (IOperator) Auxiliary.Clone(InitialOperator, clonedObjects);80 clone.myInitialOperator = (IOperator)cloner.Clone(InitialOperator); 81 81 return clone; 82 82 } … … 85 85 /// <remarks>Calls <see cref="OnOperatorAdded"/>.</remarks> 86 86 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); 89 89 OnOperatorAdded(op); 90 90 … … 95 95 /// <inheritdoc/> 96 96 /// <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)) { 100 99 foreach (IOperator o in Operators) { 101 100 int i = 0; … … 109 108 if (InitialOperator == op) 110 109 InitialOperator = null; 111 myOperators.Remove(op .Guid);110 myOperators.Remove(op); 112 111 OnOperatorRemoved(op); 113 112 } 114 113 } 115 114 /// <inheritdoc/> 116 public IOperator GetOperator(Guid guid) {117 IOperator op;118 if (myOperators.TryGetValue(guid, out op))119 return op;120 else121 return null;122 }123 /// <inheritdoc/>124 115 public void Clear() { 125 Guid[] guids = new Guid[Operators.Count];116 IOperator[] ops = new IOperator[Operators.Count]; 126 117 int i = 0; 127 118 foreach (IOperator op in Operators) { 128 guids[i] = op.Guid;119 ops[i] = op; 129 120 i++; 130 121 } 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]); 133 124 } 134 125 -
trunk/sources/HeuristicLab.Core/3.3/OperatorGroup.cs
r1823 r2526 30 30 /// Representation of a group of operators (can also include subgroups). 31 31 /// </summary> 32 public class OperatorGroup : StorableBase, IOperatorGroup {32 public class OperatorGroup : ItemBase, IOperatorGroup { 33 33 34 34 [Storable] … … 80 80 /// Clones the current instance (deep clone). 81 81 /// </summary> 82 /// <remarks>Deep clone with <see cref=" Auxiliary.Clone"/> method of helper class82 /// <remarks>Deep clone with <see cref="cloner.Clone"/> method of helper class 83 83 /// <see cref="Auxiliary"/>.</remarks> 84 84 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 85 85 /// <returns>The cloned object as <see cref="OperatorGroup"/>.</returns> 86 public override object Clone(IDictionary<Guid, object> clonedObjects) {87 OperatorGroup clone = (OperatorGroup)base.Clone(clone dObjects);86 public override IItem Clone(ICloner cloner) { 87 OperatorGroup clone = (OperatorGroup)base.Clone(cloner); 88 88 clone.myName = Name; 89 89 foreach (IOperatorGroup group in SubGroups) 90 clone.AddSubGroup((IOperatorGroup) Auxiliary.Clone(group, clonedObjects));90 clone.AddSubGroup((IOperatorGroup)cloner.Clone(group)); 91 91 foreach (IOperator op in Operators) 92 clone.AddOperator((IOperator) Auxiliary.Clone(op, clonedObjects));92 clone.AddOperator((IOperator)cloner.Clone(op)); 93 93 return clone; 94 94 } -
trunk/sources/HeuristicLab.Core/3.3/OperatorLibrary.cs
r2520 r2526 51 51 /// Clones the current instance (deep clone). 52 52 /// </summary> 53 /// <remarks>Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class53 /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class 54 54 /// <see cref="Auxiliary"/>.</remarks> 55 55 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 56 56 /// <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) { 58 58 OperatorLibrary clone = new OperatorLibrary(); 59 clone dObjects.Add(Guid, clone);60 clone.myGroup = (IOperatorGroup) Auxiliary.Clone(Group, clonedObjects);59 cloner.RegisterClonedObject(this, clone); 60 clone.myGroup = (IOperatorGroup)cloner.Clone(Group); 61 61 return clone; 62 62 } -
trunk/sources/HeuristicLab.Core/3.3/PersistenceManager.cs
r1895 r2526 41 41 /// <param name="instance">The object that should be saved.</param> 42 42 /// <param name="filename">The name of the file where the <paramref name="object"/> should be saved.</param> 43 public static void Save(I Storableinstance, string filename) {43 public static void Save(IItem instance, string filename) { 44 44 XmlGenerator.Serialize(instance, filename, 0); 45 45 } 46 46 47 public static void SaveCompressed(I Storableinstance, string filename) {47 public static void SaveCompressed(IItem instance, string filename) { 48 48 XmlGenerator.Serialize(instance, filename, 9); 49 49 } … … 55 55 /// <param name="instance">The object that should be saved.</param> 56 56 /// <param name="stream">The (file) stream where the object should be saved.</param> 57 public static void Save(I Storableinstance, Stream stream) {57 public static void Save(IItem instance, Stream stream) { 58 58 XmlGenerator.Serialize(instance, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat())); 59 59 } … … 65 65 /// <param name="filename">The filename of the file where the data is saved.</param> 66 66 /// <returns>The loaded object.</returns> 67 public static I StorableLoad(string filename) {68 return (I Storable)XmlParser.Deserialize(filename);67 public static IItem Load(string filename) { 68 return (IItem)XmlParser.Deserialize(filename); 69 69 } 70 70 /// <summary> … … 75 75 /// <param name="stream">The stream from where to load the data.</param> 76 76 /// <returns>The loaded object.</returns> 77 public static I StorableLoad(Stream stream) {78 return (I Storable)XmlParser.Deserialize(stream);77 public static IItem Load(Stream stream) { 78 return (IItem)XmlParser.Deserialize(stream); 79 79 } 80 80 -
trunk/sources/HeuristicLab.Core/3.3/Scope.cs
r2520 r2526 217 217 } 218 218 /// <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/>230 219 public IScope GetScope(string name) { 231 220 if (Name == name) return this; … … 260 249 261 250 /// <inheritdoc/> 262 public override object Clone(IDictionary<Guid, object> clonedObjects) {263 Scope clone = (Scope)base.Clone(clone dObjects);251 public override IItem Clone(ICloner cloner) { 252 Scope clone = (Scope)base.Clone(cloner); 264 253 clone.myName = Name; 265 254 266 255 foreach (IVariable variable in myVariables.Values) 267 clone.AddVariable((IVariable) Auxiliary.Clone(variable, clonedObjects));256 clone.AddVariable((IVariable)cloner.Clone(variable)); 268 257 foreach (KeyValuePair<string, string> alias in myAliases) 269 258 clone.AddAlias(alias.Key, alias.Value); 270 259 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])); 272 261 273 262 return clone; -
trunk/sources/HeuristicLab.Core/3.3/Variable.cs
r2520 r2526 95 95 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 96 96 /// <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) { 98 98 Variable clone = new Variable(); 99 clone dObjects.Add(Guid, clone);99 cloner.RegisterClonedObject(this, clone); 100 100 clone.myName = Name; 101 101 if (Value != null) 102 clone.myValue = (IItem) Auxiliary.Clone(Value, clonedObjects);102 clone.myValue = (IItem)cloner.Clone(Value); 103 103 return clone; 104 104 } -
trunk/sources/HeuristicLab.Core/3.3/VariableInfo.cs
r2520 r2526 136 136 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 137 137 /// <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) { 139 139 VariableInfo clone = new VariableInfo(); 140 clone dObjects.Add(Guid, clone);140 cloner.RegisterClonedObject(this, clone); 141 141 clone.myActualName = ActualName; 142 142 clone.myFormalName = FormalName; -
trunk/sources/HeuristicLab.Data/3.3/BoolData.cs
r2520 r2526 63 63 /// <param name="clonedObjects">Dictionary of all already cloned objects.</param> 64 64 /// <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) { 66 66 BoolData clone = new BoolData(); 67 clone dObjects.Add(Guid, clone);67 cloner.RegisterClonedObject(this, clone); 68 68 clone.Data = Data; 69 69 return clone; -
trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs
r2520 r2526 64 64 /// <param name="clonedObjects">Dictionary of all already cloned objects.</param> 65 65 /// <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) { 67 67 DoubleData clone = new DoubleData(); 68 clone dObjects.Add(Guid, clone);68 cloner.RegisterClonedObject(this, clone); 69 69 clone.Data = Data; 70 70 return clone; -
trunk/sources/HeuristicLab.Data/3.3/IntData.cs
r2520 r2526 64 64 /// <param name="clonedObjects">Dictionary of all already cloned objects.</param> 65 65 /// <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) { 67 67 IntData clone = new IntData(); 68 clone dObjects.Add(Guid, clone);68 cloner.RegisterClonedObject(this, clone); 69 69 clone.Data = Data; 70 70 return clone; -
trunk/sources/HeuristicLab.Data/3.3/ItemDictionary_T.cs
r2520 r2526 46 46 /// <param name="clonedObjects">A dictionary of all already cloned objects.</param> 47 47 /// <returns>The cloned instance as <see cref="ItemDictionary<K,V>"/>.</returns> 48 public override object Clone(IDictionary<Guid, object> clonedObjects) {48 public override IItem Clone(ICloner cloner) { 49 49 ItemDictionary<K,V> clone = new ItemDictionary<K,V>(); 50 clone dObjects.Add(Guid, clone);50 cloner.RegisterClonedObject(this, clone); 51 51 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)); 53 53 } 54 54 return clone; … … 300 300 return ((IObjectData) obj).Data.GetHashCode(); 301 301 } 302 return obj.G uid.GetHashCode();302 return obj.GetHashCode(); 303 303 } 304 304 } -
trunk/sources/HeuristicLab.Data/3.3/ItemList.cs
r1529 r2526 37 37 /// <param name="clonedObjects">A dictionary of all already cloned objects.</param> 38 38 /// <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) { 40 40 ItemList clone = new ItemList(); 41 clone dObjects.Add(Guid, clone);42 base.CloneElements(clone , clonedObjects);41 cloner.RegisterClonedObject(this, clone); 42 base.CloneElements(cloner, clone); 43 43 return clone; 44 44 } -
trunk/sources/HeuristicLab.Data/3.3/ItemList_T.cs
r2520 r2526 52 52 /// <param name="clonedObjects">A dictionary of all already cloned objects.</param> 53 53 /// <returns>The cloned instance as <see cref="ItemList<T>"/>.</returns> 54 public override object Clone(IDictionary<Guid, object> clonedObjects) {54 public override IItem Clone(ICloner cloner) { 55 55 ItemList<T> clone = new ItemList<T>(); 56 clone dObjects.Add(Guid, clone);57 CloneElements(clone , clonedObjects);56 cloner.RegisterClonedObject(this, clone); 57 CloneElements(cloner, clone); 58 58 return clone; 59 59 } … … 66 66 /// <param name="destination">The <see cref="ItemList<T>"/> where to save the cloned objects.</param> 67 67 /// <param name="clonedObjects">A dictionary of all already cloned objects.</param> 68 protected void CloneElements(I temList<T> destination, IDictionary<Guid, object> clonedObjects) {68 protected void CloneElements(ICloner cloner, ItemList<T> destination) { 69 69 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])); 71 71 } 72 72 -
trunk/sources/HeuristicLab.Data/3.3/NullData.cs
r1853 r2526 55 55 /// <param name="clonedObjects">All already cloned objects.</param> 56 56 /// <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) { 58 58 NullData clone = new NullData(); 59 clone dObjects.Add(Guid, clone);59 cloner.RegisterClonedObject(this, clone); 60 60 return clone; 61 61 } -
trunk/sources/HeuristicLab.Data/3.3/ObjectData.cs
r1842 r2526 52 52 /// Clones the current instance. 53 53 /// </summary> 54 /// <remarks>HeuristicLab data items are cloned with the <see cref="HeuristicLab.Core. Auxiliary.Clone"/> method of54 /// <remarks>HeuristicLab data items are cloned with the <see cref="HeuristicLab.Core.cloner.Clone"/> method of 55 55 /// class <see cref="Auxiliary"/> (deep copy), all other items (like basic data types) 56 56 /// are cloned with their own <c>Clone</c> methods (shadow copy).</remarks> … … 58 58 /// <param name="clonedObjects">A dictionary of all already cloned objects.</param> 59 59 /// <returns>The clone instance.</returns> 60 public override object Clone(IDictionary<Guid, object> clonedObjects) {61 ObjectData clone = (ObjectData)base.Clone(clone dObjects);62 if (Data is I Storable)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); 64 64 else if (Data is ICloneable) 65 65 clone.myData = ((ICloneable)Data).Clone(); -
trunk/sources/HeuristicLab.Data/3.3/StringData.cs
r2520 r2526 64 64 /// <param name="clonedObjects">A dictionary of all already cloned objects.</param> 65 65 /// <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) { 67 67 StringData clone = new StringData(); 68 clone dObjects.Add(Guid, clone);68 cloner.RegisterClonedObject(this, clone); 69 69 clone.Data = Data; 70 70 return clone; -
trunk/sources/HeuristicLab.Logging/3.3/Linechart.cs
r2520 r2526 85 85 /// Clones the current instance (deep clone). 86 86 /// </summary> 87 /// <remarks>Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class87 /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class 88 88 /// <see cref="Auxiliary"/>.</remarks> 89 89 /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param> 90 90 /// <returns>The cloned object as <see cref="Linechart"/>.</returns> 91 public override object Clone(IDictionary<Guid, object> clonedObjects) {92 Linechart clone = (Linechart)base.Clone(clone dObjects);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); 95 95 return clone; 96 96 } -
trunk/sources/HeuristicLab.Logging/3.3/Log.cs
r2520 r2526 59 59 /// Clones the current instance (deep clone). 60 60 /// </summary> 61 /// <remarks>Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class61 /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class 62 62 /// <see cref="Auxiliary"/>.</remarks> 63 63 /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param> 64 64 /// <returns>The cloned object as <see cref="Log"/>.</returns> 65 public override object Clone(IDictionary<Guid, object> clonedObjects) {66 Log clone = (Log)base.Clone(clone dObjects);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); 68 68 return clone; 69 69 } -
trunk/sources/HeuristicLab.Logging/3.3/PointXYChart.cs
r2520 r2526 87 87 /// Clones the current instance (deep clone). 88 88 /// </summary> 89 /// <remarks>Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class89 /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class 90 90 /// <see cref="Auxiliary"/>.</remarks> 91 91 /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param> 92 92 /// <returns>The cloned object as <see cref="PointXYChart"/>.</returns> 93 public override object Clone(IDictionary<Guid, object> clonedObjects) {94 PointXYChart clone = (PointXYChart)base.Clone(clone dObjects);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); 96 96 return clone; 97 97 } -
trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs
r2520 r2526 149 149 } 150 150 151 public override object Clone(IDictionary<Guid, object> clonedObjects) {152 ProgrammableOperator clone = (ProgrammableOperator)base.Clone(clone dObjects);151 public override IItem Clone(ICloner cloner) { 152 ProgrammableOperator clone = (ProgrammableOperator)base.Clone(cloner); 153 153 clone.myDescription = Description; 154 154 clone.myCode = Code; -
trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs
r2520 r2526 87 87 /// (System.Collections.Generic.IDictionary<System.Guid, object>)"/> 88 88 /// of base class <see cref="DelegatingOperator"/>.<br/> 89 /// Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class89 /// Deep clone through <see cref="cloner.Clone"/> method of helper class 90 90 /// <see cref="Auxiliary"/>.</remarks> 91 91 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 92 92 /// <returns>The cloned object as <see cref="CombinedOperator"/>.</returns> 93 public override object Clone(IDictionary<Guid, object> clonedObjects) {94 CombinedOperator clone = (CombinedOperator)base.Clone(clone dObjects);93 public override IItem Clone(ICloner cloner) { 94 CombinedOperator clone = (CombinedOperator)base.Clone(cloner); 95 95 clone.myDescription = Description; 96 clone.myOperatorGraph = (IOperatorGraph) Auxiliary.Clone(OperatorGraph, clonedObjects);96 clone.myOperatorGraph = (IOperatorGraph)cloner.Clone(OperatorGraph); 97 97 return clone; 98 98 } -
trunk/sources/HeuristicLab.Operators/3.3/DelegatingOperator.cs
r1530 r2526 31 31 /// </summary> 32 32 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 33 49 /// <summary> 34 50 /// Executes the specified operator in the given <paramref name="scope"/>. -
trunk/sources/HeuristicLab.Operators/3.3/VariableInjector.cs
r2520 r2526 53 53 /// Clones the current instance (deep clone). 54 54 /// </summary> 55 /// <remarks>Deep clone performed with <see cref=" Auxiliary.Clone"/> of helper class55 /// <remarks>Deep clone performed with <see cref="cloner.Clone"/> of helper class 56 56 /// <see cref="Auxiliary"/>.</remarks> 57 57 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 58 58 /// <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) { 60 60 VariableInjector clone = new VariableInjector(); 61 clone dObjects.Add(Guid, clone);61 cloner.RegisterClonedObject(this, clone); 62 62 clone.Name = Name; 63 63 foreach (IVariable variable in Variables) 64 clone.AddVariable((IVariable) Auxiliary.Clone(variable, clonedObjects));64 clone.AddVariable((IVariable)cloner.Clone(variable)); 65 65 return clone; 66 66 } -
trunk/sources/HeuristicLab.Permutation/3.3/Permutation.cs
r1530 r2526 24 24 using System.Text; 25 25 using System.Xml; 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Data; 27 28 … … 52 53 /// avoid cycles.)</param> 53 54 /// <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) { 55 56 Permutation clone = new Permutation((int[])Data.Clone()); 56 clone dObjects.Add(Guid, clone);57 cloner.RegisterClonedObject(this, clone); 57 58 return clone; 58 59 } -
trunk/sources/HeuristicLab.Random/3.3/MersenneTwister.cs
r1823 r2526 84 84 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 85 85 /// <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) { 87 87 MersenneTwister clone = new MersenneTwister(); 88 clone dObjects.Add(Guid, clone);88 cloner.RegisterClonedObject(this, clone); 89 89 clone.state = (uint[])state.Clone(); 90 90 clone.p = p; -
trunk/sources/HeuristicLab.Random/3.3/NormalDistributedRandom.cs
r1823 r2526 557 557 /// Clones the current instance (deep clone). 558 558 /// </summary> 559 /// <remarks>Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class559 /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class 560 560 /// <see cref="Auxiliary"/>.</remarks> 561 561 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 562 562 /// <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 clone dObjects.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); 566 566 return clone; 567 567 } -
trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPTour.cs
r2520 r2526 74 74 /// Clones the current instance (deep clone). 75 75 /// </summary> 76 /// <remarks>Uses <see cref=" Auxiliary.Clone"/> method of class <see cref="Auxiliary"/> to clone76 /// <remarks>Uses <see cref="cloner.Clone"/> method of class <see cref="Auxiliary"/> to clone 77 77 /// the coordinates.</remarks> 78 78 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 79 79 /// <returns>The cloned object as <see cref="TSPTour"/>.</returns> 80 public override object Clone(IDictionary<Guid, object> clonedObjects) {81 TSPTour clone = (TSPTour)base.Clone(clone dObjects);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); 83 83 clone.myTour = Tour; 84 84 return clone; -
trunk/sources/HeuristicLab.SGA/3.3/SGA.cs
r2520 r2526 462 462 set { 463 463 value.Name = "ProblemInjector"; 464 mySGA.OperatorGraph.RemoveOperator(ProblemInjector .Guid);464 mySGA.OperatorGraph.RemoveOperator(ProblemInjector); 465 465 mySGA.OperatorGraph.AddOperator(value); 466 466 myVariableInjection.AddSubOperator(value, 0); … … 477 477 set { 478 478 value.Name = "SolutionGenerator"; 479 mySGA.OperatorGraph.RemoveOperator(SolutionGenerator .Guid);479 mySGA.OperatorGraph.RemoveOperator(SolutionGenerator); 480 480 mySGA.OperatorGraph.AddOperator(value); 481 481 myPopulationInitialization.AddSubOperator(value, 0); … … 490 490 set { 491 491 value.Name = "Evaluator"; 492 mySGA.OperatorGraph.RemoveOperator(Evaluator .Guid);492 mySGA.OperatorGraph.RemoveOperator(Evaluator); 493 493 mySGA.OperatorGraph.AddOperator(value); 494 494 myPopulationInitialization.AddSubOperator(value, 1); … … 507 507 set { 508 508 value.Name = "Selector"; 509 mySGA.OperatorGraph.RemoveOperator(Selector .Guid);509 mySGA.OperatorGraph.RemoveOperator(Selector); 510 510 mySGA.OperatorGraph.AddOperator(value); 511 511 mySGAMain.AddSubOperator(value, 0); … … 520 520 set { 521 521 value.Name = "Crossover"; 522 mySGA.OperatorGraph.RemoveOperator(Crossover .Guid);522 mySGA.OperatorGraph.RemoveOperator(Crossover); 523 523 mySGA.OperatorGraph.AddOperator(value); 524 524 mySGAMain.AddSubOperator(value, 1); … … 533 533 set { 534 534 value.Name = "Mutator"; 535 mySGA.OperatorGraph.RemoveOperator(Mutator .Guid);535 mySGA.OperatorGraph.RemoveOperator(Mutator); 536 536 mySGA.OperatorGraph.AddOperator(value); 537 537 mySGAMain.AddSubOperator(value, 2); … … 552 552 /// Clones the current instance (deep clone). 553 553 /// </summary> 554 /// <remarks>Deep clone through <see cref=" Auxiliary.Clone"/> method of helper class554 /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class 555 555 /// <see cref="Auxiliary"/>.</remarks> 556 556 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 557 557 /// <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) { 559 559 SGA clone = new SGA(); 560 clone dObjects.Add(Guid, clone);561 clone.myEngine = (IEngine) Auxiliary.Clone(Engine, clonedObjects);560 cloner.RegisterClonedObject(this, clone); 561 clone.myEngine = (IEngine)cloner.Clone(Engine); 562 562 return clone; 563 563 } -
trunk/sources/HeuristicLab.ThreadParallelEngine/3.3/ThreadParallelEngine.cs
r2520 r2526 73 73 /// <inheritdoc/> 74 74 /// <returns>The cloned object as <see cref="ThreadParallelEngine"/>.</returns> 75 public override object Clone(IDictionary<Guid, object> clonedObjects) {76 ThreadParallelEngine clone = (ThreadParallelEngine)base.Clone(clone dObjects);75 public override IItem Clone(ICloner cloner) { 76 ThreadParallelEngine clone = (ThreadParallelEngine)base.Clone(cloner); 77 77 clone.myWorkers = Workers; 78 78 return clone;
Note: See TracChangeset
for help on using the changeset viewer.