Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/10/10 03:39:02 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on parameters and operators
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators/3.3/SequentialSubScopesProcessor.cs

    r1530 r2773  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Text;
     26using System.Xml;
     27using HeuristicLab.Collections;
    2528using HeuristicLab.Core;
    26 using HeuristicLab.Data;
     29using HeuristicLab.Parameters;
     30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2731
    2832namespace HeuristicLab.Operators {
    2933  /// <summary>
    30   /// Performs <c>n</c> operators on <c>n</c> subscopes, operations must be executed sequentially.
     34  /// An operator which contains multiple operators of which each is applied sequentially on one sub-scope of the current scope. The first operator is applied on the first sub-scope, the second on the second, and so on.
    3135  /// </summary>
    32   public class SequentialSubScopesProcessor : OperatorBase {
    33     /// <inheritdoc select="summary"/>
    34     public override string Description {
    35       get { return @"TODO\r\nOperator description still missing ..."; }
     36  [Item("SequentialSubScopesProcessor", "An operator which contains multiple operators of which each is applied sequentially on one sub-scope of the current scope. The first operator is applied on the first sub-scope, the second on the second, and so on.")]
     37  [Creatable("Test")]
     38  public sealed class SequentialSubScopesProcessor : MultipleCallsOperator {
     39    public SequentialSubScopesProcessor()
     40      : base() {
    3641    }
    3742
    38     /// <summary>
    39     /// Applies <c>n</c> operators on all the <c>n</c> sub scopes of the given <paramref name="scope"/>.
    40     /// </summary>
    41     /// <param name="scope">The scope on whose sub scopes the operators are applied.</param>
    42     /// <returns>A new <see cref="CompositeOperation"/> with the <c>i</c>th operator applied
    43     /// on the <c>i</c>th sub scope.</returns>
    44     public override IOperation Apply(IScope scope) {
    45       CompositeOperation next = new CompositeOperation();
    46       for (int i = 0; i < scope.SubScopes.Count; i++)
    47         next.AddOperation(new AtomicOperation(SubOperators[i], scope.SubScopes[i]));
     43    public override IExecutionSequence Apply() {
     44      ExecutionContextCollection next = new ExecutionContextCollection(base.Apply());
     45      if (Operators.Count > 0) {
     46        ExecutionContextCollection inner = new ExecutionContextCollection();
     47        for (int i = 0; (i < ExecutionContext.Scope.SubScopes.Count) && (i < Operators.Count); i++)
     48          inner.Add(new ExecutionContext(ExecutionContext.Parent, Operators[i], ExecutionContext.Scope.SubScopes[i]));
     49        next.Insert(0, inner);
     50      }
    4851      return next;
    4952    }
Note: See TracChangeset for help on using the changeset viewer.