Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs @ 11194

Last change on this file since 11194 was 11171, checked in by ascheibe, 10 years ago

#2115 merged r11170 (copyright update) into trunk

File size: 3.9 KB
RevLine 
[6475]1#region License Information
2/* HeuristicLab
[11171]3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[6475]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
[8886]22using System.ComponentModel;
[6475]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]
[8886]31  public class Task : Item, INotifyPropertyChanged {
[8887]32
[8886]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;
[10433]40        if (changed) {
41          OnPropertyChanged("TaskNr");
42          OnToStringChanged();
43        }
[8886]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;
[10433]53        if (changed) {
54          OnPropertyChanged("ResourceNr");
55          OnToStringChanged();
56        }
[8886]57      }
58    }
[6475]59
[8886]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
[6475]93    [StorableConstructor]
94    protected Task(bool deserializing) : base(deserializing) { }
95    protected Task(Task original, Cloner cloner)
96      : base(original, cloner) {
[10476]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;
[6475]102    }
[8887]103    public Task() : this(-1, -1, -1, 0) { }
[6475]104    public Task(int taskNr, int resNr, int jobNr, double duration)
105      : base() {
[10476]106      this.duration = duration;
107      this.resourceNr = resNr;
108      this.jobNr = jobNr;
109      this.taskNr = taskNr;
110      this.isScheduled = false;
[6475]111    }
112
[8887]113    public override IDeepCloneable Clone(Cloner cloner) {
114      return new Task(this, cloner);
115    }
116
[6475]117    public override string ToString() {
118      StringBuilder sb = new StringBuilder();
119      sb.Append("[" + TaskNr + "," + ResourceNr + "]");
120      return sb.ToString();
121    }
122
[8886]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    }
[6475]128  }
129}
Note: See TracBrowser for help on using the repository browser.