- Timestamp:
- 10/29/10 19:47:39 (14 years ago)
- Location:
- branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Converters/BoolConverter.cs
r3881 r4682 22 22 using System; 23 23 using System.Linq; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; … … 31 32 public class BoolConverter : Item, IItemToSolutionMessageConverter { 32 33 private static readonly Type[] itemTypes = new Type[] { typeof(ValueTypeValue<bool>), typeof(ValueTypeArray<bool>), typeof(ValueTypeMatrix<bool>) }; 34 [StorableConstructor] 35 protected BoolConverter(bool deserializing) : base(deserializing) { } 36 protected BoolConverter(BoolConverter original, Cloner cloner) : base(original, cloner) { } 37 public override IDeepCloneable Clone(Cloner cloner) { 38 return new BoolConverter(this, cloner); 39 } 40 public BoolConverter() : base() { } 33 41 34 42 #region IItemToSolutionMessageConverter Members 35 43 36 44 public Type[] ItemTypes { 37 45 get { return itemTypes; } -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Converters/DateTimeValueConverter.cs
r4068 r4682 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 30 31 public class DateTimeValueConverter : Item, IItemToSolutionMessageConverter { 31 32 private static readonly Type[] itemTypes = new Type[] { typeof(DateTimeValue) }; 33 [StorableConstructor] 34 protected DateTimeValueConverter(bool deserializing) : base(deserializing) { } 35 protected DateTimeValueConverter(DateTimeValueConverter original, Cloner cloner) : base(original, cloner) { } 36 public override IDeepCloneable Clone(Cloner cloner) { 37 return new DateTimeValueConverter(this, cloner); 38 } 39 public DateTimeValueConverter() : base() { } 32 40 33 41 #region IItemToSolutionMessageConverter Members -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Converters/DoubleConverter.cs
r3881 r4682 22 22 using System; 23 23 using System.Linq; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; … … 32 33 private static readonly Type[] itemTypes = new Type[] { typeof(ValueTypeValue<double>), typeof(ValueTypeArray<double>), typeof(ValueTypeMatrix<double>) }; 33 34 35 [StorableConstructor] 36 protected DoubleConverter(bool deserializing) : base(deserializing) { } 37 protected DoubleConverter(DoubleConverter original, Cloner cloner) : base(original, cloner) { } 38 public override IDeepCloneable Clone(Cloner cloner) { 39 return new DoubleConverter(this, cloner); 40 } 41 public DoubleConverter() : base() { } 42 34 43 #region IItemToSolutionMessageConverter Members 35 44 36 45 public Type[] ItemTypes { 37 46 get { return itemTypes; } -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Converters/IntegerConverter.cs
r3881 r4682 22 22 using System; 23 23 using System.Linq; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; … … 32 33 private static readonly Type[] itemTypes = new Type[] { typeof(ValueTypeValue<int>), typeof(ValueTypeArray<int>), typeof(ValueTypeMatrix<int>) }; 33 34 35 [StorableConstructor] 36 protected IntegerConverter(bool deserializing) : base(deserializing) { } 37 protected IntegerConverter(IntegerConverter original, Cloner cloner) : base(original, cloner) { } 38 public override IDeepCloneable Clone(Cloner cloner) { 39 return new IntegerConverter(this, cloner); 40 } 41 public IntegerConverter() : base() { } 42 34 43 #region IItemToSolutionMessageConverter Members 35 44 36 45 public Type[] ItemTypes { 37 46 get { return itemTypes; } -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Converters/StringConverter.cs
r4068 r4682 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 30 31 public class StringConverter : Item, IItemToSolutionMessageConverter { 31 32 private static readonly Type[] itemTypes = new Type[] { typeof(StringValue), typeof(StringArray), typeof(StringMatrix), typeof(IStringConvertibleValue), typeof(IStringConvertibleArray), typeof(IStringConvertibleMatrix) }; 33 34 [StorableConstructor] 35 protected StringConverter(bool deserializing) : base(deserializing) { } 36 protected StringConverter(StringConverter original, Cloner cloner) : base(original, cloner) { } 37 public override IDeepCloneable Clone(Cloner cloner) { 38 return new StringConverter(this, cloner); 39 } 40 public StringConverter() : base() { } 32 41 33 42 #region IItemToSolutionMessageConverter Members -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Converters/TimeSpanValueConverter.cs
r4068 r4682 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 30 31 public class TimeSpanValueConverter : Item, IItemToSolutionMessageConverter { 31 32 private static readonly Type[] itemTypes = new Type[] { typeof(TimeSpanValue) }; 33 34 [StorableConstructor] 35 protected TimeSpanValueConverter(bool deserializing) : base(deserializing) { } 36 protected TimeSpanValueConverter(TimeSpanValueConverter original, Cloner cloner) : base(original, cloner) { } 37 public override IDeepCloneable Clone(Cloner cloner) { 38 return new TimeSpanValueConverter(this, cloner); 39 } 40 public TimeSpanValueConverter() : base() { } 32 41 33 42 #region IItemToSolutionMessageConverter Members -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Drivers/EvaluationChannel.cs
r4068 r4682 21 21 22 22 using Google.ProtocolBuffers; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 33 34 [StorableConstructor] 34 35 protected EvaluationChannel(bool deserializing) : base(deserializing) { } 36 protected EvaluationChannel(EvaluationChannel original, Cloner cloner) : base(original, cloner) { } 35 37 protected EvaluationChannel() 36 38 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Drivers/EvaluationProcessChannel.cs
r3895 r4682 58 58 private EvaluationStreamChannel streamingChannel; 59 59 60 [StorableConstructor] 61 protected EvaluationProcessChannel(bool deserializing) : base(deserializing) { } 62 protected EvaluationProcessChannel(EvaluationProcessChannel original, Cloner cloner) 63 : base(original, cloner) { 64 executable = original.executable; 65 arguments = original.arguments; 66 } 67 public override IDeepCloneable Clone(Cloner cloner) { 68 return new EvaluationProcessChannel(this, cloner); 69 } 70 60 71 public EvaluationProcessChannel() : this(String.Empty, String.Empty) { } 61 72 public EvaluationProcessChannel(string executable, string arguments) … … 63 74 this.executable = executable; 64 75 this.arguments = arguments; 65 }66 67 public override IDeepCloneable Clone(Cloner cloner) {68 EvaluationProcessChannel clone = (EvaluationProcessChannel)base.Clone(cloner);69 clone.executable = executable;70 clone.arguments = arguments;71 return clone;72 76 } 73 77 … … 96 100 try { 97 101 streamingChannel.Send(message); 98 } catch { 102 } 103 catch { 99 104 Close(); 100 105 throw; … … 105 110 try { 106 111 return streamingChannel.Receive(builder); 107 } catch { 112 } 113 catch { 108 114 Close(); 109 115 throw; … … 121 127 process.WaitForExit(1000); 122 128 process.Close(); 123 } catch { } 129 } 130 catch { } 124 131 } 125 132 // for some reasons the event process_Exited does not fire -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Drivers/EvaluationServiceClient.cs
r4068 r4682 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 44 45 } 45 46 47 48 [StorableConstructor] 49 protected EvaluationServiceClient(bool deserializing) : base(deserializing) { } 50 protected EvaluationServiceClient(EvaluationServiceClient original, Cloner cloner) : base(original, cloner) { } 51 public override IDeepCloneable Clone(Cloner cloner) { 52 return new EvaluationServiceClient(this, cloner); 53 } 46 54 public EvaluationServiceClient() 47 55 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Drivers/EvaluationStreamChannel.cs
r3872 r4682 23 23 using System.IO; 24 24 using Google.ProtocolBuffers; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 33 34 private Stream input; 34 35 private Stream output; 36 37 [StorableConstructor] 38 protected EvaluationStreamChannel(bool deserializing) : base(deserializing) { } 39 protected EvaluationStreamChannel(EvaluationStreamChannel original, Cloner cloner) : base(original, cloner) { } 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new EvaluationStreamChannel(this, cloner); 42 } 35 43 36 44 public EvaluationStreamChannel() : base() { } -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/Drivers/EvaluationTCPChannel.cs
r3895 r4682 58 58 private Socket socket; 59 59 60 [StorableConstructor] 61 protected EvaluationTCPChannel(bool deserializing) : base(deserializing) { } 62 protected EvaluationTCPChannel(EvaluationTCPChannel original, Cloner cloner) 63 : base(original, cloner) { 64 ipAddress = original.ipAddress; 65 port = original.port; 66 } 67 public override IDeepCloneable Clone(Cloner cloner) { 68 return new EvaluationTCPChannel(this, cloner); 69 } 70 60 71 public EvaluationTCPChannel() : this(String.Empty, 0) { } 61 72 public EvaluationTCPChannel(string ip, int port) … … 63 74 this.ipAddress = ip; 64 75 this.port = port; 65 }66 67 public override IDeepCloneable Clone(Cloner cloner) {68 EvaluationTCPChannel clone = (EvaluationTCPChannel)base.Clone(cloner);69 clone.ipAddress = ipAddress;70 clone.port = port;71 return clone;72 76 } 73 77 … … 87 91 byte[] buffer = EncodeDelimited(message); 88 92 socket.Send(buffer); 89 } catch (SocketException) { 90 Close(); 91 throw; 92 } catch (ObjectDisposedException) { 93 } 94 catch (SocketException) { 95 Close(); 96 throw; 97 } 98 catch (ObjectDisposedException) { 93 99 socket = null; 94 100 Close(); … … 122 128 byte[] buffer = GetMessageBuffer(); 123 129 return builder.WeakMergeFrom(ByteString.CopyFrom(buffer)).WeakBuild(); 124 } catch (SocketException) { 125 Close(); 126 throw; 127 } catch (ObjectDisposedException) { 130 } 131 catch (SocketException) { 132 Close(); 133 throw; 134 } 135 catch (ObjectDisposedException) { 128 136 socket = null; 129 137 Close(); … … 164 172 socket.Disconnect(false); 165 173 socket.Close(); 166 } catch { } 174 } 175 catch { } 167 176 socket = null; 168 177 } -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/ExternalEvaluationProblem.cs
r4419 r4682 124 124 [StorableConstructor] 125 125 private ExternalEvaluationProblem(bool deserializing) : base(deserializing) { } 126 [StorableHook(HookType.AfterDeserialization)] 127 private void AfterDeserializationHook() { 128 AttachEventHandlers(); 129 } 130 131 private ExternalEvaluationProblem(ExternalEvaluationProblem original, Cloner cloner) 132 : base(original, cloner) { 133 AttachEventHandlers(); 134 } 135 public override IDeepCloneable Clone(Cloner cloner) { 136 return new ExternalEvaluationProblem(this, cloner); 137 } 126 138 public ExternalEvaluationProblem() 127 139 : base() { … … 141 153 } 142 154 143 public override IDeepCloneable Clone(Cloner cloner) {144 ExternalEvaluationProblem clone = (ExternalEvaluationProblem)base.Clone(cloner);145 clone.AttachEventHandlers();146 return clone;147 }148 149 155 #region Events 150 156 public event EventHandler SolutionCreatorChanged; … … 194 200 #endregion 195 201 196 #region Helpers 197 [StorableHook(HookType.AfterDeserialization)] 198 private void AfterDeserializationHook() { 199 AttachEventHandlers(); 200 } 201 202 #region Helper 202 203 private void AttachEventHandlers() { 203 204 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/ExternalEvaluator.cs
r3881 r4682 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 46 47 } 47 48 49 [StorableConstructor] 50 protected ExternalEvaluator(bool deserializing) : base(deserializing) { } 51 protected ExternalEvaluator(ExternalEvaluator original, Cloner cloner) : base(original, cloner) { } 52 public override IDeepCloneable Clone(Cloner cloner) { 53 return new ExternalEvaluator(this, cloner); 54 } 48 55 public ExternalEvaluator() 49 56 : base() { … … 64 71 try { 65 72 MessageBuilder.AddToMessage(value, name, protobufBuilder); 66 } catch (ArgumentException ex) { 73 } 74 catch (ArgumentException ex) { 67 75 throw new InvalidOperationException("ERROR in " + Name + ": Parameter " + name + " cannot be added to the message.", ex); 68 76 } -
branches/CloningRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.3/SolutionMessageBuilder.cs
r4643 r4682 50 50 [StorableConstructor] 51 51 protected SolutionMessageBuilder(bool deserializing) : base(deserializing) { } 52 [StorableHook(HookType.AfterDeserialization)] 53 private void AfterDeserialization() { 54 AttachEventHandlers(); 55 } 56 57 protected SolutionMessageBuilder(SolutionMessageBuilder original, Cloner cloner) 58 : base(original, cloner) { 59 convertersList = cloner.Clone(original.convertersList); 60 AttachEventHandlers(); 61 } 62 public override IDeepCloneable Clone(Cloner cloner) { 63 return new SolutionMessageBuilder(this, cloner); 64 } 52 65 public SolutionMessageBuilder() 53 66 : base() { … … 63 76 64 77 AttachEventHandlers(); 65 }66 67 public override IDeepCloneable Clone(Cloner cloner) {68 SolutionMessageBuilder clone = (SolutionMessageBuilder)base.Clone(cloner);69 clone.convertersList = (CheckedItemList<IItemToSolutionMessageConverter>)cloner.Clone(convertersList);70 clone.AttachEventHandlers();71 return clone;72 78 } 73 79 … … 87 93 } 88 94 89 [StorableHook(HookType.AfterDeserialization)]90 95 private void AttachEventHandlers() { 91 96 // BackwardsCompatibility3.3 92 97 #region Backwards compatible code, remove with 3.4 93 98 #pragma warning disable 0612 94 99 if (converters != null) { 95 100 if (convertersList == null) convertersList = new CheckedItemList<IItemToSolutionMessageConverter>(); … … 99 104 converters = null; 100 105 } 101 106 #pragma warning restore 0612 102 107 #endregion 103 108 convertersList.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IItemToSolutionMessageConverter>>(convertersList_Changed);
Note: See TracChangeset
for help on using the changeset viewer.