Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11529


Ignore:
Timestamp:
11/10/14 02:34:58 (10 years ago)
Author:
swagner
Message:

#2205: Implemented review comments

  • made Node and Network abstract
  • renamed GenericNode to UserDefinedNode and sealed it
  • added sealed UserDefinedNetwork
  • made Nodes in Network not changeable by default
  • made Parameters in ParameterizedPort not changeable by default
  • removed value None in PortParameterType
  • refactored call algorithm.PrepareMessage() in AlgorithmNode
Location:
branches/OptimizationNetworks
Files:
4 added
13 edited
4 moved

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Core.Networks.Views/GenericPortView.cs

    r11528 r11529  
    6666    protected override void OnContentChanged() {
    6767      base.OnContentChanged();
     68      portParameterCollectionView.Content = Content == null ? null : Content.Parameters;
    6869      connectedPortView.Content = Content == null ? null : Content.ConnectedPort;
    6970      portParameterCollectionView.Content = Content == null ? null : Content.Parameters;
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Core.Networks.Views/UserDefinedNodeView.Designer.cs

    r11527 r11529  
    2121
    2222namespace HeuristicLab.Core.Networks.Views {
    23   partial class GenericNodeView {
     23  partial class UserDefinedNodeView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Core.Networks.Views/UserDefinedNodeView.cs

    r11527 r11529  
    2424
    2525namespace HeuristicLab.Core.Networks.Views {
    26   [View("GenericNode View")]
    27   [Content(typeof(GenericNode), true)]
    28   [Content(typeof(IGenericNode), false)]
    29   public partial class GenericNodeView : NodeView {
    30     public new IGenericNode Content {
    31       get { return (IGenericNode)base.Content; }
     26  [View("UserDefinedNode View")]
     27  [Content(typeof(UserDefinedNode), true)]
     28  [Content(typeof(IUserDefinedNode), false)]
     29  public partial class UserDefinedNodeView : NodeView {
     30    public new IUserDefinedNode Content {
     31      get { return (IUserDefinedNode)base.Content; }
    3232      set { base.Content = value; }
    3333    }
    3434
    35     public GenericNodeView() {
     35    public UserDefinedNodeView() {
    3636      InitializeComponent();
    3737    }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj

    r11528 r11529  
    9191  </ItemGroup>
    9292  <ItemGroup>
    93     <Compile Include="Core.Networks.Views\GenericNodeView.cs">
    94       <SubType>UserControl</SubType>
    95     </Compile>
    96     <Compile Include="Core.Networks.Views\GenericNodeView.Designer.cs">
    97       <DependentUpon>GenericNodeView.cs</DependentUpon>
    98     </Compile>
    9993    <Compile Include="Core.Networks.Views\GenericPortView.cs">
    10094      <SubType>UserControl</SubType>
     
    192186    <Compile Include="Core.Networks.Views\PortView.Designer.cs">
    193187      <DependentUpon>PortView.cs</DependentUpon>
     188    </Compile>
     189    <Compile Include="Core.Networks.Views\UserDefinedNetworkView.cs">
     190      <SubType>UserControl</SubType>
     191    </Compile>
     192    <Compile Include="Core.Networks.Views\UserDefinedNetworkView.Designer.cs">
     193      <DependentUpon>UserDefinedNetworkView.cs</DependentUpon>
     194    </Compile>
     195    <Compile Include="Core.Networks.Views\UserDefinedNodeView.cs">
     196      <SubType>UserControl</SubType>
     197    </Compile>
     198    <Compile Include="Core.Networks.Views\UserDefinedNodeView.Designer.cs">
     199      <DependentUpon>UserDefinedNodeView.cs</DependentUpon>
    194200    </Compile>
    195201    <Compile Include="Operators.Views\HookOperatorView.cs">
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/GenericPort.cs

    r11528 r11529  
    3737        else return HeuristicLab.Common.Resources.VSImageLibrary.Error;
    3838      }
     39    }
     40
     41    new public PortParameterCollection Parameters {
     42      get { return base.Parameters; }
    3943    }
    4044
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/IGenericPort.cs

    r11526 r11529  
    2727namespace HeuristicLab.Core.Networks {
    2828  public interface IGenericPort : IParameterizedPort {
     29    new PortParameterCollection Parameters { get; }
     30
    2931    IConnectedPort ConnectedPort { get; set; }
    3032    bool PortConnectionValid { get; }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/INetwork.cs

    r11526 r11529  
    2222namespace HeuristicLab.Core.Networks {
    2323  public interface INetwork : INode {
    24     NodeCollection Nodes { get; }
     24    IKeyedItemCollection<string, INode> Nodes { get; }
    2525  }
    2626}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/IParameterizedPort.cs

    r11526 r11529  
    2424namespace HeuristicLab.Core.Networks {
    2525  public interface IParameterizedPort : IPort {
    26     PortParameterCollection Parameters { get; }
     26    IKeyedItemCollection<string, IPortParameter> Parameters { get; }
    2727
    2828    event EventHandler InterfaceChanged;
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/IUserDefinedNode.cs

    r11527 r11529  
    2121
    2222namespace HeuristicLab.Core.Networks {
    23   public interface IGenericNode : INode {
     23  public interface IUserDefinedNode : INode {
    2424    new PortCollection Ports { get; }
    2525  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/Network.cs

    r11528 r11529  
    2727
    2828namespace HeuristicLab.Core.Networks {
    29   [Item("Network", "An optimization network.")]
    30   [Creatable("Optimization Networks")]
     29  [Item("Network", "Abstract base class for networks.")]
    3130  [StorableClass]
    32   public class Network : Node, INetwork, IStorableContent {
     31  public abstract class Network : Node, INetwork, IStorableContent {
    3332    public string Filename { get; set; }
    3433
     
    4342    [Storable]
    4443    private NodeCollection nodes;
    45     public NodeCollection Nodes {
     44    protected NodeCollection Nodes {
    4645      get { return nodes; }
     46    }
     47    private ReadOnlyKeyedItemCollection<string, INode> readOnlyNodes;
     48    IKeyedItemCollection<string, INode> INetwork.Nodes {
     49      get {
     50        if (readOnlyNodes == null) readOnlyNodes = nodes.AsReadOnly();
     51        return readOnlyNodes;
     52      }
    4753    }
    4854
     
    5460      foreach (var n in Nodes)
    5561        n.Parent = this;
     62      readOnlyNodes = null;
    5663      RegisterNodesEvents();
    5764    }
    58     public Network()
     65    protected Network()
    5966      : base("Network") {
    6067      nodes = new NodeCollection();
     68      readOnlyNodes = null;
    6169      RegisterNodesEvents();
    6270    }
    63     public Network(string name)
     71    protected Network(string name)
    6472      : base(name) {
    6573      nodes = new NodeCollection();
     74      readOnlyNodes = null;
    6675      RegisterNodesEvents();
    6776    }
    68     public Network(string name, string description)
     77    protected Network(string name, string description)
    6978      : base(name, description) {
    7079      nodes = new NodeCollection();
     80      readOnlyNodes = null;
    7181      RegisterNodesEvents();
    7282    }
     
    7787        n.Parent = this;
    7888      RegisterNodesEvents();
    79     }
    80 
    81     public override IDeepCloneable Clone(Cloner cloner) {
    82       return new Network(this, cloner);
    8389    }
    8490
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/Node.cs

    r11528 r11529  
    2727
    2828namespace HeuristicLab.Core.Networks {
    29   [Item("Node", "A node of an optimization network.")]
     29  [Item("Node", "Abstract base class for nodes of a network.")]
    3030  [StorableClass]
    31   public class Node : NetworkItem, INode {
     31  public abstract class Node : NetworkItem, INode {
    3232    public static new Image StaticItemImage {
    3333      get { return HeuristicLab.Common.Resources.VSImageLibrary.RadialChart; }
     
    6868      RegisterPortsEvents();
    6969    }
    70     public Node()
     70    protected Node()
    7171      : base("Node") {
    7272      ports = new PortCollection();
     
    7474      RegisterPortsEvents();
    7575    }
    76     public Node(string name)
     76    protected Node(string name)
    7777      : base(name) {
    7878      ports = new PortCollection();
     
    8080      RegisterPortsEvents();
    8181    }
    82     public Node(string name, string description)
     82    protected Node(string name, string description)
    8383      : base(name, description) {
    8484      ports = new PortCollection();
     
    9292        p.Parent = this;
    9393      RegisterPortsEvents();
    94     }
    95 
    96     public override IDeepCloneable Clone(Cloner cloner) {
    97       return new Node(this, cloner);
    9894    }
    9995
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/ParameterizedPort.cs

    r11528 r11529  
    3535
    3636    [Storable]
    37     protected PortParameterCollection parameters;
    38     public PortParameterCollection Parameters {
     37    private PortParameterCollection parameters;
     38    protected PortParameterCollection Parameters {
    3939      get { return parameters; }
     40    }
     41    private ReadOnlyKeyedItemCollection<string, IPortParameter> readOnlyParameters;
     42    IKeyedItemCollection<string, IPortParameter> IParameterizedPort.Parameters {
     43      get {
     44        if (readOnlyParameters == null) readOnlyParameters = parameters.AsReadOnly();
     45        return readOnlyParameters;
     46      }
    4047    }
    4148
     
    4754      foreach (var p in Parameters)
    4855        p.Parent = this;
     56      readOnlyParameters = null;
    4957      RegisterParametersEvents();
    5058    }
     
    5260      : base("ParameterizedPort") {
    5361      parameters = new PortParameterCollection();
     62      readOnlyParameters = null;
    5463      RegisterParametersEvents();
    5564    }
     
    5766      : base(name) {
    5867      parameters = new PortParameterCollection();
     68      readOnlyParameters = null;
    5969      RegisterParametersEvents();
    6070    }
     
    6272      : base(name, description) {
    6373      parameters = new PortParameterCollection();
     74      readOnlyParameters = null;
    6475      RegisterParametersEvents();
    6576    }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/PortParameterType.cs

    r11526 r11529  
    2525  [Flags]
    2626  public enum PortParameterType {
    27     None = 0,
    2827    Input = 1,
    2928    Output = 2
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/UserDefinedNode.cs

    r11527 r11529  
    2424
    2525namespace HeuristicLab.Core.Networks {
    26   [Item("GenericNode", "A generic node of an optimization network.")]
     26  [Item("User-Defined Node", "A node of a network which can be defined by the user.")]
    2727  [StorableClass]
    28   public class GenericNode : Node, IGenericNode {
     28  public sealed class UserDefinedNode : Node, IUserDefinedNode {
    2929    new public PortCollection Ports {
    3030      get { return base.Ports; }
     
    3232
    3333    [StorableConstructor]
    34     protected GenericNode(bool deserializing) : base(deserializing) { }
    35     protected GenericNode(GenericNode original, Cloner cloner) : base(original, cloner) { }
    36     public GenericNode() : base("GenericNode") { }
    37     public GenericNode(string name) : base(name) { }
    38     public GenericNode(string name, string description) : base(name, description) { }
     34    private UserDefinedNode(bool deserializing) : base(deserializing) { }
     35    private UserDefinedNode(UserDefinedNode original, Cloner cloner) : base(original, cloner) { }
     36    public UserDefinedNode() : base("UserDefinedNode") { }
     37    public UserDefinedNode(string name) : base(name) { }
     38    public UserDefinedNode(string name, string description) : base(name, description) { }
    3939
    4040    public override IDeepCloneable Clone(Cloner cloner) {
    41       return new GenericNode(this, cloner);
     41      return new UserDefinedNode(this, cloner);
    4242    }
    4343  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj

    r11528 r11529  
    9090  </ItemGroup>
    9191  <ItemGroup>
    92     <Compile Include="Core.Networks\GenericNode.cs" />
     92    <Compile Include="Core.Networks\IUserDefinedNetwork.cs" />
     93    <Compile Include="Core.Networks\IUserDefinedNode.cs" />
     94    <Compile Include="Core.Networks\UserDefinedNetwork.cs" />
    9395    <Compile Include="Core.Networks\GenericPort.cs" />
    9496    <Compile Include="Core.Networks\IConnectedPort.cs" />
    95     <Compile Include="Core.Networks\IGenericNode.cs" />
    9697    <Compile Include="Core.Networks\IGenericPort.cs" />
    9798    <Compile Include="Core.Networks\IMessage.cs" />
     
    117118    <Compile Include="Core.Networks\PortParameterCollection.cs" />
    118119    <Compile Include="Core.Networks\PortParameterType.cs" />
     120    <Compile Include="Core.Networks\UserDefinedNode.cs" />
    119121    <Compile Include="Operators\HookOperator.cs" />
    120122    <Compile Include="Operators\IHookOperator.cs" />
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Optimization.Networks.KSPTSP/KSPTSPNetwork.cs

    r11526 r11529  
    6060    protected virtual void Initialize() {
    6161      #region ParametersNode
    62       var paramsNode = new GenericNode("ParametersNode");
     62      var paramsNode = new UserDefinedNode("ParametersNode");
    6363      Nodes.Add(paramsNode);
    6464
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Optimization.Networks/AlgorithmNode.cs

    r11526 r11529  
    125125
    126126      algorithm.StoreAlgorithmInEachRun = false;
    127       algorithm.Runs.Clear();
    128       algorithm.Prepare();
     127      algorithm.Prepare(true);
    129128      algorithm.ExceptionOccurred += Algorithm_ExceptionOccurred;
    130129      algorithm.Stopped += Algorithm_Stopped;
Note: See TracChangeset for help on using the changeset viewer.