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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Drawing;
|
---|
25 | using System.Text;
|
---|
26 | using System.Xml;
|
---|
27 | using HeuristicLab.Collections;
|
---|
28 | using HeuristicLab.Core;
|
---|
29 | using HeuristicLab.Data;
|
---|
30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
31 |
|
---|
32 | namespace 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 | }
|
---|