Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.StructureIdentification/DelegatingOperator.cs @ 88

Last change on this file since 88 was 88, checked in by gkronber, 17 years ago

fixed #55 by:

  • introducing a new class DelegatingOperator that overwrites Execute() of OperatorBase in exactly the same way as CombinedOperator.
  • extending OnePointShaker and FullTreeShaker from DelegatingOperator
File size: 1.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Data;
7
8namespace HeuristicLab.StructureIdentification {
9  public abstract class DelegatingOperator : OperatorBase {
10    public override IOperation Execute(IScope scope) {
11      myCanceled = false;
12
13      // copied from CombinedOperator (gkronber 22.3.08)
14      if(scope.GetVariable(Guid.ToString()) == null) { // contained operator not yet executed
15        // add marker
16        scope.AddVariable(new Variable(Guid.ToString(), new NullData()));
17
18        // add aliases
19        foreach(IVariableInfo variableInfo in VariableInfos)
20          scope.AddAlias(variableInfo.FormalName, variableInfo.ActualName);
21
22        CompositeOperation next = new CompositeOperation();
23        next.AddOperation(Apply(scope));
24        // execute combined operator again after contained operators have been executed
25        next.AddOperation(new AtomicOperation(this, scope));
26
27        OnExecuted();
28        return next;
29      } else {  // contained operator already executed
30        // remove marker
31        scope.RemoveVariable(Guid.ToString());
32
33        // remove aliases
34        foreach(IVariableInfo variableInfo in VariableInfos)
35          scope.RemoveAlias(variableInfo.FormalName);
36
37        OnExecuted();
38        return null;
39      }
40    }
41  }
42}
Note: See TracBrowser for help on using the repository browser.