Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.SolutionCaching/3.3/RunCollectionModifiers/RunCollectionModifierTask.cs @ 10119

Last change on this file since 10119 was 10119, checked in by ascheibe, 11 years ago

#1886 improved RealVectorConvexHullModifier

File size: 5.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Clients.Hive;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Analysis.SolutionCaching {
29  [Item("RunCollectionModifierTask", "Represents task which executes a RunCollectionModifierExecutable.")]
30  [StorableClass]
31  public class RunCollectionModifierTask : ItemTask {
32    public new RunCollectionModifierExecutable Item {
33      get { return (RunCollectionModifierExecutable)base.Item; }
34      set { base.Item = value; }
35    }
36
37    #region Constructors and Cloning
38    public RunCollectionModifierTask(RunCollectionModifierExecutable executable)
39      : base() {
40      Item = executable;
41    }
42    [StorableConstructor]
43    protected RunCollectionModifierTask(bool deserializing) { }
44    protected RunCollectionModifierTask(RunCollectionModifierTask original, Cloner cloner)
45      : base(original, cloner) {
46    }
47    public override IDeepCloneable Clone(Cloner cloner) {
48      return new RunCollectionModifierTask(this, cloner);
49    }
50    #endregion
51
52    public override bool CanChangeDescription {
53      get {
54        if (Item == null)
55          return false;
56        else
57          return Item.CanChangeDescription;
58      }
59    }
60
61    public override bool CanChangeName {
62      get {
63        if (Item == null)
64          return false;
65        else
66          return Item.CanChangeName;
67      }
68    }
69
70    public override string Description {
71      get {
72        if (Item == null)
73          return string.Empty;
74        else
75          return Item.Description;
76      }
77      set { Item.Description = value; }
78    }
79
80    public override string Name {
81      get {
82        if (Item == null)
83          return "RunCollectionModifierTask";
84        else
85          return Item.Name;
86      }
87      set { Item.Name = value; }
88    }
89
90    public override ExecutionState ExecutionState {
91      get { return Item.ExecutionState; }
92    }
93
94    public override TimeSpan ExecutionTime {
95      get { return Item.ExecutionTime; }
96    }
97
98    public override void Pause() {
99      Item.Pause();
100    }
101
102    public override void Prepare() {
103      Item.Prepare();
104    }
105
106    public override void Start() {
107      Item.Start();
108    }
109
110    public override void Stop() {
111      Item.Stop();
112    }
113
114    protected override void RegisterItemEvents() {
115      base.RegisterItemEvents();
116      Item.Stopped += new EventHandler(executable_Stopped);
117      Item.Paused += new EventHandler(executable_Paused);
118      Item.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(executable_ExceptionOccurred);
119      Item.DescriptionChanged += new EventHandler(executable_DescriptionChanged);
120      Item.NameChanged += new EventHandler(executable_NameChanged);
121      Item.NameChanging += new EventHandler<CancelEventArgs<string>>(executable_NameChanging);
122      Item.ExecutionStateChanged += new EventHandler(executable_ExecutionStateChanged);
123      Item.ExecutionTimeChanged += new EventHandler(executable_ExecutionTimeChanged);
124      Item.Started += new EventHandler(executable_Started);
125    }
126
127    protected virtual void DeregisterOptimizerEvents() {
128      Item.Stopped -= new EventHandler(executable_Stopped);
129      Item.Paused -= new EventHandler(executable_Paused);
130      Item.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(executable_ExceptionOccurred);
131      Item.DescriptionChanged -= new EventHandler(executable_DescriptionChanged);
132      Item.NameChanged -= new EventHandler(executable_NameChanged);
133      Item.NameChanging -= new EventHandler<CancelEventArgs<string>>(executable_NameChanging);
134      Item.ExecutionStateChanged -= new EventHandler(executable_ExecutionStateChanged);
135      Item.ExecutionTimeChanged -= new EventHandler(executable_ExecutionTimeChanged);
136      Item.Started -= new EventHandler(executable_Started);
137      base.DeregisterItemEvents();
138    }
139
140    protected void executable_NameChanging(object sender, CancelEventArgs<string> e) {
141      OnNameChanging(new CancelEventArgs<string>(e.Value, e.Cancel));
142    }
143
144    protected void executable_NameChanged(object sender, EventArgs e) {
145      this.OnNameChanged();
146    }
147
148    protected void executable_DescriptionChanged(object sender, EventArgs e) {
149      OnDescriptionChanged();
150    }
151
152    protected virtual void executable_ExceptionOccurred(object sender, EventArgs<Exception> e) {
153      OnTaskFailed(e);
154    }
155
156    protected virtual void executable_Started(object sender, EventArgs e) {
157      OnTaskStarted();
158    }
159
160    protected virtual void executable_Stopped(object sender, EventArgs e) {
161      OnTaskStopped();
162    }
163
164    protected virtual void executable_Paused(object sender, EventArgs e) {
165      OnTaskPaused();
166    }
167
168    protected virtual void executable_ExecutionTimeChanged(object sender, EventArgs e) {
169      OnExecutionTimeChanged();
170    }
171
172    protected virtual void executable_ExecutionStateChanged(object sender, EventArgs e) {
173      OnExecutionStateChanged();
174    }
175  }
176}
Note: See TracBrowser for help on using the repository browser.