Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/10 06:19:16 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on operators, engines, and optimization
File:
1 edited

Legend:

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

    r2796 r2834  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
     23using HeuristicLab.Collections;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2625
    2726namespace HeuristicLab.Core {
    28   public class ExecutionContext : DeepCloneable, IExecutionSequence {
     27  public class ExecutionContext : DeepCloneable, IExecutionContext, IAtomicOperation {
    2928    [Storable]
    30     private ExecutionContext parent;
    31     public ExecutionContext Parent {
     29    private IParameterizedItem parameterizedItem;
     30
     31    [Storable]
     32    private IExecutionContext parent;
     33    public IExecutionContext Parent {
    3234      get { return parent; }
    3335    }
    3436
    35     [Storable]
    36     private IOperator op;
     37    public IObservableKeyedCollection<string, IParameter> Parameters {
     38      get { return parameterizedItem.Parameters; }
     39    }
     40
    3741    public IOperator Operator {
    38       get { return op; }
     42      get { return parameterizedItem as IOperator; }
    3943    }
    4044
     
    4549    }
    4650
    47     [Storable]
    48     private IProblem problem;
    49     public IProblem Problem {
    50       get { return problem; }
    51     }
    52 
    5351    private ExecutionContext() {
    5452      parent = null;
    55       op = null;
     53      parameterizedItem = null;
    5654      scope = null;
    57       problem = null;
    5855    }
    59     public ExecutionContext(ExecutionContext parent, IOperator op, IScope scope, IProblem problem) {
    60       if ((op == null) || (scope == null) || (problem == null)) throw new ArgumentNullException();
     56    public ExecutionContext(IExecutionContext parent, IParameterizedItem parameterizedItem, IScope scope) {
     57      if ((parameterizedItem == null) || (scope == null)) throw new ArgumentNullException();
    6158      this.parent = parent;
    62       this.op = op;
     59      this.parameterizedItem = parameterizedItem;
    6360      this.scope = scope;
    64       this.problem = problem;
    6561    }
    6662
     
    6864      ExecutionContext clone = new ExecutionContext();
    6965      cloner.RegisterClonedObject(this, clone);
    70       clone.parent = (ExecutionContext)cloner.Clone(parent);
    71       clone.op = (IOperator)cloner.Clone(op);
     66      clone.parent = (IExecutionContext)cloner.Clone(parent);
     67      clone.parameterizedItem = (IParameterizedItem)cloner.Clone(parameterizedItem);
    7268      clone.scope = (IScope)cloner.Clone(scope);
    73       clone.problem = (IProblem)cloner.Clone(problem);
    7469      return clone;
    7570    }
    7671
    77     public ExecutionContext CreateContext(IOperator op) {
    78       return new ExecutionContext(parent, op, scope, problem);
     72    public IAtomicOperation CreateOperation(IOperator op) {
     73      return new ExecutionContext(parent, op, scope);
    7974    }
    80     public ExecutionContext CreateContext(IOperator op, IScope scope) {
    81       return new ExecutionContext(parent, op, scope, problem);
     75    public IAtomicOperation CreateOperation(IOperator op, IScope scope) {
     76      return new ExecutionContext(parent, op, scope);
    8277    }
    83     public ExecutionContext CreateChildContext(IOperator op) {
    84       return new ExecutionContext(this, op, scope, problem);
     78    public IAtomicOperation CreateChildOperation(IOperator op) {
     79      return new ExecutionContext(this, op, scope);
    8580    }
    86     public ExecutionContext CreateChildContext(IOperator op, IScope scope) {
    87       return new ExecutionContext(this, op, scope, problem);
     81    public IAtomicOperation CreateChildOperation(IOperator op, IScope scope) {
     82      return new ExecutionContext(this, op, scope);
    8883    }
    8984  }
Note: See TracChangeset for help on using the changeset viewer.