- Timestamp:
- 02/19/10 02:15:10 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators/3.3/SubScopesRemover.cs
r2794 r2830 27 27 namespace HeuristicLab.Operators { 28 28 /// <summary> 29 /// An operator which removes one specified or (if not specified) all sub-scopesfrom the current scope.29 /// An operator which removes all sub-scopes or one specified sub-scope from the current scope. 30 30 /// </summary> 31 [Item("SubScopesRemover", "An operator which removes one specified or (if not specified) all sub-scopesfrom the current scope.")]31 [Item("SubScopesRemover", "An operator which removes all sub-scopes or one specified sub-scope from the current scope.")] 32 32 [EmptyStorableClass] 33 33 [Creatable("Test")] 34 public class SubScopesRemover : SingleSuccessorOperator { 34 public sealed class SubScopesRemover : SingleSuccessorOperator { 35 private ValueParameter<BoolData> RemoveAllSubScopesParameter { 36 get { return (ValueParameter<BoolData>)Parameters["RemoveAllSubScopes"]; } 37 } 35 38 public ValueLookupParameter<IntData> SubScopeIndexParameter { 36 39 get { return (ValueLookupParameter<IntData>)Parameters["SubScopeIndex"]; } 37 40 } 38 pr otectedScopeParameter CurrentScopeParameter {41 private ScopeParameter CurrentScopeParameter { 39 42 get { return (ScopeParameter)Parameters["CurrentScope"]; } 43 } 44 45 public bool RemoveAllSubScopes { 46 get { return RemoveAllSubScopesParameter.Value.Value; } 47 set { RemoveAllSubScopesParameter.Value.Value = value; } 40 48 } 41 49 public IScope CurrentScope { … … 45 53 public SubScopesRemover() 46 54 : base() { 47 Parameters.Add(new ValueLookupParameter<IntData>("SubScopeIndex", "The index of the sub-scope which should be removed. If this parameter has no value, all sub-scopes of the current scope are removed.")); 55 Parameters.Add(new ValueParameter<BoolData>("RemoveAllSubScopes", "True if all sub-scopes of the current scope should be removed, otherwise false.", new BoolData(true))); 56 Parameters.Add(new ValueLookupParameter<IntData>("SubScopeIndex", "The index of the sub-scope which should be removed. This parameter is ignored, if RemoveAllSubScopes is true.")); 48 57 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope from which one or all sub-scopes should be removed.")); 49 58 } 50 59 51 60 public override IExecutionSequence Apply() { 52 IntData index = SubScopeIndexParameter.ActualValue; 53 if (index != null) 54 CurrentScope.SubScopes.RemoveAt(index.Value); 55 else 61 if (RemoveAllSubScopes) 56 62 CurrentScope.SubScopes.Clear(); 63 else { 64 CurrentScope.SubScopes.RemoveAt(SubScopeIndexParameter.ActualValue.Value); 65 } 57 66 return base.Apply(); 58 67 }
Note: See TracChangeset
for help on using the changeset viewer.