- Timestamp:
- 02/10/10 03:39:02 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators/3.3/SequentialSubScopesProcessor.cs
r1530 r2773 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using System.Text; 26 using System.Xml; 27 using HeuristicLab.Collections; 25 28 using HeuristicLab.Core; 26 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 31 28 32 namespace HeuristicLab.Operators { 29 33 /// <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. 31 35 /// </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() { 36 41 } 37 42 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 } 48 51 return next; 49 52 }
Note: See TracChangeset
for help on using the changeset viewer.