Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs @ 15967

Last change on this file since 15967 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 3.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.ComponentModel;
23using System.Text;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Encodings.ScheduleEncoding {
29  [Item("Task", "Represents a task that has to be scheduled.")]
30  [StorableClass]
31  public class Task : Item, INotifyPropertyChanged {
32
33    [Storable(Name = "TaskNr")]
34    private int taskNr;
35    public int TaskNr {
36      get { return taskNr; }
37      set {
38        bool changed = taskNr != value;
39        taskNr = value;
40        if (changed) {
41          OnPropertyChanged("TaskNr");
42          OnToStringChanged();
43        }
44      }
45    }
46    [Storable(Name = "ResourceNr")]
47    private int resourceNr;
48    public int ResourceNr {
49      get { return resourceNr; }
50      set {
51        bool changed = resourceNr != value;
52        resourceNr = value;
53        if (changed) {
54          OnPropertyChanged("ResourceNr");
55          OnToStringChanged();
56        }
57      }
58    }
59
60    [Storable(Name = "JobNr")]
61    private int jobNr;
62    public int JobNr {
63      get { return jobNr; }
64      set {
65        bool changed = jobNr != value;
66        jobNr = value;
67        if (changed) OnPropertyChanged("JobNr");
68      }
69    }
70
71    [Storable(Name = "Duration")]
72    private double duration;
73    public double Duration {
74      get { return duration; }
75      set {
76        bool changed = duration != value;
77        duration = value;
78        if (changed) OnPropertyChanged("Duration");
79      }
80    }
81
82    [Storable(Name = "IsScheduled")]
83    private bool isScheduled;
84    public bool IsScheduled {
85      get { return isScheduled; }
86      set {
87        bool changed = isScheduled != value;
88        isScheduled = value;
89        if (changed) OnPropertyChanged("IsScheduled");
90      }
91    }
92
93    [StorableConstructor]
94    protected Task(bool deserializing) : base(deserializing) { }
95    protected Task(Task original, Cloner cloner)
96      : base(original, cloner) {
97      this.resourceNr = original.ResourceNr;
98      this.jobNr = original.JobNr;
99      this.duration = original.Duration;
100      this.taskNr = original.TaskNr;
101      this.isScheduled = original.IsScheduled;
102    }
103    public Task() : this(-1, -1, -1, 0) { }
104    public Task(int taskNr, int resNr, int jobNr, double duration)
105      : base() {
106      this.duration = duration;
107      this.resourceNr = resNr;
108      this.jobNr = jobNr;
109      this.taskNr = taskNr;
110      this.isScheduled = false;
111    }
112
113    public override IDeepCloneable Clone(Cloner cloner) {
114      return new Task(this, cloner);
115    }
116
117    public override string ToString() {
118      StringBuilder sb = new StringBuilder();
119      sb.Append("[" + TaskNr + "," + ResourceNr + "]");
120      return sb.ToString();
121    }
122
123    public event PropertyChangedEventHandler PropertyChanged;
124    protected virtual void OnPropertyChanged(string propertyName) {
125      var handler = PropertyChanged;
126      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
127    }
128  }
129}
Note: See TracBrowser for help on using the repository browser.