Changeset 13799 for branches/OptimizationNetworks/HeuristicLab.Networks
- Timestamp:
- 04/26/16 15:05:28 (9 years ago)
- Location:
- branches/OptimizationNetworks/HeuristicLab.Networks/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks/3.3/AlgorithmNode.cs
r13459 r13799 59 59 } 60 60 61 [Storable] 62 private IItemCollection<IAlgorithm> startedAlgorithms; 63 public IItemCollection<IAlgorithm> StartedAlgorithms { 64 get { return startedAlgorithms; } 65 } 66 61 67 [StorableConstructor] 62 68 protected AlgorithmNode(bool deserializing) : base(deserializing) { } … … 65 71 algorithm = cloner.Clone(original.algorithm); 66 72 runs = cloner.Clone(original.runs); 73 startedAlgorithms = cloner.Clone(original.startedAlgorithms); 74 RegisterStartedAlgorithmsEvents(); 67 75 } 68 76 public AlgorithmNode() 69 77 : base("AlgorithmNode") { 70 78 runs = new RunCollection(); 71 } 79 startedAlgorithms = new ItemCollection<IAlgorithm>(); 80 RegisterStartedAlgorithmsEvents(); 81 } 82 72 83 public AlgorithmNode(string name) 73 84 : base(name) { 74 85 runs = new RunCollection(); 86 startedAlgorithms = new ItemCollection<IAlgorithm>(); 87 RegisterStartedAlgorithmsEvents(); 75 88 } 76 89 public AlgorithmNode(string name, string description) 77 90 : base(name, description) { 78 91 runs = new RunCollection(); 92 startedAlgorithms = new ItemCollection<IAlgorithm>(); 93 RegisterStartedAlgorithmsEvents(); 79 94 } 80 95 81 96 public override IDeepCloneable Clone(Cloner cloner) { 82 97 return new AlgorithmNode(this, cloner); 98 } 99 100 [StorableHook(HookType.AfterDeserialization)] 101 private void AfterDeserialization() { 102 RegisterStartedAlgorithmsEvents(); 103 } 104 105 protected virtual void RegisterStartedAlgorithmsEvents() { 106 startedAlgorithms.ItemsAdded += StartedAlgorithms_ItemsChanged; 107 startedAlgorithms.ItemsRemoved += StartedAlgorithms_ItemsChanged; 108 } 109 110 private void StartedAlgorithms_ItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IAlgorithm> e) { 111 OnStartedAlgorithmsChanged(); 83 112 } 84 113 … … 146 175 algorithm.Prepare(true); 147 176 algorithm.ExceptionOccurred += (sender, args) => { exception = args.Value; }; 148 algorithm.Started += (sender, args) => { started.Set(); };149 algorithm.Stopped += (sender, args) => { stopped.Set(); };177 algorithm.Started += (sender, args) => { started.Set(); startedAlgorithms.Add((IAlgorithm)sender); }; 178 algorithm.Stopped += (sender, args) => { stopped.Set(); startedAlgorithms.Remove((IAlgorithm)sender); }; 150 179 algorithm.Start(); 151 180 stopped.WaitOne(); … … 175 204 } 176 205 206 public event EventHandler StartedAlgorithmsChanged; 207 protected virtual void OnStartedAlgorithmsChanged() { 208 var handler = StartedAlgorithmsChanged; 209 if (handler != null) handler(this, EventArgs.Empty); 210 } 211 177 212 #region Ports Events 178 213 protected override void RegisterPortsEvents() { -
branches/OptimizationNetworks/HeuristicLab.Networks/3.3/IAlgorithmNode.cs
r11577 r13799 20 20 #endregion 21 21 22 using System; 23 using HeuristicLab.Core; 22 24 using HeuristicLab.Core.Networks; 23 25 using HeuristicLab.Optimization; 24 using System;25 26 26 27 namespace HeuristicLab.Networks { … … 29 30 IAlgorithm Algorithm { get; set; } 30 31 RunCollection Runs { get; } 32 IItemCollection<IAlgorithm> StartedAlgorithms { get; } 31 33 32 34 event EventHandler AlgorithmChanged; 35 event EventHandler StartedAlgorithmsChanged; 33 36 } 34 37 }
Note: See TracChangeset
for help on using the changeset viewer.