Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs @ 2755

Last change on this file since 2755 was 2740, checked in by swagner, 15 years ago

Operator architecture refactoring (#95)

  • worked on parameters and operators
File size: 2.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Drawing;
25using System.Text;
26using System.Xml;
27using HeuristicLab.Collections;
28using HeuristicLab.Core;
29using HeuristicLab.Data;
30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
31
32namespace HeuristicLab.Operators {
33  /// <summary>
34  /// Operator which contains an operator graph.
35  /// </summary>
36  [Item("CombinedOperator", "An operator which contains an operator graph.")]
37  [Creatable("Test")]
38  public sealed class CombinedOperator : SingleSuccessorOperator, IOperator {
39    public override Image ItemImage {
40      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Module; }
41    }
42    [Storable]
43    private OperatorGraph operatorGraph;
44    public OperatorGraph OperatorGraph {
45      get { return operatorGraph; }
46    }
47    public new ParameterCollection Parameters {
48      get {
49        return base.Parameters;
50      }
51    }
52    IObservableKeyedCollection<string, IParameter> IOperator.Parameters {
53      get { return Parameters; }
54    }
55    public override bool CanChangeDescription {
56      get { return true; }
57    }
58
59    public CombinedOperator()
60      : base() {
61      operatorGraph = new OperatorGraph();
62    }
63
64    public override IDeepCloneable Clone(Cloner cloner) {
65      CombinedOperator clone = (CombinedOperator)base.Clone(cloner);
66      clone.operatorGraph = (OperatorGraph)cloner.Clone(operatorGraph);
67      return clone;
68    }
69
70    public override ExecutionContextCollection Apply() {
71      ExecutionContextCollection next = base.Apply();
72      if (operatorGraph.InitialOperator != null)
73        next.Insert(0, new ExecutionContext(ExecutionContext, operatorGraph.InitialOperator, ExecutionContext.Scope));
74      return next;
75    }
76  }
77}
Note: See TracBrowser for help on using the repository browser.