Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/10 02:15:10 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on operators and SGA
  • improved performance
File:
1 edited

Legend:

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

    r2794 r2830  
    2727namespace HeuristicLab.Operators {
    2828  /// <summary>
    29   /// An operator which removes one specified or (if not specified) all sub-scopes from the current scope.
     29  /// An operator which removes all sub-scopes or one specified sub-scope from the current scope.
    3030  /// </summary>
    31   [Item("SubScopesRemover", "An operator which removes one specified or (if not specified) all sub-scopes from the current scope.")]
     31  [Item("SubScopesRemover", "An operator which removes all sub-scopes or one specified sub-scope from the current scope.")]
    3232  [EmptyStorableClass]
    3333  [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    }
    3538    public ValueLookupParameter<IntData> SubScopeIndexParameter {
    3639      get { return (ValueLookupParameter<IntData>)Parameters["SubScopeIndex"]; }
    3740    }
    38     protected ScopeParameter CurrentScopeParameter {
     41    private ScopeParameter CurrentScopeParameter {
    3942      get { return (ScopeParameter)Parameters["CurrentScope"]; }
     43    }
     44
     45    public bool RemoveAllSubScopes {
     46      get { return RemoveAllSubScopesParameter.Value.Value; }
     47      set { RemoveAllSubScopesParameter.Value.Value = value; }
    4048    }
    4149    public IScope CurrentScope {
     
    4553    public SubScopesRemover()
    4654      : 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."));
    4857      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope from which one or all sub-scopes should be removed."));
    4958    }
    5059
    5160    public override IExecutionSequence Apply() {
    52       IntData index = SubScopeIndexParameter.ActualValue;
    53       if (index != null)
    54         CurrentScope.SubScopes.RemoveAt(index.Value);
    55       else
     61      if (RemoveAllSubScopes)
    5662        CurrentScope.SubScopes.Clear();
     63      else {
     64        CurrentScope.SubScopes.RemoveAt(SubScopeIndexParameter.ActualValue.Value);
     65      }
    5766      return base.Apply();
    5867    }
Note: See TracChangeset for help on using the changeset viewer.