Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/08/10 03:43:36 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on parameters and operators
File:
1 edited

Legend:

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

    r1530 r2757  
    2424using System.Text;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Data;
     26using HeuristicLab.Parameters;
     27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
    2829namespace HeuristicLab.Operators {
    2930  /// <summary>
    30   /// Operator that removes all variables in the given scope and deletes also all subscopes.
     31  /// An operator which removes all variables and sub-scopes from the current scope.
    3132  /// </summary>
    32   public class ScopeCleaner : OperatorBase {
    33     /// <inheritdoc select="summary"/>
    34     public override string Description {
    35       get { return @"Removes all variables in the current scope and deletes all subscopes"; }
     33  [Item("ScopeCleaner", "An operator which removes all variables and sub-scopes from the current scope.")]
     34  [EmptyStorableClass]
     35  [Creatable("Test")]
     36  public sealed class ScopeCleaner : SingleSuccessorOperator {
     37    private ScopeParameter CurrentScopeParameter {
     38      get { return (ScopeParameter)Parameters["CurrentScope"]; }
     39    }
     40    public IScope CurrentScope {
     41      get { return CurrentScopeParameter.ActualValue; }
    3642    }
    3743
    38     /// <summary>
    39     /// Deletes all variable and sub scopes from the given <paramref name="scope"/>.
    40     /// </summary>
    41     /// <remarks>Calls <see cref="IScope.Clear"/> of interface <see cref="IScope"/>.</remarks>
    42     /// <param name="scope">The scope to clear.</param>
    43     /// <returns><c>null</c>.</returns>
    44     public override IOperation Apply(IScope scope) {
    45       scope.Clear();
    46       return null;
     44    public ScopeCleaner()
     45      : base() {
     46      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose variables and sub-scopes should be removed."));
     47    }
     48
     49    public override IExecutionContext Apply() {
     50      CurrentScope.Variables.Clear();
     51      CurrentScope.SubScopes.Clear();
     52      return base.Apply();
    4753    }
    4854  }
Note: See TracChangeset for help on using the changeset viewer.