Changeset 10231 for trunk/sources
- Timestamp:
- 12/17/13 10:34:51 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators/3.3/InstrumentedOperator.cs
r10149 r10231 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 32 33 private const string AfterExecutionOperatorsParameterName = "AfterExecutionOperators"; 33 34 34 private IFixedValueParameter< ItemList<SingleSuccessorOperator>> BeforeExecutionOperatorsParameter {35 get { return (IFixedValueParameter< ItemList<SingleSuccessorOperator>>)Parameters[BeforeExecutionOperatorsParameterName]; }35 private IFixedValueParameter<OperatorList> BeforeExecutionOperatorsParameter { 36 get { return (IFixedValueParameter<OperatorList>)Parameters[BeforeExecutionOperatorsParameterName]; } 36 37 } 37 private IFixedValueParameter< ItemList<SingleSuccessorOperator>> AfterExecutionOperatorsParameter {38 get { return (IFixedValueParameter< ItemList<SingleSuccessorOperator>>)Parameters[AfterExecutionOperatorsParameterName]; }38 private IFixedValueParameter<OperatorList> AfterExecutionOperatorsParameter { 39 get { return (IFixedValueParameter<OperatorList>)Parameters[AfterExecutionOperatorsParameterName]; } 39 40 } 40 41 41 public ItemList<SingleSuccessorOperator>BeforeExecutionOperators {42 public OperatorList BeforeExecutionOperators { 42 43 get { return BeforeExecutionOperatorsParameter.Value; } 43 44 } 44 public ItemList<SingleSuccessorOperator>AfterExecutionOperators {45 public OperatorList AfterExecutionOperators { 45 46 get { return AfterExecutionOperatorsParameter.Value; } 46 47 } … … 53 54 protected InstrumentedOperator() 54 55 : base() { 55 Parameters.Add(new FixedValueParameter< ItemList<SingleSuccessorOperator>>(BeforeExecutionOperatorsParameterName, "Actions that are executed before the execution of the operator", new ItemList<SingleSuccessorOperator>()));56 Parameters.Add(new FixedValueParameter< ItemList<SingleSuccessorOperator>>(AfterExecutionOperatorsParameterName, "Actions that are executed after the execution of the operator", new ItemList<SingleSuccessorOperator>()));56 Parameters.Add(new FixedValueParameter<OperatorList>(BeforeExecutionOperatorsParameterName, "Actions that are executed before the execution of the operator", new OperatorList())); 57 Parameters.Add(new FixedValueParameter<OperatorList>(AfterExecutionOperatorsParameterName, "Actions that are executed after the execution of the operator", new OperatorList())); 57 58 BeforeExecutionOperatorsParameter.Hidden = true; 58 59 AfterExecutionOperatorsParameter.Hidden = true; … … 64 65 #region Backwards compatible code, remove with 3.4 65 66 if (!Parameters.ContainsKey(BeforeExecutionOperatorsParameterName)) { 66 Parameters.Add(new FixedValueParameter< ItemList<SingleSuccessorOperator>>(BeforeExecutionOperatorsParameterName, "Actions that are executed before the execution of the operator", new ItemList<SingleSuccessorOperator>()));67 Parameters.Add(new FixedValueParameter<OperatorList>(BeforeExecutionOperatorsParameterName, "Actions that are executed before the execution of the operator", new OperatorList())); 67 68 BeforeExecutionOperatorsParameter.Hidden = true; 68 69 } 69 70 if (!Parameters.ContainsKey(AfterExecutionOperatorsParameterName)) { 70 Parameters.Add(new FixedValueParameter< ItemList<SingleSuccessorOperator>>(AfterExecutionOperatorsParameterName, "Actions that are executed after the execution of the operator", new ItemList<SingleSuccessorOperator>()));71 Parameters.Add(new FixedValueParameter<OperatorList>(AfterExecutionOperatorsParameterName, "Actions that are executed after the execution of the operator", new OperatorList())); 71 72 AfterExecutionOperatorsParameter.Hidden = true; 72 73 } … … 75 76 76 77 public sealed override IOperation Apply() { 77 var opCol = new OperationCollection(); 78 //to speed up the execution call instrumented apply directly if no before operators exists 79 if (!BeforeExecutionOperators.Any()) 80 return InstrumentedApply(); 78 81 79 82 //build before operations 83 var opCol = new OperationCollection(); 80 84 foreach (var beforeAction in BeforeExecutionOperators) { 81 IOperationbeforeActionOperation = ExecutionContext.CreateOperation(beforeAction);85 var beforeActionOperation = ExecutionContext.CreateOperation(beforeAction); 82 86 opCol.Add(beforeActionOperation); 83 87 } … … 88 92 89 93 public virtual IOperation InstrumentedApply() { 94 if (!AfterExecutionOperators.Any()) { 95 if (Successor != null) return ExecutionContext.CreateOperation(Successor); 96 return null; 97 } 98 90 99 var opCol = new OperationCollection(); 91 100 foreach (var afterAction in AfterExecutionOperators) { 92 IOperationafterActionOperation = ExecutionContext.CreateOperation(afterAction);101 var afterActionOperation = ExecutionContext.CreateOperation(afterAction); 93 102 opCol.Add(afterActionOperation); 94 103 } 104 95 105 if (Successor != null) 96 106 opCol.Add(ExecutionContext.CreateOperation(Successor));
Note: See TracChangeset
for help on using the changeset viewer.