Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Core/OperatorLink.cs @ 468

Last change on this file since 468 was 421, checked in by gkronber, 16 years ago

added missing GPL license headers for new files (#211)

File size: 2.7 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.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Xml;
28
29namespace HeuristicLab.CEDMA.Core {
30  public class OperatorLink : OperatorBase {
31    private long id;
32    public long Id {
33      get { return id; }
34    }
35
36    private IOperator myOperator;
37    public IOperator Operator {
38      get { return myOperator; }
39      set { myOperator = value; }
40    }
41
42    public OperatorLink() : base() { } // for cloning and persistence
43
44    public OperatorLink(long id, IOperator op)
45      : base() {
46      this.id = id;
47      this.myOperator = op;
48      Name = myOperator.Name;
49    }
50
51    public override void Abort() {
52      throw new NotSupportedException();
53    }
54
55    public override IOperation Apply(IScope scope) {
56      throw new NotSupportedException();
57    }
58
59    public override object Clone(IDictionary<Guid, object> clonedObjects) {
60      OperatorLink clone = (OperatorLink)base.Clone(clonedObjects);
61      clone.id = id;
62      clone.myOperator = Operator;
63      return clone;
64    }
65
66    public override IView CreateView() {
67      return myOperator.CreateView();
68    }
69
70    public override IOperation Execute(IScope scope) {
71      throw new NotSupportedException();
72    }
73
74    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
75      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
76      XmlAttribute idAttr = document.CreateAttribute("OperatorId");
77      idAttr.Value = id.ToString();
78      node.Attributes.Append(idAttr);
79      return node;
80    }
81
82    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
83      id = long.Parse(node.Attributes["OperatorId"].Value);
84      base.Populate(node, restoredObjects);
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.