Changeset 2740 for trunk/sources/HeuristicLab.Operators/3.3
- Timestamp:
- 02/03/10 04:43:06 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Operators/3.3
- Files:
-
- 1 added
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs
r2727 r2740 36 36 [Item("CombinedOperator", "An operator which contains an operator graph.")] 37 37 [Creatable("Test")] 38 public sealed class CombinedOperator : S tandardOperator, IOperator {38 public sealed class CombinedOperator : SingleSuccessorOperator, IOperator { 39 39 public override Image ItemImage { 40 40 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Module; } … … 68 68 } 69 69 70 public override ExecutionContextCollection Apply( ExecutionContext context) {71 ExecutionContextCollection next = base.Apply( context);70 public override ExecutionContextCollection Apply() { 71 ExecutionContextCollection next = base.Apply(); 72 72 if (operatorGraph.InitialOperator != null) 73 next.Insert(0, new ExecutionContext( context, operatorGraph.InitialOperator, context.Scope));73 next.Insert(0, new ExecutionContext(ExecutionContext, operatorGraph.InitialOperator, ExecutionContext.Scope)); 74 74 return next; 75 75 } -
trunk/sources/HeuristicLab.Operators/3.3/Counter.cs
r2715 r2740 35 35 [EmptyStorableClass] 36 36 [Creatable("Test")] 37 public sealed class Counter : S tandardOperator {37 public sealed class Counter : SingleSuccessorOperator { 38 38 public ItemParameter<IntData> Value { 39 39 get { return (ItemParameter<IntData>)Parameters["Value"]; } … … 49 49 } 50 50 51 public override ExecutionContextCollection Apply( ExecutionContext context) {52 IntData value = (IntData)Value. GetValue(context);53 IntData increment = (IntData)Increment. GetValue(context);51 public override ExecutionContextCollection Apply() { 52 IntData value = (IntData)Value.Value; 53 IntData increment = (IntData)Increment.Value; 54 54 value.Value += increment.Value; 55 return base.Apply( context);55 return base.Apply(); 56 56 } 57 57 } -
trunk/sources/HeuristicLab.Operators/3.3/EmptyOperator.cs
r2684 r2740 34 34 [Creatable("Test")] 35 35 [EmptyStorableClass] 36 public sealed class EmptyOperator : S tandardOperator {36 public sealed class EmptyOperator : SingleSuccessorOperator { 37 37 public EmptyOperator() 38 38 : base() { -
trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r2714 r2740 86 86 <ItemGroup> 87 87 <Compile Include="CombinedOperator.cs" /> 88 <Compile Include="MultipleSuccessorsOperator.cs" /> 88 89 <Compile Include="Counter.cs" /> 89 90 <Compile Include="EmptyOperator.cs"> … … 94 95 <Compile Include="Properties\AssemblyInfo.cs" /> 95 96 <Compile Include="SequentialProcessor.cs" /> 96 <Compile Include="S tandardOperator.cs" />97 <Compile Include="SingleSuccessorOperator.cs" /> 97 98 </ItemGroup> 98 99 <ItemGroup> -
trunk/sources/HeuristicLab.Operators/3.3/Operator.cs
r2684 r2740 84 84 } 85 85 86 [Storable] 87 private ExecutionContext executionContext; 88 protected ExecutionContext ExecutionContext { 89 get { return executionContext; } 90 } 91 86 92 /// <summary> 87 93 /// Initializes a new instance of <see cref="OperatorBase"/> setting the breakpoint flag and … … 107 113 clone.canceled = canceled; 108 114 clone.breakpoint = breakpoint; 115 clone.executionContext = (ExecutionContext)cloner.Clone(executionContext); 109 116 return clone; 110 117 } … … 112 119 /// <inheritdoc/> 113 120 public virtual ExecutionContextCollection Execute(ExecutionContext context) { 114 canceled = false; 115 ExecutionContextCollection next = Apply(context); 116 OnExecuted(); 117 return next; 121 try { 122 canceled = false; 123 executionContext = context; 124 foreach (IParameter param in Parameters) 125 param.ExecutionContext = context; 126 ExecutionContextCollection next = Apply(); 127 OnExecuted(); 128 return next; 129 } 130 finally { 131 foreach (IParameter param in Parameters) 132 param.ExecutionContext = null; 133 context = null; 134 } 118 135 } 119 136 /// <inheritdoc/> … … 127 144 /// <param name="scope">The scope where to execute the operator</param> 128 145 /// <returns><c>null</c>.</returns> 129 public virtual ExecutionContextCollection Apply( ExecutionContext context) {146 public virtual ExecutionContextCollection Apply() { 130 147 return new ExecutionContextCollection(); 131 148 } -
trunk/sources/HeuristicLab.Operators/3.3/SequentialProcessor.cs
r2684 r2740 36 36 [Creatable("Test")] 37 37 [EmptyStorableClass] 38 public sealed class SequentialProcessor : Operator, IOperator { 39 public new ParameterCollection Parameters { 40 get { 41 return base.Parameters; 42 } 43 } 44 IObservableKeyedCollection<string, IParameter> IOperator.Parameters { 45 get { return Parameters; } 46 } 47 38 public sealed class SequentialProcessor : MultipleSuccessorsOperator { 48 39 public SequentialProcessor() 49 40 : base() { 50 41 } 51 42 52 public override ExecutionContextCollection Apply( ExecutionContext context) {43 public override ExecutionContextCollection Apply() { 53 44 ExecutionContextCollection next = new ExecutionContextCollection(); 54 foreach (IParameter param in Parameters) { 55 IOperatorParameter opParam = param as IOperatorParameter; 56 if (opParam != null) { 57 IOperator op = (IOperator)opParam.GetValue(context); 58 if (op != null) next.Add(new ExecutionContext(context.Parent, op, context.Scope)); 59 } 60 } 45 for (int i = 0; i < Successors.Count; i++) 46 next.Add(new ExecutionContext(ExecutionContext.Parent, Successors[i], ExecutionContext.Scope)); 61 47 return next; 62 48 } -
trunk/sources/HeuristicLab.Operators/3.3/SingleSuccessorOperator.cs
r2739 r2740 32 32 /// A base class for operators which have only one successor. 33 33 /// </summary> 34 [Item("S tandardOperator", "A base class for operators which have only one successor.")]34 [Item("SingleSuccessorOperator", "A base class for operators which have only one successor.")] 35 35 [Creatable("Test")] 36 36 [EmptyStorableClass] 37 public abstract class S tandardOperator : Operator {38 p ublic OperatorParameter Successor {37 public abstract class SingleSuccessorOperator : Operator { 38 protected OperatorParameter SuccessorParameter { 39 39 get { return (OperatorParameter)Parameters["Successor"]; } 40 40 } 41 42 public StandardOperator() 43 : base() { 44 Parameters.Add(new OperatorParameter("Successor", "Operator which is executed next")); 41 public IOperator Successor { 42 get { return SuccessorParameter.Value; } 43 set { SuccessorParameter.Value = value; } 45 44 } 46 45 47 public override ExecutionContextCollection Apply(ExecutionContext context) { 48 IOperator successor = (IOperator)Successor.GetValue(context); 49 if (successor != null) 50 return new ExecutionContextCollection(new ExecutionContext(context.Parent, successor, context.Scope)); 46 public SingleSuccessorOperator() 47 : base() { 48 Parameters.Add(new OperatorParameter("Successor", "Operator which is executed next.")); 49 } 50 51 public override ExecutionContextCollection Apply() { 52 if (Successor != null) 53 return new ExecutionContextCollection(new ExecutionContext(ExecutionContext.Parent, Successor, ExecutionContext.Scope)); 51 54 else 52 55 return new ExecutionContextCollection();
Note: See TracChangeset
for help on using the changeset viewer.