Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraint.cs @ 16886

Last change on this file since 16886 was 16886, checked in by chaider, 5 years ago

#2971 Added Storable-Attribues to IntervalConstraint

File size: 4.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2019 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
21using System;
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HEAL.Attic;
25
26namespace HeuristicLab.Problems.DataAnalysis {
27  [StorableType("8109BE58-CCFB-4462-A2F4-EEE5DFADAFF7")]
28  [Item("Interval Constraint", "Constraint on intervals.")]
29  public class IntervalConstraint : NamedItem {
30    private string expression;
31    [Storable]
32    public string Expression {
33      get => expression;
34      set {
35        if (value != expression) {
36          expression = value;
37          OnChanged(EventArgs.Empty);
38        }
39      }
40    }
41    private string definition;
42    [Storable]
43    public string Definition {
44      get => definition;
45      set {
46        if (value != definition) {
47          definition = value;
48          OnChanged(EventArgs.Empty);
49        }
50      }
51    }
52    [Storable]
53    public Interval Interval { get; set; }
54    private bool inclusiveLowerBound;
55    [Storable]
56    public bool InclusiveLowerBound {
57      get => inclusiveLowerBound;
58      set {
59        if (value != inclusiveLowerBound) {
60          inclusiveLowerBound = value;
61          OnChanged(EventArgs.Empty);
62        }
63      }
64    }
65    [Storable]
66    public bool InclusiveUpperBound { get; set; }
67    [Storable]
68    public bool IsDerivation { get; set; }
69
70    private string variable;
71    [Storable]
72    public string Variable {
73      get => variable;
74      set {
75        if (value != variable) {
76          variable = value;
77          OnChanged(EventArgs.Empty);
78        }
79      }
80    }
81
82    public int numberOfDerivation;
83    [Storable]
84    public int NumberOfDerivation {
85      get => numberOfDerivation;
86      set {
87        if (value != numberOfDerivation) {
88          numberOfDerivation = value;
89          OnChanged(EventArgs.Empty);
90        }
91      }
92    }
93
94    private bool enabled;
95    [Storable]
96    public bool Enabled {
97      get => enabled;
98      set {
99        if (value != enabled) {
100          enabled = value;
101          OnChanged(EventArgs.Empty);
102        }
103      }
104    }
105
106    [StorableConstructor]
107    protected IntervalConstraint(StorableConstructorFlag _) : base(_) { }
108
109    public IntervalConstraint(string expression, string definition, Interval interval, bool inclusiveLowerBound,
110      bool inclusiveUpperBound, bool isDerivation, string variable, int numberOfDerivation, bool isChecked) {
111      base.name = expression;
112      Expression = expression;
113      Definition = definition;
114      Interval = interval;
115      InclusiveLowerBound = inclusiveLowerBound;
116      InclusiveUpperBound = inclusiveUpperBound;
117      IsDerivation = isDerivation;
118      Variable = variable;
119      NumberOfDerivation = numberOfDerivation;
120      enabled = isChecked;
121    }
122
123    public override IDeepCloneable Clone(Cloner cloner) {
124      return new IntervalConstraint(this, cloner);
125    }
126
127    protected IntervalConstraint(IntervalConstraint original, Cloner cloner)
128      : base(original, cloner) {
129      this.Expression = original.Expression;
130      this.Definition = original.Definition;
131      this.Interval = original.Interval;
132      this.InclusiveLowerBound = original.InclusiveLowerBound;
133      this.InclusiveUpperBound = original.InclusiveUpperBound;
134      this.IsDerivation = original.IsDerivation;
135      this.Variable = original.Variable;
136      this.NumberOfDerivation = original.NumberOfDerivation;
137      this.enabled = original.enabled;
138    }
139
140    public event EventHandler Changed;
141    protected virtual void OnChanged(EventArgs e) {
142      EventHandler handlers = Changed;
143      if (handlers != null)
144        handlers(this, e);
145    }
146  }
147}
Note: See TracBrowser for help on using the repository browser.