Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/29/19 15:00:56 (5 years ago)
Author:
mkommend
Message:

#3005: Added readonly flag to all value parameters.

Location:
trunk/HeuristicLab.Parameters/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs

    r16565 r16872  
    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>();
     121      this.readOnly = false;
    107122      this.getsCollected = true;
    108123      Initialize();
     
    111126      : base(name, typeof(T)) {
    112127      this.validValues = new ItemSet<T>();
     128      this.readOnly = false;
    113129      this.getsCollected = getsCollected;
    114130      Initialize();
     
    117133      : base(name, typeof(T)) {
    118134      this.validValues = validValues;
     135      this.readOnly = false;
    119136      this.getsCollected = true;
    120137      Initialize();
     
    123140      : base(name, typeof(T)) {
    124141      this.validValues = validValues;
     142      this.readOnly = false;
    125143      this.getsCollected = getsCollected;
    126144      Initialize();
     
    130148      this.validValues = validValues;
    131149      this.value = value;
     150      this.readOnly = false;
    132151      this.getsCollected = true;
    133152      Initialize();
     
    137156      this.validValues = validValues;
    138157      this.value = value;
     158      this.readOnly = false;
    139159      this.getsCollected = getsCollected;
    140160      Initialize();
     
    143163      : base(name, description, typeof(T)) {
    144164      this.validValues = new ItemSet<T>();
     165      this.readOnly = false;
    145166      this.getsCollected = true;
    146167      Initialize();
     
    149170      : base(name, description, typeof(T)) {
    150171      this.validValues = new ItemSet<T>();
     172      this.readOnly = false;
    151173      this.getsCollected = getsCollected;
    152174      Initialize();
     
    155177      : base(name, description, typeof(T)) {
    156178      this.validValues = validValues;
     179      this.readOnly = false;
    157180      this.getsCollected = true;
    158181      Initialize();
     
    161184      : base(name, description, typeof(T)) {
    162185      this.validValues = validValues;
     186      this.readOnly = false;
    163187      this.getsCollected = getsCollected;
    164188      Initialize();
     
    168192      this.validValues = validValues;
    169193      this.value = value;
     194      this.readOnly = false;
    170195      this.getsCollected = true;
    171196      Initialize();
     
    175200      this.validValues = validValues;
    176201      this.value = value;
     202      this.readOnly = false;
    177203      this.getsCollected = getsCollected;
    178204      Initialize();
     
    212238      OnToStringChanged();
    213239    }
     240    public event EventHandler ReadOnlyChanged;
     241    protected virtual void OnReadOnlyChanged() {
     242      EventHandler handler = ReadOnlyChanged;
     243      if (handler != null) handler(this, EventArgs.Empty);
     244    }
    214245    public event EventHandler GetsCollectedChanged;
    215246    protected virtual void OnGetsCollectedChanged() {
  • trunk/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs

    r16565 r16872  
    2222using System;
    2323using System.Drawing;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    26 using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Parameters {
     
    4545      get { return this.value; }
    4646      set {
     47        if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter.");
    4748        if (value != this.value) {
    4849          DeregisterValueEvents();
     
    6364          );
    6465        Value = val;
     66      }
     67    }
     68
     69    [Storable(DefaultValue = false)]
     70    private bool readOnly;
     71    public bool ReadOnly {
     72      get { return readOnly; }
     73      set {
     74        if (value == readOnly) return;
     75        readOnly = value;
     76        OnReadOnlyChanged();
    6577      }
    6678    }
     
    108120      : base(original, cloner) {
    109121      value = cloner.Clone(original.value);
     122      readOnly = original.readOnly;
    110123      getsCollected = original.getsCollected;
    111124      reactOnValueToStringChangedAndValueItemImageChanged = original.reactOnValueToStringChangedAndValueItemImageChanged;
     
    114127    public OptionalValueParameter()
    115128      : base("Anonymous", typeof(T)) {
     129      this.readOnly = false;
    116130      this.getsCollected = true;
    117131      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    119133    public OptionalValueParameter(string name)
    120134      : base(name, typeof(T)) {
     135      this.readOnly = false;
    121136      this.getsCollected = true;
    122137      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    124139    public OptionalValueParameter(string name, bool getsCollected)
    125140      : base(name, typeof(T)) {
     141      this.readOnly = false;
    126142      this.getsCollected = getsCollected;
    127143      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    130146      : base(name, typeof(T)) {
    131147      this.value = value;
     148      this.readOnly = false;
    132149      this.getsCollected = true;
    133150      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    137154      : base(name, typeof(T)) {
    138155      this.value = value;
     156      this.readOnly = false;
    139157      this.getsCollected = getsCollected;
    140158      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    143161    public OptionalValueParameter(string name, string description)
    144162      : base(name, description, typeof(T)) {
     163      this.readOnly = false;
    145164      this.getsCollected = true;
    146165      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    148167    public OptionalValueParameter(string name, string description, bool getsCollected)
    149168      : base(name, description, typeof(T)) {
     169      this.readOnly = false;
    150170      this.getsCollected = getsCollected;
    151171      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    154174      : base(name, description, typeof(T)) {
    155175      this.value = value;
     176      this.readOnly = false;
    156177      this.getsCollected = true;
    157178      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    161182      : base(name, description, typeof(T)) {
    162183      this.value = value;
     184      this.readOnly = false;
    163185      this.getsCollected = getsCollected;
    164186      this.reactOnValueToStringChangedAndValueItemImageChanged = true;
     
    197219      OnToStringChanged();
    198220    }
     221
     222    public event EventHandler ReadOnlyChanged;
     223    protected virtual void OnReadOnlyChanged() {
     224      EventHandler handler = ReadOnlyChanged;
     225      if (handler != null) handler(this, EventArgs.Empty);
     226    }
    199227    public event EventHandler GetsCollectedChanged;
    200228    protected virtual void OnGetsCollectedChanged() {
  • trunk/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs

    r16565 r16872  
    2222using System;
    2323using System.Drawing;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    26 using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Parameters {
     
    4545      get { return this.value; }
    4646      set {
     47        if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter.");
    4748        if (value != this.value) {
    4849          DeregisterValueEvents();
     
    6667    }
    6768
     69    [Storable(DefaultValue = false)]
     70    private bool readOnly;
     71    public bool ReadOnly {
     72      get { return readOnly; }
     73      set {
     74        if (value == readOnly) return;
     75        readOnly = value;
     76        OnReadOnlyChanged();
     77      }
     78    }
     79
    6880    [Storable(DefaultValue = true)]
    6981    private bool getsCollected;
     
    8496      : base(original, cloner) {
    8597      value = cloner.Clone(original.value);
     98      readOnly = original.readOnly;
    8699      getsCollected = original.getsCollected;
    87100      RegisterValueEvents();
     
    89102    public ValueLookupParameter()
    90103      : base() {
     104      this.readOnly = false;
    91105      this.Hidden = false;
    92106      this.getsCollected = true;
     
    94108    public ValueLookupParameter(string name)
    95109      : base(name) {
     110      this.readOnly = false;
    96111      this.Hidden = false;
    97112      this.getsCollected = true;
     
    99114    public ValueLookupParameter(string name, bool getsCollected)
    100115      : base(name) {
     116      this.readOnly = false;
    101117      this.Hidden = false;
    102118      this.getsCollected = getsCollected;
     
    105121      : base(name) {
    106122      this.value = value;
     123      this.readOnly = false;
    107124      this.Hidden = false;
    108125      this.getsCollected = true;
     
    112129      : base(name) {
    113130      this.value = value;
     131      this.readOnly = false;
    114132      this.Hidden = false;
    115133      this.getsCollected = getsCollected;
     
    118136    public ValueLookupParameter(string name, string description)
    119137      : base(name, description) {
     138      this.readOnly = false;
    120139      this.Hidden = false;
    121140      this.getsCollected = true;
     
    123142    public ValueLookupParameter(string name, string description, bool getsCollected)
    124143      : base(name, description) {
     144      this.readOnly = false;
    125145      this.Hidden = false;
    126146      this.getsCollected = getsCollected;
     
    129149      : base(name, description) {
    130150      this.value = value;
     151      this.readOnly = false;
    131152      this.Hidden = false;
    132153      this.getsCollected = true;
     
    136157      : base(name, description) {
    137158      this.value = value;
     159      this.readOnly = false;
    138160      this.Hidden = false;
    139161      this.getsCollected = getsCollected;
     
    142164    public ValueLookupParameter(string name, string description, string actualName)
    143165      : base(name, description, actualName) {
     166      this.readOnly = false;
    144167      this.Hidden = false;
    145168      this.getsCollected = true;
     
    147170    public ValueLookupParameter(string name, string description, string actualName, bool getsCollected)
    148171      : base(name, description, actualName) {
     172      this.readOnly = false;
    149173      this.Hidden = false;
    150174      this.getsCollected = getsCollected;
     
    177201      OnToStringChanged();
    178202    }
     203    public event EventHandler ReadOnlyChanged;
     204    protected virtual void OnReadOnlyChanged() {
     205      EventHandler handler = ReadOnlyChanged;
     206      if (handler != null) handler(this, EventArgs.Empty);
     207    }
    179208    public event EventHandler GetsCollectedChanged;
    180209    protected virtual void OnGetsCollectedChanged() {
Note: See TracChangeset for help on using the changeset viewer.