Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj (revision 11421)
@@ -49,4 +49,10 @@
+
+ UserControl
+
+
+ PortView.cs
+
UserControl
@@ -67,9 +73,9 @@
InputPortView.cs
-
+
UserControl
-
- PortView.cs
+
+ ValuePortView.cs
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.cs (revision 11421)
@@ -29,5 +29,5 @@
[Content(typeof(IInputPort<>), false)]
[Content(typeof(IInputPort), false)]
- public partial class InputPortView : PortView {
+ public partial class InputPortView : ValuePortView {
public new IInputPort Content {
get { return (IInputPort)base.Content; }
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.Designer.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.Designer.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.Designer.cs (revision 11421)
@@ -45,10 +45,5 @@
///
private void InitializeComponent() {
- this.valueGroupBox = new System.Windows.Forms.GroupBox();
- this.valuePanel = new System.Windows.Forms.Panel();
- this.valueViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
- this.valueGroupBox.SuspendLayout();
- this.valuePanel.SuspendLayout();
this.SuspendLayout();
//
@@ -64,46 +59,7 @@
this.infoLabel.Location = new System.Drawing.Point(626, 3);
//
- // valueGroupBox
- //
- this.valueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.valueGroupBox.Controls.Add(this.valuePanel);
- this.valueGroupBox.Location = new System.Drawing.Point(0, 26);
- this.valueGroupBox.Name = "valueGroupBox";
- this.valueGroupBox.Size = new System.Drawing.Size(645, 491);
- this.valueGroupBox.TabIndex = 3;
- this.valueGroupBox.TabStop = false;
- this.valueGroupBox.Text = "Value";
- //
- // valuePanel
- //
- this.valuePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.valuePanel.Controls.Add(this.valueViewHost);
- this.valuePanel.Location = new System.Drawing.Point(6, 19);
- this.valuePanel.Name = "valuePanel";
- this.valuePanel.Size = new System.Drawing.Size(633, 466);
- this.valuePanel.TabIndex = 0;
- //
- // valueViewHost
- //
- this.valueViewHost.Caption = "View";
- this.valueViewHost.Content = null;
- this.valueViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
- this.valueViewHost.Enabled = false;
- this.valueViewHost.Location = new System.Drawing.Point(0, 0);
- this.valueViewHost.Name = "valueViewHost";
- this.valueViewHost.ReadOnly = false;
- this.valueViewHost.Size = new System.Drawing.Size(633, 466);
- this.valueViewHost.TabIndex = 0;
- this.valueViewHost.ViewsLabelVisible = true;
- this.valueViewHost.ViewType = null;
- //
// PortView
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
- this.Controls.Add(this.valueGroupBox);
this.Name = "PortView";
this.Size = new System.Drawing.Size(645, 517);
@@ -111,8 +67,5 @@
this.Controls.SetChildIndex(this.nameTextBox, 0);
this.Controls.SetChildIndex(this.infoLabel, 0);
- this.Controls.SetChildIndex(this.valueGroupBox, 0);
((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
- this.valueGroupBox.ResumeLayout(false);
- this.valuePanel.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -122,10 +75,4 @@
#endregion
- protected System.Windows.Forms.GroupBox valueGroupBox;
- protected System.Windows.Forms.Panel valuePanel;
- protected MainForm.WindowsForms.ViewHost valueViewHost;
-
-
-
}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.cs (revision 11421)
@@ -28,6 +28,5 @@
namespace HeuristicLab.Optimization.Networks.Views {
[View("Port View")]
- [Content(typeof(Port<>), true)]
- [Content(typeof(IPort<>), false)]
+ [Content(typeof(Port), true)]
[Content(typeof(IPort), false)]
public partial class PortView : NamedItemView {
@@ -40,38 +39,4 @@
InitializeComponent();
}
-
- protected override void DeregisterContentEvents() {
- Content.ValueChanged -= Content_ValueChanged;
- base.DeregisterContentEvents();
- }
-
- protected override void RegisterContentEvents() {
- base.RegisterContentEvents();
- Content.ValueChanged += Content_ValueChanged;
- }
-
- protected override void OnContentChanged() {
- base.OnContentChanged();
- if (Content == null) {
- valueViewHost.Content = null;
- } else {
- valueViewHost.ViewType = null;
- valueViewHost.Content = Content.Value as IContent;
- }
- }
-
- protected override void SetEnabledStateOfControls() {
- base.SetEnabledStateOfControls();
- valueGroupBox.Enabled = (Content as IContent) != null;
- }
- protected virtual void Content_ValueChanged(object sender, System.EventArgs e) {
- if (InvokeRequired)
- Invoke(new EventHandler(Content_ValueChanged), sender, e);
- else {
- valueViewHost.ViewType = null;
- valueViewHost.Content = Content.Value as IContent;
-
- }
- }
}
}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/ValuePortView.Designer.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/ValuePortView.Designer.cs (revision 11421)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/ValuePortView.Designer.cs (revision 11421)
@@ -0,0 +1,132 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.Optimization.Networks.Views {
+ partial class ValuePortView {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing) {
+ if (components != null) components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ this.valueGroupBox = new System.Windows.Forms.GroupBox();
+ this.valuePanel = new System.Windows.Forms.Panel();
+ this.valueViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
+ ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+ this.valueGroupBox.SuspendLayout();
+ this.valuePanel.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // nameTextBox
+ //
+ this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
+ this.errorProvider.SetIconPadding(this.nameTextBox, 2);
+ this.nameTextBox.Location = new System.Drawing.Point(69, 0);
+ this.nameTextBox.Size = new System.Drawing.Size(551, 20);
+ //
+ // infoLabel
+ //
+ this.infoLabel.Location = new System.Drawing.Point(626, 3);
+ //
+ // valueGroupBox
+ //
+ this.valueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.valueGroupBox.Controls.Add(this.valuePanel);
+ this.valueGroupBox.Location = new System.Drawing.Point(0, 26);
+ this.valueGroupBox.Name = "valueGroupBox";
+ this.valueGroupBox.Size = new System.Drawing.Size(645, 491);
+ this.valueGroupBox.TabIndex = 3;
+ this.valueGroupBox.TabStop = false;
+ this.valueGroupBox.Text = "Value";
+ //
+ // valuePanel
+ //
+ this.valuePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.valuePanel.Controls.Add(this.valueViewHost);
+ this.valuePanel.Location = new System.Drawing.Point(6, 19);
+ this.valuePanel.Name = "valuePanel";
+ this.valuePanel.Size = new System.Drawing.Size(633, 466);
+ this.valuePanel.TabIndex = 0;
+ //
+ // valueViewHost
+ //
+ this.valueViewHost.Caption = "View";
+ this.valueViewHost.Content = null;
+ this.valueViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.valueViewHost.Enabled = false;
+ this.valueViewHost.Location = new System.Drawing.Point(0, 0);
+ this.valueViewHost.Name = "valueViewHost";
+ this.valueViewHost.ReadOnly = false;
+ this.valueViewHost.Size = new System.Drawing.Size(633, 466);
+ this.valueViewHost.TabIndex = 0;
+ this.valueViewHost.ViewsLabelVisible = true;
+ this.valueViewHost.ViewType = null;
+ //
+ // ValuePortView
+ //
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
+ this.Controls.Add(this.valueGroupBox);
+ this.Name = "ValuePortView";
+ this.Size = new System.Drawing.Size(645, 517);
+ this.Controls.SetChildIndex(this.nameLabel, 0);
+ this.Controls.SetChildIndex(this.nameTextBox, 0);
+ this.Controls.SetChildIndex(this.infoLabel, 0);
+ this.Controls.SetChildIndex(this.valueGroupBox, 0);
+ ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+ this.valueGroupBox.ResumeLayout(false);
+ this.valuePanel.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ protected System.Windows.Forms.GroupBox valueGroupBox;
+ protected System.Windows.Forms.Panel valuePanel;
+ protected MainForm.WindowsForms.ViewHost valueViewHost;
+
+
+
+
+ }
+}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/ValuePortView.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/ValuePortView.cs (revision 11421)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/ValuePortView.cs (revision 11421)
@@ -0,0 +1,76 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core.Views;
+using HeuristicLab.MainForm;
+using System;
+using System.Windows.Forms;
+
+namespace HeuristicLab.Optimization.Networks.Views {
+ [View("ValuePort View")]
+ [Content(typeof(ValuePort<>), true)]
+ [Content(typeof(IValuePort<>), false)]
+ [Content(typeof(IValuePort), false)]
+ public partial class ValuePortView : PortView {
+ public new IValuePort Content {
+ get { return (IValuePort)base.Content; }
+ set { base.Content = value; }
+ }
+
+ public ValuePortView() {
+ InitializeComponent();
+ }
+
+ protected override void DeregisterContentEvents() {
+ Content.ValueChanged -= Content_ValueChanged;
+ base.DeregisterContentEvents();
+ }
+
+ protected override void RegisterContentEvents() {
+ base.RegisterContentEvents();
+ Content.ValueChanged += Content_ValueChanged;
+ }
+
+ protected override void OnContentChanged() {
+ base.OnContentChanged();
+ if (Content == null) {
+ valueViewHost.Content = null;
+ } else {
+ valueViewHost.ViewType = null;
+ valueViewHost.Content = Content.Value as IContent;
+ }
+ }
+
+ protected override void SetEnabledStateOfControls() {
+ base.SetEnabledStateOfControls();
+ valueGroupBox.Enabled = (Content as IContent) != null;
+ }
+ protected virtual void Content_ValueChanged(object sender, System.EventArgs e) {
+ if (InvokeRequired)
+ Invoke(new EventHandler(Content_ValueChanged), sender, e);
+ else {
+ valueViewHost.ViewType = null;
+ valueViewHost.Content = Content.Value as IContent;
+ }
+ }
+ }
+}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj (revision 11421)
@@ -48,5 +48,7 @@
+
+
@@ -61,5 +63,5 @@
-
+
@@ -67,5 +69,5 @@
-
+
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputOutputPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputOutputPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputOutputPort.cs (revision 11421)
@@ -24,5 +24,5 @@
namespace HeuristicLab.Optimization.Networks {
- public interface IInputOutputPort : IPort {
+ public interface IInputOutputPort : IValuePort {
IOutputInputPort OutputInputPort { get; }
@@ -30,5 +30,5 @@
}
- public interface IInputOutputPort : IInputOutputPort, IPort
+ public interface IInputOutputPort : IInputOutputPort, IValuePort
where TIn : class, IItem
where TOut : class, IItem {
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputPort.cs (revision 11421)
@@ -24,5 +24,5 @@
namespace HeuristicLab.Optimization.Networks {
- public interface IInputPort : IPort {
+ public interface IInputPort : IValuePort {
IOutputPort OutputPort { get; set; }
@@ -30,5 +30,5 @@
}
- public interface IInputPort : IInputPort, IPort where T : class, IItem {
+ public interface IInputPort : IInputPort, IValuePort where T : class, IItem {
new IOutputPort OutputPort { get; set; }
}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputInputPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputInputPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputInputPort.cs (revision 11421)
@@ -24,9 +24,9 @@
namespace HeuristicLab.Optimization.Networks {
- public interface IOutputInputPort : IPort {
+ public interface IOutputInputPort : IValuePort {
object SendValue(object value);
}
- public interface IOutputInputPort : IOutputInputPort, IPort
+ public interface IOutputInputPort : IOutputInputPort, IValuePort
where TOut : class, IItem
where TIn : class, IItem {
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputPort.cs (revision 11421)
@@ -23,9 +23,9 @@
namespace HeuristicLab.Optimization.Networks {
- public interface IOutputPort : IPort {
+ public interface IOutputPort : IValuePort {
new object Value { get; set; }
}
- public interface IOutputPort : IOutputPort, IPort where T : class, IItem {
+ public interface IOutputPort : IOutputPort, IValuePort where T : class, IItem {
new T Value { get; set; }
}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs (revision 11421)
@@ -21,17 +21,8 @@
using HeuristicLab.Core;
-using System;
namespace HeuristicLab.Optimization.Networks {
public interface IPort : INamedItem {
- //DISCUSS: Should there be a reference to the node of this port?
-
- object Value { get; }
-
- event EventHandler ValueChanged;
- }
-
- public interface IPort : IPort where T : class, IItem {
- new T Value { get; }
+ INode Node { get; set; }
}
}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IValuePort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IValuePort.cs (revision 11421)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IValuePort.cs (revision 11421)
@@ -0,0 +1,37 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Core;
+using System;
+
+namespace HeuristicLab.Optimization.Networks {
+ public interface IValuePort : IPort {
+ //DISCUSS: Should there be a reference to the node of this port?
+
+ object Value { get; }
+
+ event EventHandler ValueChanged;
+ }
+
+ public interface IValuePort : IValuePort where T : class, IItem {
+ new T Value { get; }
+ }
+}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs (revision 11421)
@@ -28,5 +28,5 @@
[Item("InputOutputPort", "A synchronous input/output port of an optimization network node.")]
[StorableClass]
- public class InputOutputPort : Port, IInputOutputPort
+ public class InputOutputPort : ValuePort, IInputOutputPort
where TIn : class, IItem
where TOut : class, IItem {
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs (revision 11421)
@@ -29,5 +29,5 @@
[Item("InputPort", "An asynchronous input port of an optimization network node.")]
[StorableClass]
- public class InputPort : Port, IInputPort where T : class, IItem {
+ public class InputPort : ValuePort, IInputPort where T : class, IItem {
public static new Image StaticItemImage {
get { return HeuristicLab.Common.Resources.VSImageLibrary.ArrowDown; }
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Node.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Node.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Node.cs (revision 11421)
@@ -56,15 +56,15 @@
public Node()
: base("Node") {
- ports = new PortCollection();
+ ports = new PortCollection(this);
readOnlyPorts = null;
}
public Node(string name)
: base(name) {
- ports = new PortCollection();
+ ports = new PortCollection(this);
readOnlyPorts = null;
}
public Node(string name, string description)
: base(name, description) {
- ports = new PortCollection();
+ ports = new PortCollection(this);
readOnlyPorts = null;
}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputInputPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputInputPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputInputPort.cs (revision 11421)
@@ -28,5 +28,5 @@
[Item("OutputInputPort", "A synchronous output/input port of an optimization network node.")]
[StorableClass]
- public class OutputInputPort : Port, IOutputInputPort
+ public class OutputInputPort : ValuePort, IOutputInputPort
where TOut : class, IItem
where TIn : class, IItem {
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputPort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputPort.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputPort.cs (revision 11421)
@@ -29,5 +29,5 @@
[Item("OutputPort", "An asynchronous output port of an optimization network node.")]
[StorableClass]
- public class OutputPort : Port, IOutputPort where T : class, IItem {
+ public class OutputPort : ValuePort, IOutputPort where T : class, IItem {
public static new Image StaticItemImage {
get { return HeuristicLab.Common.Resources.VSImageLibrary.ArrowUp; }
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs (revision 11421)
@@ -29,5 +29,5 @@
[Item("Port", "Abstract base class for ports of an optimization network node.")]
[StorableClass]
- public abstract class Port : NamedItem, IPort where T : class, IItem {
+ public abstract class Port : NamedItem, IPort {
public static new Image StaticItemImage {
get { return HeuristicLab.Common.Resources.VSImageLibrary.Field; }
@@ -35,58 +35,25 @@
[Storable]
- protected T value;
- public virtual T Value {
- get { return value; }
- protected set {
- DeregisterValueEvents();
- this.value = value;
- RegisterValueEvents();
- OnValueChanged();
+ private INode node;
+ public INode Node {
+ get { return node; }
+ set {
+ if ((value != null) && !value.Ports.Contains(this))
+ throw new InvalidOperationException("Port is not contained in port collection of node.");
+ if ((value == null) && node.Ports.Contains(this))
+ throw new InvalidOperationException("Port is still contained in port collection of node.");
+ node = value;
}
- }
- object IPort.Value {
- get { return Value; }
}
[StorableConstructor]
protected Port(bool deserializing) : base(deserializing) { }
- protected Port(Port original, Cloner cloner)
+ protected Port(Port original, Cloner cloner)
: base(original, cloner) {
- value = cloner.Clone(original.value);
- RegisterValueEvents();
+ node = (INode)cloner.GetClone(original.node); // NOTE: original node is NOT automatically cloned
}
protected Port() : base("Port") { }
protected Port(string name) : base(name) { }
protected Port(string name, string description) : base(name, description) { }
-
- [StorableHook(HookType.AfterDeserialization)]
- private void AfterDeserialization() {
- RegisterValueEvents();
- }
-
- public override string ToString() {
- return Name + ": " + (Value != null ? Value.ToString() : "null");
- }
-
- public event EventHandler ValueChanged;
- protected virtual void OnValueChanged() {
- var handler = ValueChanged;
- if (handler != null) handler(this, EventArgs.Empty);
- OnToStringChanged();
- }
-
- protected virtual void RegisterValueEvents() {
- if (value != null) {
- value.ToStringChanged += new EventHandler(Value_ToStringChanged);
- }
- }
- protected virtual void DeregisterValueEvents() {
- if (value != null) {
- value.ToStringChanged -= new EventHandler(Value_ToStringChanged);
- }
- }
- private void Value_ToStringChanged(object sender, EventArgs e) {
- OnToStringChanged();
- }
}
}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/PortCollection.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/PortCollection.cs (revision 11420)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/PortCollection.cs (revision 11421)
@@ -20,21 +20,68 @@
#endregion
-using System.Collections.Generic;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System;
+using System.Collections.Generic;
namespace HeuristicLab.Optimization.Networks {
[StorableClass]
- [Item("PortCollection", "Represents a collection of ports.")]
+ [Item("PortCollection", "Represents a collection of ports in an optimization network node.")]
public class PortCollection : NamedItemCollection {
+ [Storable]
+ private INode node;
+ public INode Node {
+ get { return node; }
+ }
+
[StorableConstructor]
protected PortCollection(bool deserializing) : base(deserializing) { }
- protected PortCollection(PortCollection original, Cloner cloner) : base(original, cloner) { }
- public PortCollection() : base() { }
- public PortCollection(int capacity) : base(capacity) { }
- public PortCollection(IEnumerable collection) : base(collection) { }
+ protected PortCollection(PortCollection original, Cloner cloner)
+ : base(original, cloner) {
+ if (!cloner.ClonedObjectRegistered(original.node))
+ // NOTE: cannot clone port collection alone if referenced node is not cloned
+ throw new InvalidOperationException("Node of port collection is not cloned.");
+ node = cloner.Clone(original.node);
+ }
+ public PortCollection(INode node)
+ : base() {
+ this.node = node;
+ }
+ public PortCollection(INode node, int capacity)
+ : base(capacity) {
+ this.node = node;
+ }
+ public PortCollection(INode node, IEnumerable collection)
+ : base(collection) {
+ this.node = node;
+ }
public override IDeepCloneable Clone(Cloner cloner) { return new PortCollection(this, cloner); }
+
+ protected override void OnItemsAdded(IEnumerable items) {
+ foreach (var p in items)
+ p.Node = node;
+ base.OnItemsAdded(items);
+ }
+ protected override void OnItemsRemoved(IEnumerable items) {
+ foreach (var p in items)
+ p.Node = null;
+ base.OnItemsRemoved(items);
+ }
+ protected override void OnItemsReplaced(IEnumerable items, IEnumerable oldItems) {
+ foreach (var p in oldItems)
+ p.Node = null;
+ foreach (var p in items)
+ p.Node = node;
+ base.OnItemsReplaced(items, oldItems);
+ }
+ protected override void OnCollectionReset(IEnumerable items, IEnumerable oldItems) {
+ foreach (var p in oldItems)
+ p.Node = null;
+ foreach (var p in items)
+ p.Node = node;
+ base.OnCollectionReset(items, oldItems);
+ }
}
}
Index: /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/ValuePort.cs
===================================================================
--- /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/ValuePort.cs (revision 11421)
+++ /branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/ValuePort.cs (revision 11421)
@@ -0,0 +1,87 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System;
+
+namespace HeuristicLab.Optimization.Networks {
+ [Item("ValuePort", "Abstract base class for ports of an optimization network node which contain a single value.")]
+ [StorableClass]
+ public abstract class ValuePort : Port, IValuePort where T : class, IItem {
+ [Storable]
+ protected T value;
+ public virtual T Value {
+ get { return value; }
+ protected set {
+ DeregisterValueEvents();
+ this.value = value;
+ RegisterValueEvents();
+ OnValueChanged();
+ }
+ }
+ object IValuePort.Value {
+ get { return Value; }
+ }
+
+ [StorableConstructor]
+ protected ValuePort(bool deserializing) : base(deserializing) { }
+ protected ValuePort(ValuePort original, Cloner cloner)
+ : base(original, cloner) {
+ value = cloner.Clone(original.value);
+ RegisterValueEvents();
+ }
+ protected ValuePort() : base("ValuePort") { }
+ protected ValuePort(string name) : base(name) { }
+ protected ValuePort(string name, string description) : base(name, description) { }
+
+ [StorableHook(HookType.AfterDeserialization)]
+ private void AfterDeserialization() {
+ RegisterValueEvents();
+ }
+
+ public override string ToString() {
+ return base.ToString() + ": " + (Value != null ? Value.ToString() : "null");
+ }
+
+ public event EventHandler ValueChanged;
+ protected virtual void OnValueChanged() {
+ var handler = ValueChanged;
+ if (handler != null) handler(this, EventArgs.Empty);
+ OnToStringChanged();
+ }
+
+ protected virtual void RegisterValueEvents() {
+ if (value != null) {
+ value.ToStringChanged += new EventHandler(Value_ToStringChanged);
+ }
+ }
+ protected virtual void DeregisterValueEvents() {
+ if (value != null) {
+ value.ToStringChanged -= new EventHandler(Value_ToStringChanged);
+ }
+ }
+ private void Value_ToStringChanged(object sender, EventArgs e) {
+ OnToStringChanged();
+ }
+ }
+}