- Timestamp:
- 04/19/11 18:58:53 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/EngineJob.cs
r6000 r6033 9 9 namespace HeuristicLab.HiveEngine { 10 10 [StorableClass] 11 public class EngineJob : AbstractJob { 12 [Storable] 13 private IEngine engine; 14 11 public class EngineJob : ItemJob { 15 12 [Storable] 16 13 protected IOperation initialOperation; … … 20 17 } 21 18 19 public new IEngine Item { 20 get { return (IEngine)base.Item; } 21 set { base.Item = value; } 22 } 23 22 24 public override TimeSpan ExecutionTime { 23 get { return engine.ExecutionTime; }25 get { return Item.ExecutionTime; } 24 26 } 25 27 26 28 public override ExecutionState ExecutionState { 27 get { return engine.ExecutionState; }29 get { return Item.ExecutionState; } 28 30 } 29 31 … … 32 34 public EngineJob(IOperation initialOperation, IEngine engine) { 33 35 this.initialOperation = initialOperation; 34 this.engine = engine; 35 RegisterEngineEvents(); 36 this.Item = engine; 36 37 } 37 38 … … 40 41 protected EngineJob(EngineJob original, Cloner cloner) 41 42 : base(original, cloner) { 42 this.engine = cloner.Clone(original.engine);43 43 this.initialOperation = cloner.Clone(original.initialOperation); 44 RegisterEngineEvents();45 44 } 46 45 public override IDeepCloneable Clone(Cloner cloner) { 47 46 return new EngineJob(this, cloner); 48 }49 [StorableHook(HookType.AfterDeserialization)]50 private void AfterDeserialization() {51 RegisterEngineEvents();52 47 } 53 48 #endregion … … 60 55 61 56 public override void Start() { 62 engine.Prepare(initialOperation);63 engine.Start();57 Item.Prepare(initialOperation); 58 Item.Start(); 64 59 } 65 60 66 61 public override void Pause() { 67 engine.Pause();62 Item.Pause(); 68 63 } 69 64 70 65 public override void Stop() { 71 engine.Stop();66 Item.Stop(); 72 67 } 73 68 … … 76 71 } 77 72 78 private void RegisterEngineEvents() { 79 engine.Stopped += new EventHandler(engine_Stopped); 80 engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred); 73 protected override void RegisterItemEvents() { 74 Item.Stopped += new EventHandler(engine_Stopped); 75 Item.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred); 76 } 77 78 protected override void DeregisterItemEvents() { 79 Item.Stopped -= new EventHandler(engine_Stopped); 80 Item.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred); 81 81 } 82 82 … … 103 103 104 104 public override string Name { 105 get { return engine.ToString(); }105 get { return Item.ToString(); } 106 106 set { throw new NotSupportedException(); } 107 107 }
Note: See TracChangeset
for help on using the changeset viewer.