Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis SolutionEnsembles/HeuristicLab.Operators.Programmable/3.3/ProgrammableSingleSuccessorOperator.cs @ 6004

Last change on this file since 6004 was 4838, checked in by epitzer, 14 years ago

Better reflect single successor operation generation inside user visible code. (#1275)

File size: 1.6 KB
Line 
1
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Parameters;
5using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6namespace HeuristicLab.Operators.Programmable {
7
8  [Item("ProgrammableSingleSuccessorOperator", "An operator that can be programmed for arbitrary needs and handle a single successor.")]
9  [StorableClass]
10  public class ProgrammableSingleSuccessorOperator : ProgrammableOperator {
11
12    public IOperator Successor {
13      get {
14        IParameter parameter;
15        Parameters.TryGetValue("Successor", out parameter);
16        OperatorParameter successorParameter = parameter as OperatorParameter;
17        if (successorParameter == null)
18          return null;
19        return successorParameter.Value;
20      }
21      set {
22        ((OperatorParameter)Parameters["Successor"]).Value = value;
23      }
24    }
25
26    [StorableConstructor]
27    protected ProgrammableSingleSuccessorOperator(bool deserializing) : base(deserializing) { }
28    protected ProgrammableSingleSuccessorOperator(ProgrammableSingleSuccessorOperator original, Cloner cloner)
29      : base(original, cloner) {
30    }
31    public ProgrammableSingleSuccessorOperator()
32      : base() {
33      Parameters.Add(new OperatorParameter("Successor", "Operator that is executed next."));
34    }
35
36    public override IDeepCloneable Clone(Cloner cloner) {
37      return new ProgrammableSingleSuccessorOperator(this, cloner);
38    }
39
40    public override string MethodSuffix {
41      get { return "return op.Successor == null ? null : context.CreateOperation(op.Successor);"; }
42    }
43  }
44}
Note: See TracBrowser for help on using the repository browser.