Changeset 2033


Ignore:
Timestamp:
06/09/09 00:57:49 (12 years ago)
Author:
swagner
Message:

Refactoring of the operator architecture (#95)

Location:
branches/Operator Architecture Refactoring
Files:
10 added
7 deleted
26 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/Operator Architecture Refactoring/HeuristicLab.AdvancedOptimizationFrontend/3.3/MainForm.cs

    r1921 r2033  
    4141    private class Task {
    4242      public string filename;
    43       public IStorable storable;
     43      public object instance;
    4444      public IEditor editor;
    4545
    4646      private Task() { }
    47       public Task(string filename, IStorable storable, IEditor editor) {
     47      public Task(string filename, object instance, IEditor editor) {
    4848        this.filename = filename;
    49         this.storable = storable;
     49        this.instance = instance;
    5050        this.editor = editor;
    5151      }
     
    154154      Task task = (Task)state;
    155155      try {
    156         task.storable = PersistenceManager.Load(task.filename);
     156        task.instance = PersistenceManager.Load(task.filename);
    157157      } catch (FileNotFoundException fileNotFoundEx) {
    158158        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.",
     
    175175      else {
    176176        IEditor editor = null;
    177         if (task.storable != null) {
    178           IEditable editable = task.storable as IEditable;
     177        if (task.instance != null) {
     178          IEditable editable = task.instance as IEditable;
    179179          if (editable != null)
    180180            editor = editable.CreateEditor();
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/AtomicOperation.cs

    r1823 r2033  
    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 object Clone(IDictionary<long, object> clonedObjects) {
    7575      AtomicOperation clone = new AtomicOperation();
    76       clonedObjects.Add(Guid, clone);
     76      clonedObjects.Add(clone.Id, clone);
    7777      clone.myOperator = (IOperator)Auxiliary.Clone(Operator, clonedObjects);
    7878      clone.myScope = (IScope)Auxiliary.Clone(Scope, clonedObjects);
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Auxiliary.cs

    r1529 r2033  
    3838    /// <param name="clonedObjects">A dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    3939    /// <returns>The cloned object.</returns>
    40     public static object Clone(IStorable obj, IDictionary<Guid, object> clonedObjects) {
     40    public static object Clone(ICloneable obj, IDictionary<long, object> clonedObjects) {
    4141      object clone;
    42       if (clonedObjects.TryGetValue(obj.Guid, out clone))
     42      if (clonedObjects.TryGetValue(obj.Id, out clone))
    4343        return clone;
    4444      else
     
    8484    }
    8585    #endregion
    86 
    87     #region Constraint Violation Messages
    88     /// <summary>
    89     /// Shows a warning message box with an OK-Button, indicating that the given constraints were violated and so
    90     /// the operation could not be completed.
    91     /// </summary>
    92     /// <param name="violatedConstraints">The constraints that could not be fulfilled.</param>
    93     public static void ShowConstraintViolationMessageBox(ICollection<IConstraint> violatedConstraints) {
    94       string message = BuildConstraintViolationMessage(violatedConstraints);
    95       MessageBox.Show("The following constraints are violated. The operation could not be completed.\n\n" + message,
    96                       "Constraint Violation",
    97                       MessageBoxButtons.OK,
    98                       MessageBoxIcon.Warning);
    99     }
    100     /// <summary>
    101     /// Shows a question message box with a yes-no option, where to choose whether to ignore
    102     /// the given violated constraints and to complete the operation or not.
    103     /// </summary>
    104     /// <param name="violatedConstraints">The constraints that could not be fulfilled.</param>
    105     /// <returns>The result of the choice ("Yes" = 6, "No" = 7).</returns>
    106     public static DialogResult ShowIgnoreConstraintViolationMessageBox(ICollection<IConstraint> violatedConstraints) {
    107       string message = BuildConstraintViolationMessage(violatedConstraints);
    108       return MessageBox.Show("The following constraints are violated. Do you want to complete the operation anyhow?\n\n" + message,
    109                              "Constraint Violation",
    110                              MessageBoxButtons.YesNo,
    111                              MessageBoxIcon.Question);
    112     }
    113     /// <summary>
    114     /// Builds a message out of a given collection of violated constraints,
    115     /// including the constraints type and description.
    116     /// </summary>
    117     /// <param name="violatedConstraints">The constraints that could not be fulfilled.</param>
    118     /// <returns>The message to display.</returns>
    119     private static string BuildConstraintViolationMessage(ICollection<IConstraint> violatedConstraints) {
    120       StringBuilder sb = new StringBuilder();
    121       foreach (IConstraint constraint in violatedConstraints) {
    122         sb.AppendLine(constraint.GetType().Name);
    123         sb.AppendLine(constraint.Description);
    124         sb.AppendLine();
    125       }
    126       return sb.ToString();
    127     }
    128     #endregion
    12986  }
    13087}
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/CloneableBase.cs

    r2032 r2033  
    2323using System.Collections.Generic;
    2424using System.Text;
    25 using System.Xml;
     25using System.Runtime.InteropServices;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    2828namespace HeuristicLab.Core {
    2929  /// <summary>
    30   /// The base class for all storable objects.
     30  /// The base class for all cloneable objects.
    3131  /// </summary>
    32   public abstract class StorableBase : IStorable {
    33 
    34     [Storable]
    35     private Guid myGuid;
     32  public abstract class CloneableBase : ICloneable {
    3633    /// <summary>
    37     /// Gets the Guid of the item.
     34    /// Gets a unique id (memory address) of the current instance. The id is used to
     35    /// detect, if an object has already been cloned or not.
    3836    /// </summary>
    39     public Guid Guid {
    40       get { return myGuid; }
    41     }
    42 
    43     /// <summary>
    44     /// Initializes a new instance of the class <see cref="StorableBase"/> with a new <see cref="Guid"/>.
    45     /// </summary>
    46     protected StorableBase() {
    47       myGuid = Guid.NewGuid();
     37    public long Id {
     38      get {
     39        GCHandle handle = new GCHandle();
     40        handle.Target = this;
     41        return GCHandle.ToIntPtr(handle).ToInt64();
     42      }
    4843    }
    4944
     
    5449    /// <returns>The clone.</returns>
    5550    public object Clone() {
    56       return Auxiliary.Clone(this, new Dictionary<Guid, object>());
     51      return Auxiliary.Clone(this, new Dictionary<long, object>());
    5752    }
    5853    /// <summary>
     
    6257    /// <param name="clonedObjects">All already cloned objects.</param>
    6358    /// <returns>The clone.</returns>
    64     public virtual object Clone(IDictionary<Guid, object> clonedObjects) {
    65       object clone = Activator.CreateInstance(this.GetType());
    66       clonedObjects.Add(Guid, clone);
     59    public virtual object Clone(IDictionary<long, object> clonedObjects) {
     60      CloneableBase clone = (CloneableBase)Activator.CreateInstance(this.GetType());
     61      clonedObjects.Add(clone.Id, clone);
    6762      return clone;
    6863    }
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/CompositeOperation.cs

    r1823 r2033  
    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 object Clone(IDictionary<long, object> clonedObjects) {
    8787      CompositeOperation clone = new CompositeOperation();
    88       clonedObjects.Add(Guid, clone);
     88      clonedObjects.Add(clone.Id, clone);
    8989      clone.myExecuteInParallel = ExecuteInParallel;
    9090      for (int i = 0; i < Operations.Count; i++)
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/EngineBase.cs

    r1823 r2033  
    130130    /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
    131131    /// <returns>The cloned object as <see cref="EngineBase"/>.</returns>
    132     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     132    public override object Clone(IDictionary<long, object> clonedObjects) {
    133133      EngineBase clone = (EngineBase)base.Clone(clonedObjects);
    134134      clone.myOperatorGraph = (IOperatorGraph)Auxiliary.Clone(OperatorGraph, clonedObjects);
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj

    r1667 r2033  
    113113      <DependentUpon>ChooseOperatorDialog.cs</DependentUpon>
    114114    </Compile>
    115     <Compile Include="ConstrainedItemBase.cs" />
    116     <Compile Include="ConstrainedItemBaseView.cs">
    117       <SubType>UserControl</SubType>
    118     </Compile>
    119     <Compile Include="ConstrainedItemBaseView.Designer.cs">
    120       <DependentUpon>ConstrainedItemBaseView.cs</DependentUpon>
    121     </Compile>
    122     <Compile Include="ConstraintEventArgs.cs" />
     115    <Compile Include="CloneableBase.cs" />
    123116    <Compile Include="AtomicOperation.cs" />
    124117    <Compile Include="CompositeOperation.cs" />
     
    130123    </Compile>
    131124    <Compile Include="AliasEventArgs.cs" />
     125    <Compile Include="CallGraph.cs" />
     126    <Compile Include="CallNode.cs" />
     127    <Compile Include="ParameterView.cs">
     128      <SubType>UserControl</SubType>
     129    </Compile>
     130    <Compile Include="ParameterView.Designer.cs">
     131      <DependentUpon>ParameterView.cs</DependentUpon>
     132    </Compile>
     133    <Compile Include="Parameter.cs" />
     134    <Compile Include="ParameterType.cs" />
     135    <Compile Include="Interfaces\IParameter.cs" />
     136    <Compile Include="Interfaces\ICallNode.cs" />
     137    <Compile Include="Interfaces\ICallGraph.cs" />
     138    <Compile Include="Interfaces\ICloneable.cs" />
    132139    <Compile Include="KeyValueEventArgs.cs" />
    133140    <Compile Include="OperatorBaseDescriptionView.cs">
     
    155162    </Compile>
    156163    <Compile Include="ExceptionEventArgs.cs" />
    157     <Compile Include="Interfaces\IConstrainedItem.cs" />
    158     <Compile Include="Interfaces\IConstraint.cs" />
    159164    <Compile Include="Interfaces\IItem.cs" />
    160165    <Compile Include="ItemBase.cs" />
     
    248253    <Compile Include="Interfaces\IRandom.cs" />
    249254    <Compile Include="OperatorGraph.cs" />
    250     <Compile Include="StorableBase.cs" />
    251255    <Compile Include="Scope.cs" />
    252256    <Compile Include="EngineBase.cs" />
    253257    <Compile Include="Interfaces\IEngine.cs" />
    254258    <Compile Include="Interfaces\IOperator.cs" />
    255     <Compile Include="Interfaces\IStorable.cs" />
    256259    <Compile Include="PersistenceManager.cs" />
    257260    <Compile Include="HeuristicLabCorePlugin.cs" />
     
    290293      <SubType>Designer</SubType>
    291294    </EmbeddedResource>
    292     <EmbeddedResource Include="ConstrainedItemBaseView.resx">
    293       <DependentUpon>ConstrainedItemBaseView.cs</DependentUpon>
    294       <SubType>Designer</SubType>
    295     </EmbeddedResource>
    296295    <EmbeddedResource Include="ChooseTypeDialog.resx">
    297296      <DependentUpon>ChooseTypeDialog.cs</DependentUpon>
     297      <SubType>Designer</SubType>
     298    </EmbeddedResource>
     299    <EmbeddedResource Include="ParameterView.resx">
     300      <DependentUpon>ParameterView.cs</DependentUpon>
    298301      <SubType>Designer</SubType>
    299302    </EmbeddedResource>
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/ICloneable.cs

    r2032 r2033  
    2626
    2727namespace HeuristicLab.Core {
    28 
    2928  /// <summary>
    30   /// Interface to represent objects that are de- and serializeable.
     29  /// Interface to represent objects that are cloneable.
    3130  /// </summary>
    32   public interface IStorable {
    33 
     31  public interface ICloneable : System.ICloneable {
    3432    /// <summary>
    35     /// Gets the objects unique identifier.
     33    /// Gets a unique id representing the current object. This id is used to check, if an object has
     34    /// already been cloned (to avoid cycles).
    3635    /// </summary>
    37     Guid Guid { get; }
    38 
    39     /// <summary>
    40     /// Clones the current instance (deep clone).
    41     /// </summary>
    42     /// <returns>The cloned object.</returns>
    43     object Clone();
    44 
     36    long Id { get; }
    4537    /// <summary>
    4638    /// Clones the current instance, considering already cloned objects.
     
    4840    /// <param name="clonedObjects">All already cloned objects. (Needed to avoid cycles.)</param>
    4941    /// <returns>The cloned object.</returns>
    50     object Clone(IDictionary<Guid, object> clonedObjects);
     42    object Clone(IDictionary<long, object> clonedObjects);
    5143  }
    5244}
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IItem.cs

    r776 r2033  
    2828  /// Interface to represent (almost) every HeuristicLab object (an object, an operator,...).
    2929  /// </summary>
    30   public interface IItem : IStorable, IViewable {
    31     /// <summary>
    32     /// Fires a new <c>Changed</c> event.
    33     /// </summary>
    34     void FireChanged();
    35 
    36     /// <summary>
    37     /// Occurs when the current instance has changed.
    38     /// </summary>
    39     event EventHandler Changed;
     30  public interface IItem : ICloneable, IViewable {
    4031  }
    4132}
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IOperator.cs

    r776 r2033  
    2929  /// a basic instruction of an algorithm.
    3030  /// </summary>
    31   public interface IOperator : IConstrainedItem {
     31  public interface IOperator : IItem {
    3232    /// <summary>
    3333    /// Gets or sets the name of the current instance.
     
    6767    void AddSubOperator(IOperator op);
    6868    /// <summary>
    69     /// Adds the given sub operator to the current instance if all constraints can be fulfilled.
    70     /// </summary>
    71     /// <param name="op">The operator to add.</param>
    72     /// <returns><c>true</c> if the operator could be added without violating constraints,
    73     /// <c>false</c> otherwise.</returns>
    74     bool TryAddSubOperator(IOperator op);
    75     /// <summary>
    76     /// Adds the given sub operator to the current instance if all constraints can be fulfilled.
    77     /// </summary>
    78     /// <param name="op">The operator to add.</param>
    79     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    80     /// fulfilled.</param>
    81     /// <returns><c>true</c> if the operator could be added without violating constraints,
    82     /// <c>false</c> otherwise.</returns>
    83     bool TryAddSubOperator(IOperator op, out ICollection<IConstraint> violatedConstraints);
    84     /// <summary>
    8569    /// Adds the given sub operator at a the specified <paramref name="index"/>.
    8670    /// </summary>
     
    8973    void AddSubOperator(IOperator op, int index);
    9074    /// <summary>
    91     /// Adds the given operator at the specified <paramref name="index"/> to the current instance
    92     /// if all constraints can be fulfilled.
    93     /// </summary>
    94     /// <param name="op">The operator to add.</param>
    95     /// <param name="index">The position where to add the operator.</param>
    96     /// <returns><c>true</c> if the operator could be added without violating constraints,
    97     /// <c>false</c> otherwise.</returns>
    98     bool TryAddSubOperator(IOperator op, int index);
    99     /// <summary>
    100     /// Adds the given operator at the specified <paramref name="index"/> to the current instance
    101     /// if all constraints can be fulfilled.
    102     /// </summary>
    103     /// <param name="op">The operator to add.</param>
    104     /// <param name="index">The position where to add the operator.</param>
    105     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    106     /// fulfilled.</param>
    107     /// <returns><c>true</c> if the operator could be added without violating constraints,
    108     /// <c>false</c> otherwise.</returns>
    109     bool TryAddSubOperator(IOperator op, int index, out ICollection<IConstraint> violatedConstraints);
    110     /// <summary>
    11175    /// Removes a sub operator at the specified <paramref name="index"/>.
    11276    /// </summary>
    11377    /// <param name="index">The position where to delete the operator.</param>
    11478    void RemoveSubOperator(int index);
    115     /// <summary>
    116     /// Removes a sub operator at the specified <paramref name="index"/> if all constraint can be fulfilled.
    117     /// </summary>
    118     /// <param name="index">The position where to delete the operator.</param>
    119     /// <returns><c>true</c> if the operator could be deleted without violating constraints,
    120     /// <c>false</c> otherwise.</returns>
    121     bool TryRemoveSubOperator(int index);
    122     /// <summary>
    123     /// Deletes the operator at the specified <paramref name="index"/> 
    124     /// if all constraints can be fulfilled.
    125     /// </summary>
    126     /// <param name="index">The position where to delete the operator.</param>
    127     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    128     /// fulfilled.</param>
    129     /// <returns><c>true</c> if the operator could be deleted without violating constraints,
    130     /// <c>false</c> otherwise.</returns>
    131     bool TryRemoveSubOperator(int index, out ICollection<IConstraint> violatedConstraints);
    13279
    13380    /// <summary>
     
    14390    void AddVariableInfo(IVariableInfo variableInfo);
    14491    /// <summary>
    145     /// Adds the specified variable info to the current instance, if all constraints can be fulfilled.
    146     /// </summary>
    147     /// <param name="variableInfo">The variable info to add.</param>
    148     /// <returns><c>true</c> if the variable info could be added without violating constraints,
    149     /// <c>false</c> otherwise.</returns>
    150     bool TryAddVariableInfo(IVariableInfo variableInfo);
    151     /// <summary>
    152     /// Adds the specified variable info to the current instance, if all constraints can be fulfilled.
    153     /// </summary>
    154     /// <param name="variableInfo">The variable info to add.</param>
    155     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    156     /// fulfilled.</param>
    157     /// <returns><c>true</c> if the variable info could be added without violating constraints,
    158     /// <c>false</c> otherwise.</returns>
    159     bool TryAddVariableInfo(IVariableInfo variableInfo, out ICollection<IConstraint> violatedConstraints);
    160     /// <summary>
    16192    /// Removes the variable info with the given formal name.
    16293    /// </summary>
    16394    /// <param name="formalName">The formal name of the variable info to remove.</param>
    16495    void RemoveVariableInfo(string formalName);
    165     /// <summary>
    166     /// Deletes the variable info with the given formal name,
    167     /// if all constraints can be fulfilled.
    168     /// </summary>
    169     /// <param name="formalName">The formal name of the variable info to remove.</param>
    170     /// <returns><c>true</c> if the variable info could be deleted without violating constraints,
    171     /// <c>false</c> otherwise.</returns>
    172     bool TryRemoveVariableInfo(string formalName);
    173     /// <summary>
    174     /// Deletes the variable info with the given formal name,
    175     /// if all constraints can be fulfilled.
    176     /// </summary>
    177     /// <param name="formalName">The formal name of the variable info to remove.</param>
    178     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    179     /// fulfilled.</param>
    180     /// <returns><c>true</c> if the variable info could be deleted without violating constraints,
    181     /// <c>false</c> otherwise.</returns>
    182     bool TryRemoveVariableInfo(string formalName, out ICollection<IConstraint> violatedConstraints);
    18396
    18497    /// <summary>
     
    194107    void AddVariable(IVariable variable);
    195108    /// <summary>
    196     /// Adds the specified <paramref name="variable"/> to the current instance if all constraints can
    197     /// be fulfilled.
    198     /// </summary>
    199     /// <param name="variable">The variable to add.</param>
    200     /// <returns><c>true</c> if the variable could be added without violating constraints,
    201     /// <c>false</c> otherwise.</returns>
    202     bool TryAddVariable(IVariable variable);
    203     /// <summary>
    204     /// Adds the specified <paramref name="variable"/> to the current instance if all constraints can
    205     /// be fulfilled.
    206     /// </summary>
    207     /// <param name="variable">The variable to add.</param>
    208     /// <param name="violatedConstraints">Output parameter; contains all constraints that could
    209     /// not be fulfillled.</param>
    210     /// <returns><c>true</c> if the variable could be added without violating constraints,
    211     /// <c>false</c> otherwise.</returns>
    212     bool TryAddVariable(IVariable variable, out ICollection<IConstraint> violatedConstraints);
    213     /// <summary>
    214109    /// Deletes the variable with the specified <paramref name="name"/>.
    215110    /// </summary>
    216111    /// <param name="name">The name of the variable to delete.</param>
    217112    void RemoveVariable(string name);
    218     /// <summary>
    219     /// Deletes the variable with the specified <paramref name="name"/> if all constraints can be
    220     /// fulfilled.
    221     /// </summary>
    222     /// <param name="name">The name of the variable to remove.</param>
    223     /// <returns><c>true</c> if the variable could be deleted without violating constraints,
    224     /// <c>false</c> otherwise.</returns>
    225     bool TryRemoveVariable(string name);
    226     /// <summary>
    227     /// Deletes the variable with the specified <paramref name="name"/> if all constraints can be
    228     /// fulfilled.
    229     /// </summary>
    230     /// <param name="name">The name of the variable to remove.</param>
    231     /// <param name="violatedConstraints">Output parameter; contains all constraints that could
    232     /// not be fulfilled.</param>
    233     /// <returns><c>true</c> if the variable could be deleted without violating constraints,
    234     /// <c>false</c> otherwise.</returns>
    235     bool TryRemoveVariable(string name, out ICollection<IConstraint> violatedConstraints);
    236    
     113
    237114    /// <inheritdoc cref="GetVariableValue(string, HeuristicLab.Core.IScope, bool)"/>
    238115    /// <typeparam name="T">The type of the value that is searched.</typeparam>       
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IOperatorGraph.cs

    r776 r2033  
    4545    void AddOperator(IOperator op);
    4646    /// <summary>
    47     /// Removes an operator with the specified <paramref name="guid"/> from the current instance.
     47    /// Removes an operator from the current instance.
    4848    /// </summary>
    49     /// <param name="guid">The unique id of the operator to remove.</param>
    50     void RemoveOperator(Guid guid);
    51     /// <summary>
    52     /// Gets the operator with the specified <paramref name="guid"/>.
    53     /// </summary>
    54     /// <param name="guid">The unique id of the operator.</param>
    55     /// <returns>The searched operator.</returns>
    56     IOperator GetOperator(Guid guid);
     49    /// <param name="op">The operator that should be removed.</param>
     50    void RemoveOperator(IOperator op);
    5751    /// <summary>
    5852    /// Clears the current instance.
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IOperatorGroup.cs

    r776 r2033  
    2929  /// Interface to represent a group of operators.
    3030  /// </summary>
    31   public interface IOperatorGroup : IStorable {
     31  public interface IOperatorGroup : ICloneable {
    3232    /// <summary>
    3333    /// Gets or sets the name of the current instance.
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IScope.cs

    r801 r2033  
    129129    void ReorderSubScopes(int[] sequence);
    130130    /// <summary>
    131     /// Gets the sub scope with the given <paramref name="guid"/>.
    132     /// </summary>
    133     /// <param name="guid">The unique identifier of the sub scope.</param>
    134     /// <returns>The sub scope with the given <paramref name="guid"/>.</returns>
    135     IScope GetScope(Guid guid);
    136     /// <summary>
    137131    /// Gets the sub scope with the given <paramref name="name"/>.
    138132    /// </summary>
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IViewable.cs

    r776 r2033  
    3434    /// <returns>The created view.</returns>
    3535    IView CreateView();
     36
     37    /// <summary>
     38    /// Fires a new <c>Changed</c> event.
     39    /// </summary>
     40    void FireChanged();
     41    /// <summary>
     42    /// Occurs when the current instance has changed.
     43    /// </summary>
     44    event EventHandler Changed;
    3645  }
    3746}
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/ItemBase.cs

    r1853 r2033  
    3131  /// </summary>
    3232  [EmptyStorableClass]
    33   public abstract class ItemBase : StorableBase, IItem {
     33  public abstract class ItemBase : CloneableBase, IItem {
    3434    /// <summary>
    3535    /// Creates a new instance of <see cref="ItemBaseView"/> for
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorBase.cs

    r1823 r2033  
    3030  /// The base class for all operators.
    3131  /// </summary>
    32   public abstract class OperatorBase : ConstrainedItemBase, IOperator {
     32  public abstract class OperatorBase : ItemBase, IOperator {
    3333
    3434    [Storable]
     
    130130    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    131131    /// <returns>The cloned object as <see cref="OperatorBase"/>.</returns>
    132     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     132    public override object Clone(IDictionary<long, object> clonedObjects) {
    133133      OperatorBase clone = (OperatorBase)base.Clone(clonedObjects);
    134134      clone.myName = Name;
     
    162162      OnSubOperatorAdded(subOperator, mySubOperators.Count - 1);
    163163    }
    164     /// <inheritdoc cref="IOperator.TryAddSubOperator(HeuristicLab.Core.IOperator)"/>
    165     /// <param name="subOperator">The sub operator to add.</param>
    166     /// <remarks>Calls <see cref="OnSubOperatorAdded"/>.</remarks>
    167     public virtual bool TryAddSubOperator(IOperator subOperator) {
    168       mySubOperators.Add(subOperator);
    169       if (IsValid()) {
    170         OnSubOperatorAdded(subOperator, mySubOperators.Count - 1);
    171         return true;
    172       } else {
    173         mySubOperators.RemoveAt(mySubOperators.Count - 1);
    174         return false;
    175       }
    176     }
    177     /// <inheritdoc cref="HeuristicLab.Core.IOperator.TryAddSubOperator(HeuristicLab.Core.IOperator,
    178     /// out System.Collections.Generic.ICollection&lt;HeuristicLab.Core.IConstraint&gt;)"/>
    179     /// <param name="subOperator">The sub operator to add.</param>
    180     /// <remarks>Calls <see cref="OnSubOperatorAdded"/>.</remarks>
    181     public virtual bool TryAddSubOperator(IOperator subOperator, out ICollection<IConstraint> violatedConstraints) {
    182       mySubOperators.Add(subOperator);
    183       if (IsValid(out violatedConstraints)) {
    184         OnSubOperatorAdded(subOperator, mySubOperators.Count - 1);
    185         return true;
    186       } else {
    187         mySubOperators.RemoveAt(mySubOperators.Count - 1);
    188         return false;
    189       }
    190     }
    191164    /// <inheritdoc cref="HeuristicLab.Core.IOperator.AddSubOperator(HeuristicLab.Core.IOperator, int)"/>
    192165    /// <param name="subOperator">The sub operator to add.</param>
     
    196169      OnSubOperatorAdded(subOperator, index);
    197170    }
    198     /// <inheritdoc cref="IOperator.TryAddSubOperator(HeuristicLab.Core.IOperator, int)"/>
    199     /// <param name="subOperator">The sub operator to add.</param>
    200     /// <remarks>Calls <see cref="OnSubOperatorAdded"/>.</remarks>
    201     public virtual bool TryAddSubOperator(IOperator subOperator, int index) {
    202       mySubOperators.Insert(index, subOperator);
    203       if (IsValid()) {
    204         OnSubOperatorAdded(subOperator, index);
    205         return true;
    206       } else {
    207         mySubOperators.RemoveAt(index);
    208         return false;
    209       }
    210     }
    211     /// <inheritdoc cref="IOperator.TryAddSubOperator(HeuristicLab.Core.IOperator, int, out
    212     /// System.Collections.Generic.ICollection&lt;HeuristicLab.Core.IConstraint&gt;)"/>
    213     /// <param name="subOperator">The sub operator to add.</param>
    214     /// <remarks>Calls <see cref="OnSubOperatorAdded"/>.</remarks>
    215     public virtual bool TryAddSubOperator(IOperator subOperator, int index, out ICollection<IConstraint> violatedConstraints) {
    216       mySubOperators.Insert(index, subOperator);
    217       if (IsValid(out violatedConstraints)) {
    218         OnSubOperatorAdded(subOperator, index);
    219         return true;
    220       } else {
    221         mySubOperators.RemoveAt(index);
    222         return false;
    223       }
    224     }
    225171    /// <inheritdoc/>
    226172    /// <remarks>Calls <see cref="OnSubOperatorRemoved"/>.</remarks>
     
    229175      mySubOperators.RemoveAt(index);
    230176      OnSubOperatorRemoved(op, index);
    231     }
    232     /// <inheritdoc/>
    233     /// <remarks>Calls <see cref="OnSubOperatorRemoved"/>.</remarks>
    234     public virtual bool TryRemoveSubOperator(int index) {
    235       IOperator op = mySubOperators[index];
    236       mySubOperators.RemoveAt(index);
    237       if (IsValid()) {
    238         OnSubOperatorRemoved(op, index);
    239         return true;
    240       } else {
    241         mySubOperators.Insert(index, op);
    242         return false;
    243       }
    244     }
    245     /// <inheritdoc/>
    246     /// <remarks>Calls <see cref="OnSubOperatorRemoved"/>.</remarks>
    247     public virtual bool TryRemoveSubOperator(int index, out ICollection<IConstraint> violatedConstraints) {
    248       IOperator op = mySubOperators[index];
    249       mySubOperators.RemoveAt(index);
    250       if (IsValid(out violatedConstraints)) {
    251         OnSubOperatorRemoved(op, index);
    252         return true;
    253       } else {
    254         mySubOperators.Insert(index, op);
    255         return false;
    256       }
    257177    }
    258178    #endregion
     
    274194    }
    275195    /// <inheritdoc/>
    276     /// <remarks>Calls <see cref="OnVariableInfoAdded"/>.</remarks>
    277     public virtual bool TryAddVariableInfo(IVariableInfo variableInfo) {
    278       myVariableInfos.Add(variableInfo.FormalName, variableInfo);
    279       if (IsValid()) {
    280         OnVariableInfoAdded(variableInfo);
    281         return true;
    282       } else {
    283         myVariableInfos.Remove(variableInfo.FormalName);
    284         return false;
    285       }
    286     }
    287     /// <inheritdoc/>
    288     /// <remarks>Calls <see cref="OnVariableInfoAdded"/>.</remarks>
    289     public virtual bool TryAddVariableInfo(IVariableInfo variableInfo, out ICollection<IConstraint> violatedConstraints) {
    290       myVariableInfos.Add(variableInfo.FormalName, variableInfo);
    291       if (IsValid(out violatedConstraints)) {
    292         OnVariableInfoAdded(variableInfo);
    293         return true;
    294       } else {
    295         myVariableInfos.Remove(variableInfo.FormalName);
    296         return false;
    297       }
    298     }
    299     /// <inheritdoc/>
    300196    /// <remarks>Calls <see cref="OnVariableInfoRemoved"/>.</remarks>
    301197    public virtual void RemoveVariableInfo(string formalName) {
     
    305201        OnVariableInfoRemoved(variableInfo);
    306202      }
    307     }
    308     /// <inheritdoc/>
    309     /// <remarks>Calls <see cref="OnVariableInfoRemoved"/>.</remarks>
    310     public virtual bool TryRemoveVariableInfo(string formalName) {
    311       IVariableInfo variableInfo;
    312       if (myVariableInfos.TryGetValue(formalName, out variableInfo)) {
    313         myVariableInfos.Remove(formalName);
    314         if (IsValid()) {
    315           OnVariableInfoRemoved(variableInfo);
    316           return true;
    317         } else {
    318           myVariableInfos.Add(formalName, variableInfo);
    319           return false;
    320         }
    321       }
    322       return true;
    323     }
    324     /// <inheritdoc/>
    325     /// <remarks>Calls <see cref="OnVariableInfoRemoved"/>.</remarks>
    326     public virtual bool TryRemoveVariableInfo(string formalName, out ICollection<IConstraint> violatedConstraints) {
    327       IVariableInfo variableInfo;
    328       if (myVariableInfos.TryGetValue(formalName, out variableInfo)) {
    329         myVariableInfos.Remove(formalName);
    330         if (IsValid(out violatedConstraints)) {
    331           OnVariableInfoRemoved(variableInfo);
    332           return true;
    333         } else {
    334           myVariableInfos.Add(formalName, variableInfo);
    335           return false;
    336         }
    337       }
    338       violatedConstraints = new List<IConstraint>();
    339       return true;
    340203    }
    341204    #endregion
     
    358221      variable.NameChanged += new EventHandler(Variable_NameChanged);
    359222      OnVariableAdded(variable);
    360     }
    361     /// <inheritdoc/>
    362     /// <remarks>Calls <see cref="OnVariableAdded"/> and adds <c>NameChanging</c> and <c>NameChanged</c>
    363     /// event handlers.</remarks>
    364     public virtual bool TryAddVariable(IVariable variable) {
    365       myVariables.Add(variable.Name, variable);
    366       if (IsValid()) {
    367         variable.NameChanging += new EventHandler<NameChangingEventArgs>(Variable_NameChanging);
    368         variable.NameChanged += new EventHandler(Variable_NameChanged);
    369         OnVariableAdded(variable);
    370         return true;
    371       } else {
    372         myVariableInfos.Remove(variable.Name);
    373         return false;
    374       }
    375     }
    376     /// <inheritdoc/>
    377     /// <remarks>Calls <see cref="OnVariableAdded"/> and adds <c>NameChanging</c> and <c>NameChanged</c>
    378     /// event handlers.</remarks>
    379     public virtual bool TryAddVariable(IVariable variable, out ICollection<IConstraint> violatedConstraints) {
    380       myVariables.Add(variable.Name, variable);
    381       if (IsValid(out violatedConstraints)) {
    382         variable.NameChanging += new EventHandler<NameChangingEventArgs>(Variable_NameChanging);
    383         variable.NameChanged += new EventHandler(Variable_NameChanged);
    384         OnVariableAdded(variable);
    385         return true;
    386       } else {
    387         myVariableInfos.Remove(variable.Name);
    388         return false;
    389       }
    390223    }
    391224    /// <inheritdoc/>
     
    400233        OnVariableRemoved(variable);
    401234      }
    402     }
    403     /// <inheritdoc/>
    404     /// <remarks>Calls <see cref="OnVariableRemoved"/> and removes <c>NameChanging</c> and <c>NameChanged</c>
    405     /// event handlers.</remarks>
    406     public virtual bool TryRemoveVariable(string name) {
    407       IVariable variable;
    408       if (myVariables.TryGetValue(name, out variable)) {
    409         myVariables.Remove(name);
    410         if (IsValid()) {
    411           variable.NameChanging -= new EventHandler<NameChangingEventArgs>(Variable_NameChanging);
    412           variable.NameChanged -= new EventHandler(Variable_NameChanged);
    413           OnVariableRemoved(variable);
    414           return true;
    415         } else {
    416           myVariables.Add(name, variable);
    417           return false;
    418         }
    419       }
    420       return true;
    421     }
    422     /// <inheritdoc/>
    423     /// <remarks>Calls <see cref="OnVariableRemoved"/> and removes <c>NameChanging</c> and <c>NameChanged</c>
    424     /// event handlers.</remarks>
    425     public virtual bool TryRemoveVariable(string name, out ICollection<IConstraint> violatedConstraints) {
    426       IVariable variable;
    427       if (myVariables.TryGetValue(name, out variable)) {
    428         myVariables.Remove(name);
    429         if (IsValid(out violatedConstraints)) {
    430           variable.NameChanging -= new EventHandler<NameChangingEventArgs>(Variable_NameChanging);
    431           variable.NameChanged -= new EventHandler(Variable_NameChanged);
    432           OnVariableRemoved(variable);
    433           return true;
    434         } else {
    435           myVariables.Add(name, variable);
    436           return false;
    437         }
    438       }
    439       violatedConstraints = new List<IConstraint>();
    440       return true;
    441235    }
    442236    private void Variable_NameChanging(object sender, NameChangingEventArgs e) {
     
    489283    }
    490284    #endregion
     285
    491286    /// <inheritdoc/>
    492287    public virtual IOperation Execute(IScope scope) {
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorBaseView.Designer.cs

    r1529 r2033  
    5454      this.operatorBaseVariablesView = new HeuristicLab.Core.OperatorBaseVariablesView();
    5555      this.constraintsTabPage = new System.Windows.Forms.TabPage();
    56       this.constrainedItemBaseView = new HeuristicLab.Core.ConstrainedItemBaseView();
    5756      this.descriptionTabPage = new System.Windows.Forms.TabPage();
    5857      this.operatorBaseDescriptionView = new HeuristicLab.Core.OperatorBaseDescriptionView();
     
    121120      // constraintsTabPage
    122121      //
    123       this.constraintsTabPage.Controls.Add(this.constrainedItemBaseView);
    124122      this.constraintsTabPage.Location = new System.Drawing.Point(4, 22);
    125123      this.constraintsTabPage.Name = "constraintsTabPage";
     
    129127      this.constraintsTabPage.Text = "Constraints";
    130128      this.constraintsTabPage.UseVisualStyleBackColor = true;
    131       //
    132       // constrainedItemBaseView
    133       //
    134       this.constrainedItemBaseView.Caption = "Constrained Data";
    135       this.constrainedItemBaseView.ConstrainedItem = null;
    136       this.constrainedItemBaseView.Dock = System.Windows.Forms.DockStyle.Fill;
    137       this.constrainedItemBaseView.Location = new System.Drawing.Point(3, 3);
    138       this.constrainedItemBaseView.Name = "constrainedItemBaseView";
    139       this.constrainedItemBaseView.Size = new System.Drawing.Size(409, 301);
    140       this.constrainedItemBaseView.TabIndex = 0;
    141129      //
    142130      // descriptionTabPage
     
    184172    protected TabPage variablesTabPage;
    185173    private TabPage constraintsTabPage;
    186     protected ConstrainedItemBaseView constrainedItemBaseView;
    187174    protected OperatorBaseVariableInfosView operatorBaseVariableInfosView;
    188175    protected OperatorBaseVariablesView operatorBaseVariablesView;
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorBaseView.cs

    r1529 r2033  
    6868      operatorBaseVariableInfosView.Operator = null;
    6969      operatorBaseVariablesView.Operator = null;
    70       constrainedItemBaseView.ConstrainedItem = null;
    7170      operatorBaseDescriptionView.Operator = null;
    7271      base.RemoveItemEvents();
     
    7978      operatorBaseVariableInfosView.Operator = Operator;
    8079      operatorBaseVariablesView.Operator = Operator;
    81       constrainedItemBaseView.ConstrainedItem = Operator;
    8280      operatorBaseDescriptionView.Operator = Operator;
    8381    }
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorGraph.cs

    r1823 r2033  
    3333
    3434    [Storable]
    35     private IDictionary<Guid, IOperator> myOperators;
     35    private IList<IOperator> myOperators;
    3636    /// <summary>
    3737    /// Gets all operators of the current instance.
    3838    /// </summary>
    3939    public ICollection<IOperator> Operators {
    40       get { return myOperators.Values; }
     40      get { return myOperators; }
    4141    }
    4242
     
    6161    /// </summary>
    6262    public OperatorGraph() {
    63       myOperators = new Dictionary<Guid, IOperator>();
     63      myOperators = new List<IOperator>();
    6464    }
    6565
     
    8080    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    8181    /// <returns>The cloned object as <see cref="OperatorGraph"/>.</returns>
    82     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     82    public override object Clone(IDictionary<long, object> clonedObjects) {
    8383      OperatorGraph clone = new OperatorGraph();
    84       clonedObjects.Add(Guid, clone);
     84      clonedObjects.Add(clone.Id, clone);
    8585      foreach (IOperator op in Operators)
    8686        clone.AddOperator((IOperator)Auxiliary.Clone(op, clonedObjects));
     
    9393    /// <remarks>Calls <see cref="OnOperatorAdded"/>.</remarks>
    9494    public void AddOperator(IOperator op) {
    95       if (!myOperators.ContainsKey(op.Guid)) {
    96         myOperators.Add(op.Guid, op);
     95      if (!myOperators.Contains(op)) {
     96        myOperators.Add(op);
    9797        OnOperatorAdded(op);
    9898
     
    103103    /// <inheritdoc/>
    104104    /// <remarks>Calls <see cref="OnOperatorRemoved"/>.</remarks>
    105     public void RemoveOperator(Guid guid) {
    106       IOperator op = GetOperator(guid);
    107       if (op != null) {
     105    public void RemoveOperator(IOperator op) {
     106      if (Operators.Contains(op)) {
    108107        foreach (IOperator o in Operators) {
    109108          int i = 0;
     
    117116        if (InitialOperator == op)
    118117          InitialOperator = null;
    119         myOperators.Remove(op.Guid);
     118        myOperators.Remove(op);
    120119        OnOperatorRemoved(op);
    121120      }
    122121    }
    123122    /// <inheritdoc/>
    124     public IOperator GetOperator(Guid guid) {
    125       IOperator op;
    126       if (myOperators.TryGetValue(guid, out op))
    127         return op;
    128       else
    129         return null;
    130     }
    131     /// <inheritdoc/>
    132123    public void Clear() {
    133       Guid[] guids = new Guid[Operators.Count];
    134       int i = 0;
    135       foreach (IOperator op in Operators) {
    136         guids[i] = op.Guid;
    137         i++;
    138       }
    139       for (int j = 0; j < guids.Length; j++)
    140         RemoveOperator(guids[j]);
     124      while (myOperators.Count > 0)
     125        RemoveOperator(myOperators[0]);
    141126    }
    142127
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorGraphView.cs

    r1529 r2033  
    218218        if (operatorsListView.SelectedItems.Count > 0) {
    219219          foreach (ListViewItem item in operatorsListView.SelectedItems)
    220             OperatorGraph.RemoveOperator(((IOperator)item.Tag).Guid);
     220            OperatorGraph.RemoveOperator((IOperator)item.Tag);
    221221        }
    222222      }
     
    258258      if (operatorsListView.SelectedItems.Count > 0) {
    259259        foreach (ListViewItem item in operatorsListView.SelectedItems)
    260           OperatorGraph.RemoveOperator(((IOperator)item.Tag).Guid);
     260          OperatorGraph.RemoveOperator((IOperator)item.Tag);
    261261      }
    262262    }
     
    350350              IOperator newParent = (IOperator)node.Parent.Tag;
    351351              int newIndex = node.Index;
    352               ICollection<IConstraint> violatedConstraints;
    353               ICollection<IConstraint> violatedConstraints2;
    354               oldParent.TryRemoveSubOperator(oldIndex, out violatedConstraints);
    355               newParent.TryAddSubOperator(op, newIndex, out violatedConstraints2);
    356               if ((violatedConstraints.Count == 0) && (violatedConstraints2.Count == 0)) {
    357                 graphTreeView.SelectedNode = parentNode.Nodes[newIndex];
    358               } else {
    359                 List<IConstraint> allViolatedConstraints = new List<IConstraint>(violatedConstraints);
    360                 allViolatedConstraints.AddRange(violatedConstraints2);
    361                 if (Auxiliary.ShowIgnoreConstraintViolationMessageBox(allViolatedConstraints) == DialogResult.Yes) {
    362                   if (violatedConstraints.Count > 0)
    363                     oldParent.RemoveSubOperator(oldIndex);
    364                   if (violatedConstraints2.Count > 0)
    365                     newParent.AddSubOperator(op, newIndex);
    366                   graphTreeView.SelectedNode = parentNode.Nodes[newIndex];
    367                 } else {
    368                   if (violatedConstraints.Count == 0)
    369                     oldParent.AddSubOperator(op, oldIndex);
    370                   if (violatedConstraints2.Count == 0)
    371                     newParent.RemoveSubOperator(newIndex);
    372                 }
    373               }
     352              oldParent.RemoveSubOperator(oldIndex);
     353              newParent.AddSubOperator(op, newIndex);
     354              graphTreeView.SelectedNode = parentNode.Nodes[newIndex];
    374355            }
    375356          } else {
    376357            if (node != null) {
    377358              IOperator parent = (IOperator)node.Tag;
    378               ICollection<IConstraint> violatedConstraints;
    379               if (parent.TryAddSubOperator(op, out violatedConstraints)) {
    380                 graphTreeView.SelectedNode = node.Nodes[node.Nodes.Count - 1];
    381               } else if (Auxiliary.ShowIgnoreConstraintViolationMessageBox(violatedConstraints) == DialogResult.Yes) {
    382                 parent.AddSubOperator(op);
    383                 graphTreeView.SelectedNode = node.Nodes[node.Nodes.Count - 1];
    384               }
     359              parent.AddSubOperator(op);
     360              graphTreeView.SelectedNode = node.Nodes[node.Nodes.Count - 1];
    385361            }
    386362          }
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorGroup.cs

    r1823 r2033  
    3030  /// Representation of a group of operators (can also include subgroups).
    3131  /// </summary>
    32   public class OperatorGroup : StorableBase, IOperatorGroup {
     32  public class OperatorGroup : CloneableBase, IOperatorGroup {
    3333
    3434    [Storable]
     
    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) {
     86    public override object Clone(IDictionary<long, object> clonedObjects) {
    8787      OperatorGroup clone = (OperatorGroup)base.Clone(clonedObjects);
    8888      clone.myName = Name;
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorLibrary.cs

    r1823 r2033  
    7070    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    7171    /// <returns>The cloned object as <see cref="OperatorLibrary"/>.</returns>
    72     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     72    public override object Clone(IDictionary<long, object> clonedObjects) {
    7373      OperatorLibrary clone = new OperatorLibrary();
    74       clonedObjects.Add(Guid, clone);
     74      clonedObjects.Add(clone.Id, clone);
    7575      clone.myGroup = (IOperatorGroup)Auxiliary.Clone(Group, clonedObjects);
    7676      return clone;
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/PersistenceManager.cs

    r1895 r2033  
    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(object 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(object 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(object 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 object Load(string filename) {
     68      return 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 object Load(Stream stream) {
     78      return XmlParser.Deserialize(stream);
    7979    }
    8080
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Scope.cs

    r1823 r2033  
    4545   
    4646    private IDictionary<string, IVariable> myVariables;
    47     /// <inheritdoc/>   
     47    /// <inheritdoc/>
    4848    public ICollection<IVariable> Variables {
    4949      get { return myVariables.Values; }
     
    224224    }
    225225    /// <inheritdoc/>
    226     public IScope GetScope(Guid guid) {
    227       if (Guid == guid) return this;
    228       else {
    229         for (int i = 0; i < mySubScopes.Count; i++) {
    230           IScope s = mySubScopes[i].GetScope(guid);
    231           if (s != null) return s;
    232         }
    233       }
    234       return null;
    235     }
    236     /// <inheritdoc/>
    237226    public IScope GetScope(string name) {
    238227      if (Name == name) return this;
     
    267256
    268257    /// <inheritdoc/>
    269     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     258    public override object Clone(IDictionary<long, object> clonedObjects) {
    270259      Scope clone = (Scope)base.Clone(clonedObjects);
    271260      clone.myName = Name;
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Variable.cs

    r1823 r2033  
    102102    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    103103    /// <returns>The cloned object as <see cref="Variable"/>.</returns>
    104     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     104    public override object Clone(IDictionary<long, object> clonedObjects) {
    105105      Variable clone = new Variable();
    106       clonedObjects.Add(Guid, clone);
     106      clonedObjects.Add(clone.Id, clone);
    107107      clone.myName = Name;
    108108      if (Value != null)
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/VariableInfo.cs

    r1823 r2033  
    145145    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    146146    /// <returns>The cloned object as <see cref="VariableInfo"/>.</returns>
    147     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     147    public override object Clone(IDictionary<long, object> clonedObjects) {
    148148      VariableInfo clone = new VariableInfo();
    149       clonedObjects.Add(Guid, clone);
     149      clonedObjects.Add(clone.Id, clone);
    150150      clone.myActualName = ActualName;
    151151      clone.myFormalName = FormalName;
  • branches/Operator Architecture Refactoring/HeuristicLab.OptimizationFrontend/3.3/MainForm.cs

    r1530 r2033  
    3737    private class Task {
    3838      public string filename;
    39       public IStorable storable;
     39      public object instance;
    4040      public IEditor editor;
    4141
    4242      private Task() { }
    43       public Task(string filename, IStorable storable, IEditor editor) {
     43      public Task(string filename, object instance, IEditor editor) {
    4444        this.filename = filename;
    45         this.storable = storable;
     45        this.instance = instance;
    4646        this.editor = editor;
    4747      }
     
    145145      Task task = (Task)state;
    146146      try {
    147         task.storable = PersistenceManager.Load(task.filename);
     147        task.instance = PersistenceManager.Load(task.filename);
    148148      } catch(FileNotFoundException ex) {
    149149        MessageBox.Show("Sorry couldn't open file \"" + task.filename + "\".\nThe file or plugin \"" + ex.FileName + "\" is not available.\nPlease make sure you have all necessary plugins installed.",
     
    162162      else {
    163163        IEditor editor = null;
    164         if(task.storable != null) {
    165           IEditable editable = task.storable as IEditable;
     164        if(task.instance != null) {
     165          IEditable editable = task.instance as IEditable;
    166166          if(editable != null)
    167167            editor = editable.CreateEditor();
     
    200200    private void AsynchronousSave(object state) {
    201201      Task task = (Task)state;
    202       PersistenceManager.Save(task.storable, task.filename);
     202      PersistenceManager.Save(task.instance, task.filename);
    203203      SaveFinished(task);
    204204    }
  • branches/Operator Architecture Refactoring/HeuristicLab.ThreadParallelEngine/3.3/ThreadParallelEngine.cs

    r1872 r2033  
    7373    /// <inheritdoc/>
    7474    /// <returns>The cloned object as <see cref="ThreadParallelEngine"/>.</returns>
    75     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     75    public override object Clone(IDictionary<long, object> clonedObjects) {
    7676      ThreadParallelEngine clone = (ThreadParallelEngine)base.Clone(clonedObjects);
    7777      clone.myWorkers = Workers;
Note: See TracChangeset for help on using the changeset viewer.