Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Communication.Data/3.2/TcpNetworkDriverConfiguration.cs @ 3149

Last change on this file since 3149 was 1529, checked in by gkronber, 16 years ago

Moved source files of plugins AdvancedOptimizationFrontEnd ... Grid into version-specific sub-folders. #576

File size: 3.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.Text;
25using System.Xml;
26using System.Net.Sockets;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29
30namespace HeuristicLab.Communication.Data {
31  public class TcpNetworkDriverConfiguration : ItemBase, IDriverConfiguration {
32    private StringData targetIPAddress;
33    public StringData TargetIPAddress {
34      get { return targetIPAddress; }
35      set {
36        targetIPAddress = value;
37        OnChanged();
38      }
39    }
40
41    private IntData targetPort;
42    public IntData TargetPort {
43      get { return targetPort; }
44      set {
45        targetPort = value;
46        OnChanged();
47      }
48    }
49
50    private IntData sourcePort;
51    public IntData SourcePort {
52      get { return sourcePort; }
53      set {
54        sourcePort = value;
55        OnChanged();
56      }
57    }
58
59    public TcpNetworkDriverConfiguration() {
60      targetIPAddress = new StringData("127.0.0.1");
61      targetPort = new IntData(2552);
62      sourcePort = new IntData(5225);
63    }
64
65    public override IView CreateView() {
66      return new TcpNetworkDriverConfigurationView(this);
67    }
68
69    #region persistence & clone
70    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
71      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
72      XmlNode ipNode = PersistenceManager.Persist("TargetIP", TargetIPAddress, document, persistedObjects);
73      node.AppendChild(ipNode);
74      XmlNode tportNode = PersistenceManager.Persist("TargetPort", TargetPort, document, persistedObjects);
75      node.AppendChild(tportNode);
76      XmlNode sportNode = PersistenceManager.Persist("SourcePort", SourcePort, document, persistedObjects);
77      node.AppendChild(sportNode);
78      return node;
79    }
80
81    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
82      base.Populate(node, restoredObjects);
83      targetIPAddress = (StringData)PersistenceManager.Restore(node.SelectSingleNode("TargetIP"), restoredObjects);
84      targetPort = (IntData)PersistenceManager.Restore(node.SelectSingleNode("TargetPort"), restoredObjects);
85      sourcePort = (IntData)PersistenceManager.Restore(node.SelectSingleNode("SourcePort"), restoredObjects);
86    }
87
88    public override object Clone(IDictionary<Guid, object> clonedObjects) {
89      TcpNetworkDriverConfiguration clone = new TcpNetworkDriverConfiguration();
90      clonedObjects.Add(Guid, clone);
91      clone.targetIPAddress = (StringData)Auxiliary.Clone(TargetIPAddress, clonedObjects);
92      clone.targetPort = (IntData)Auxiliary.Clone(TargetPort, clonedObjects);
93      clone.sourcePort = (IntData)Auxiliary.Clone(SourcePort, clonedObjects);
94      return clone;
95    }
96    #endregion
97  }
98}
Note: See TracBrowser for help on using the repository browser.