- Timestamp:
- 09/30/14 02:14:09 (10 years ago)
- Location:
- branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/EventArgs.cs
r11401 r11406 24 24 25 25 namespace HeuristicLab.Optimization.Networks { 26 public class OutputInputPortEventArgs<T> : EventArgs where T : class, IItem { 27 public T Result { get; set; } 26 public class OutputInputPortEventArgs<TOut, TIn> : EventArgs 27 where TOut : class, IItem 28 where TIn : class, IItem { 29 public TOut Value { get; private set; } 30 public TIn Result { get; set; } 28 31 29 public OutputInputPortEventArgs() { } 32 public OutputInputPortEventArgs(TOut value) { 33 Value = value; 34 } 30 35 } 31 36 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj
r11401 r11406 50 50 <Compile Include="EventArgs.cs" /> 51 51 <Compile Include="IInputOutputPort.cs" /> 52 <Compile Include="IAlgorithmNode.cs" /> 52 53 <Compile Include="InputOutputPort.cs" /> 53 54 <Compile Include="IOutputInputPort.cs" /> 55 <Compile Include="AlgorithmNode.cs" /> 54 56 <Compile Include="OutputInputPort.cs" /> 55 57 <Compile Include="OutputPort.cs" /> … … 90 92 <Name>HeuristicLab.Core-3.3</Name> 91 93 </ProjectReference> 94 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 95 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> 96 <Name>HeuristicLab.Optimization-3.3</Name> 97 </ProjectReference> 92 98 <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj"> 93 99 <Project>{102bc7d3-0ef9-439c-8f6d-96ff0fdb8e1b}</Project> -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputOutputPort.cs
r11401 r11406 21 21 22 22 using HeuristicLab.Core; 23 using System; 23 24 24 25 namespace HeuristicLab.Optimization.Networks { … … 31 32 where TOut : class, IItem { 32 33 new IOutputInputPort<TIn, TOut> OutputInputPort { get; set; } 34 35 event EventHandler<OutputInputPortEventArgs<TIn, TOut>> ValueReceived; 33 36 } 34 37 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputInputPort.cs
r11401 r11406 33 33 TIn SendValue(TOut value); 34 34 35 event EventHandler<OutputInputPortEventArgs<T In>> ValueSent;35 event EventHandler<OutputInputPortEventArgs<TOut, TIn>> ValueSent; 36 36 } 37 37 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs
r11401 r11406 73 73 } 74 74 75 public event EventHandler<OutputInputPortEventArgs<TIn, TOut>> ValueReceived; 76 protected TOut OnValueReceived(TIn value) { 77 var args = new OutputInputPortEventArgs<TIn, TOut>(value); 78 var handler = ValueReceived; 79 if (handler != null) handler(this, args); 80 return args.Result; 81 } 82 75 83 protected void RegisterOutputInputPortEvents() { 76 84 outputInputPort.ValueSent += OutputInputPort_ValueSent; … … 79 87 outputInputPort.ValueSent -= OutputInputPort_ValueSent; 80 88 } 81 protected void OutputInputPort_ValueSent(object sender, OutputInputPortEventArgs<TOut> e) { 82 Value = OutputInputPort.Value; 83 //TODO: switch threads to decouple value propagation and resulting action 84 //TODO: clone value? 85 //TODO: add computed result to event args 89 protected void OutputInputPort_ValueSent(object sender, OutputInputPortEventArgs<TIn, TOut> e) { 90 var value = (TIn)e.Value.Clone(); 91 Value = value; 92 e.Result = OnValueReceived(value); 93 //DISCUSS: clone value? 94 //DISCUSS: switch threads to decouple value propagation and resulting action -> should be done in Node? 86 95 } 87 96 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs
r11401 r11406 79 79 } 80 80 protected void OutputPort_ValueChanged(object sender, EventArgs e) { 81 Value = OutputPort.Value; 82 //TODO: switch threads to decouple value propagation and to make communication asynchronous 83 //TODO: clone value? 84 //TODO: clone value? 81 Value = (T)OutputPort.Value.Clone(); 82 //DISCUSS: clone value? 83 //DISCUSS: switch threads to decouple value propagation and to make communication asynchronous -> should be done in Node? 85 84 } 86 85 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputInputPort.cs
r11401 r11406 45 45 public TIn SendValue(TOut value) { 46 46 Value = value; 47 return OnValueSent( );47 return OnValueSent(value); 48 48 } 49 49 public object SendValue(object value) { … … 57 57 } 58 58 59 public event EventHandler<OutputInputPortEventArgs<T In>> ValueSent;60 protected virtual TIn OnValueSent( ) {61 var args = new OutputInputPortEventArgs<T In>();59 public event EventHandler<OutputInputPortEventArgs<TOut, TIn>> ValueSent; 60 protected virtual TIn OnValueSent(TOut value) { 61 var args = new OutputInputPortEventArgs<TOut, TIn>(value); 62 62 var handler = ValueSent; 63 63 if (handler != null) handler(this, args); -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Plugin.cs.frame
r11401 r11406 34 34 // [PluginDependency("HeuristicLab.Data", "3.3")] 35 35 // [PluginDependency("HeuristicLab.Parameters", "3.3")] 36 [PluginDependency("HeuristicLab.Optimization", "3.3")] 36 37 [PluginDependency("HeuristicLab.Persistence", "3.3")] 37 38 public class HeuristicLabOptimizationNetworksPlugin : PluginBase { -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs
r11401 r11406 39 39 get { return value; } 40 40 protected set { 41 if (value != this.value) { 42 DeregisterValueEvents(); 43 this.value = value; 44 RegisterValueEvents(); 45 OnValueChanged(); 46 } 41 DeregisterValueEvents(); 42 this.value = value; 43 RegisterValueEvents(); 44 OnValueChanged(); 47 45 } 48 46 } … … 73 71 public event EventHandler ValueChanged; 74 72 protected virtual void OnValueChanged() { 75 EventHandler handler = ValueChanged;73 var handler = ValueChanged; 76 74 if (handler != null) handler(this, EventArgs.Empty); 77 75 OnToStringChanged();
Note: See TracChangeset
for help on using the changeset viewer.