Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/08/10 03:43:36 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on parameters and operators
Location:
trunk/sources/HeuristicLab.Core/3.3
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/Engine.cs

    r2687 r2757  
    9393    /// </summary>
    9494    [Storable]
    95     private Stack<ExecutionContext> executionStack;
     95    private Stack<IExecutionContext> executionStack;
    9696    /// <summary>
    9797    /// Gets the current execution stack.
    9898    /// </summary>
    99     protected Stack<ExecutionContext> ExecutionStack {
     99    protected Stack<IExecutionContext> ExecutionStack {
    100100      get { return executionStack; }
    101101    }
     
    135135    protected Engine() {
    136136      globalScope = new Scope("Global");
    137       executionStack = new Stack<ExecutionContext>();
     137      executionStack = new Stack<IExecutionContext>();
    138138      OperatorGraph = new OperatorGraph();
    139139    }
     
    151151      clone.globalScope = (Scope)cloner.Clone(globalScope);
    152152      clone.executionTime = executionTime;
    153       ExecutionContext[] contexts = executionStack.ToArray();
     153      IExecutionContext[] contexts = executionStack.ToArray();
    154154      for (int i = contexts.Length - 1; i >= 0; i--)
    155         clone.executionStack.Push((ExecutionContext)cloner.Clone(contexts[i]));
     155        clone.executionStack.Push((IExecutionContext)cloner.Clone(contexts[i]));
    156156      clone.running = running;
    157157      clone.canceled = canceled;
  • trunk/sources/HeuristicLab.Core/3.3/ExecutionContext.cs

    r2687 r2757  
    2626
    2727namespace HeuristicLab.Core {
    28   public class ExecutionContext : DeepCloneable {
     28  public class ExecutionContext : DeepCloneable, IExecutionContext {
    2929    [Storable]
    3030    private ExecutionContext parent;
  • trunk/sources/HeuristicLab.Core/3.3/ExecutionContextCollection.cs

    r2664 r2757  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Text;
    2526using System.Xml;
     
    2728
    2829namespace HeuristicLab.Core {
    29   public class ExecutionContextCollection : DeepCloneable, IList<ExecutionContext> {
     30  public class ExecutionContextCollection : DeepCloneable, IList<IExecutionContext>, IExecutionContext {
    3031    [Storable]
    31     private IList<ExecutionContext> contexts;
     32    private IList<IExecutionContext> contexts;
    3233
    3334    [Storable]
     
    3940
    4041    public ExecutionContextCollection() {
    41       contexts = new List<ExecutionContext>();
     42      contexts = new List<IExecutionContext>();
    4243      parallel = false;
    4344    }
    44     public ExecutionContextCollection(IEnumerable<ExecutionContext> collection) {
    45       contexts = new List<ExecutionContext>(collection);
     45    public ExecutionContextCollection(IEnumerable<IExecutionContext> collection) {
     46      contexts = new List<IExecutionContext>(collection.Where(e => e != null));
    4647      parallel = false;
    4748    }
    48     public ExecutionContextCollection(params ExecutionContext[] list) {
    49       contexts = new List<ExecutionContext>(list);
     49    public ExecutionContextCollection(params IExecutionContext[] list) {
     50      contexts = new List<IExecutionContext>(list.Where(e => e != null));
    5051      parallel = false;
    5152    }
     
    5657      clone.parallel = parallel;
    5758      for (int i = 0; i < contexts.Count; i++)
    58         clone.contexts.Add((ExecutionContext)cloner.Clone(contexts[i]));
     59        clone.contexts.Add((IExecutionContext)cloner.Clone(contexts[i]));
    5960      return clone;
    6061    }
    6162
    62     #region IList<ExecutionContext> Members
    63     public int IndexOf(ExecutionContext item) {
     63    #region IList<IExecutionContext> Members
     64    public int IndexOf(IExecutionContext item) {
    6465      return contexts.IndexOf(item);
    6566    }
    66     public void Insert(int index, ExecutionContext item) {
    67       contexts.Insert(index, item);
     67    public void Insert(int index, IExecutionContext item) {
     68      if (item != null) contexts.Insert(index, item);
    6869    }
    6970    public void RemoveAt(int index) {
    7071      contexts.RemoveAt(index);
    7172    }
    72     public ExecutionContext this[int index] {
     73    public IExecutionContext this[int index] {
    7374      get { return contexts[index]; }
    74       set { contexts[index] = value; }
     75      set { if (value != null) contexts[index] = value; }
    7576    }
    7677    #endregion
    7778
    78     #region ICollection<ExecutionContext> Members
    79     public void Add(ExecutionContext item) {
    80       contexts.Add(item);
     79    #region ICollection<IExecutionContext> Members
     80    public void Add(IExecutionContext item) {
     81      if (item != null) contexts.Add(item);
    8182    }
    8283    public void Clear() {
    8384      contexts.Clear();
    8485    }
    85     public bool Contains(ExecutionContext item) {
     86    public bool Contains(IExecutionContext item) {
    8687      return contexts.Contains(item);
    8788    }
    88     public void CopyTo(ExecutionContext[] array, int arrayIndex) {
     89    public void CopyTo(IExecutionContext[] array, int arrayIndex) {
    8990      contexts.CopyTo(array, arrayIndex);
    9091    }
     
    9596      get { return contexts.IsReadOnly; }
    9697    }
    97     public bool Remove(ExecutionContext item) {
     98    public bool Remove(IExecutionContext item) {
    9899      return contexts.Remove(item);
    99100    }
    100101    #endregion
    101102
    102     #region IEnumerable<ExecutionContext> Members
    103     public IEnumerator<ExecutionContext> GetEnumerator() {
     103    #region IEnumerable<IExecutionContext> Members
     104    public IEnumerator<IExecutionContext> GetEnumerator() {
    104105      return contexts.GetEnumerator();
    105106    }
  • trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj

    r2756 r2757  
    104104    <Compile Include="ChangedEventArgs.cs" />
    105105    <None Include="HeuristicLabCorePlugin.cs.frame" />
     106    <Compile Include="Interfaces\IExecutionContext.cs" />
    106107    <Compile Include="Interfaces\IValueLookupParameter.cs" />
    107108    <Compile Include="Interfaces\IValueParameter.cs" />
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IOperator.cs

    r2653 r2757  
    4444    /// <param name="scope">The scope where to execute the current instance.</param>
    4545    /// <returns>The next operation.</returns>
    46     ExecutionContextCollection Execute(ExecutionContext context);
     46    IExecutionContext Execute(ExecutionContext context);
    4747    /// <summary>
    4848    /// Aborts the current operator.
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IParameter.cs

    r2740 r2757  
    2929  public interface IParameter : INamedItem {
    3030    Type DataType { get; }
     31    IItem ActualValue { get; set; }
    3132    ExecutionContext ExecutionContext { get; set; }
    3233  }
  • trunk/sources/HeuristicLab.Core/3.3/ItemArray.cs

    r2746 r2757  
    2929using HeuristicLab.Common.Resources;
    3030using HeuristicLab.Collections;
    31 
    3231
    3332namespace HeuristicLab.Core {
Note: See TracChangeset for help on using the changeset viewer.