Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/19 15:38:16 (5 years ago)
Author:
gkronber
Message:

#2994: merged r16839:16910 from trunk to branch

Location:
branches/2994-AutoDiffForIntervals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals

  • branches/2994-AutoDiffForIntervals/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs

    r16565 r16911  
    2222using System;
    2323using System.Drawing;
     24using HEAL.Attic;
    2425using HeuristicLab.Collections;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    27 using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Parameters {
     
    4040      }
    4141    }
    42      
     42
    4343    [Storable]
    4444    private ItemSet<T> validValues;
     
    5252      get { return this.value; }
    5353      set {
     54        if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter.");
    5455        if (value != this.value) {
    5556          if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value.");
     
    7475    }
    7576
     77    [Storable(DefaultValue = false)]
     78    private bool readOnly;
     79    public bool ReadOnly {
     80      get { return readOnly; }
     81      set {
     82        if (value == readOnly) return;
     83        readOnly = value;
     84        OnReadOnlyChanged();
     85      }
     86    }
     87
    7688    [Storable(DefaultValue = true)]
    7789    private bool getsCollected;
     
    93105      validValues = cloner.Clone(original.validValues);
    94106      value = cloner.Clone(original.value);
     107      readOnly = original.readOnly;
    95108      getsCollected = original.getsCollected;
    96109      Initialize();
     
    99112      : base("Anonymous", typeof(T)) {
    100113      this.validValues = new ItemSet<T>();
     114      this.readOnly = false;
    101115      this.getsCollected = true;
    102116      Initialize();
     
    105119      : base(name, typeof(T)) {
    106120      this.validValues = new ItemSet<T>();
    107       this.getsCollected = true;
    108       Initialize();
    109     }
    110     public OptionalConstrainedValueParameter(string name, bool getsCollected)
    111       : base(name, typeof(T)) {
    112       this.validValues = new ItemSet<T>();
    113       this.getsCollected = getsCollected;
     121      this.readOnly = false;
     122      this.getsCollected = true;
    114123      Initialize();
    115124    }
     
    117126      : base(name, typeof(T)) {
    118127      this.validValues = validValues;
    119       this.getsCollected = true;
    120       Initialize();
    121     }
    122     public OptionalConstrainedValueParameter(string name, ItemSet<T> validValues, bool getsCollected)
    123       : base(name, typeof(T)) {
    124       this.validValues = validValues;
    125       this.getsCollected = getsCollected;
     128      this.readOnly = false;
     129      this.getsCollected = true;
    126130      Initialize();
    127131    }
     
    130134      this.validValues = validValues;
    131135      this.value = value;
    132       this.getsCollected = true;
    133       Initialize();
    134     }
    135     public OptionalConstrainedValueParameter(string name, ItemSet<T> validValues, T value, bool getsCollected)
    136       : base(name, typeof(T)) {
    137       this.validValues = validValues;
    138       this.value = value;
    139       this.getsCollected = getsCollected;
     136      this.readOnly = false;
     137      this.getsCollected = true;
    140138      Initialize();
    141139    }
     
    143141      : base(name, description, typeof(T)) {
    144142      this.validValues = new ItemSet<T>();
    145       this.getsCollected = true;
    146       Initialize();
    147     }
    148     public OptionalConstrainedValueParameter(string name, string description, bool getsCollected)
    149       : base(name, description, typeof(T)) {
    150       this.validValues = new ItemSet<T>();
    151       this.getsCollected = getsCollected;
     143      this.readOnly = false;
     144      this.getsCollected = true;
    152145      Initialize();
    153146    }
     
    155148      : base(name, description, typeof(T)) {
    156149      this.validValues = validValues;
    157       this.getsCollected = true;
    158       Initialize();
    159     }
    160     public OptionalConstrainedValueParameter(string name, string description, ItemSet<T> validValues, bool getsCollected)
    161       : base(name, description, typeof(T)) {
    162       this.validValues = validValues;
    163       this.getsCollected = getsCollected;
     150      this.readOnly = false;
     151      this.getsCollected = true;
    164152      Initialize();
    165153    }
     
    168156      this.validValues = validValues;
    169157      this.value = value;
    170       this.getsCollected = true;
    171       Initialize();
    172     }
    173     public OptionalConstrainedValueParameter(string name, string description, ItemSet<T> validValues, T value, bool getsCollected)
    174       : base(name, description, typeof(T)) {
    175       this.validValues = validValues;
    176       this.value = value;
    177       this.getsCollected = getsCollected;
     158      this.readOnly = false;
     159      this.getsCollected = true;
    178160      Initialize();
    179161    }
     
    212194      OnToStringChanged();
    213195    }
     196    public event EventHandler ReadOnlyChanged;
     197    protected virtual void OnReadOnlyChanged() {
     198      EventHandler handler = ReadOnlyChanged;
     199      if (handler != null) handler(this, EventArgs.Empty);
     200    }
    214201    public event EventHandler GetsCollectedChanged;
    215202    protected virtual void OnGetsCollectedChanged() {
Note: See TracChangeset for help on using the changeset viewer.