Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/19/11 13:52:12 (13 years ago)
Author:
mkommend
Message:

#1532:

  • Enabled renaming of symbols
  • Fixed cloning of grammers
  • Added readonly attribute in grammars to lock grammars during the algorithm run
  • Removed useless clone method in cloner
  • Changed CheckedItemCollectionViews to enable scrolling during the locked state
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs

    r5809 r6233  
    2020#endregion
    2121
    22 using System.Linq;
     22using System;
    2323using HeuristicLab.Common;
     24using HeuristicLab.Core;
    2425using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2526
     
    2829  public abstract class SymbolicExpressionGrammar : SymbolicExpressionGrammarBase, ISymbolicExpressionGrammar {
    2930    #region fields & properties
     31    [Storable(DefaultValue = false)]
     32    private bool readOnly;
     33    public bool ReadOnly {
     34      get { return readOnly; }
     35      set {
     36        if (readOnly != value) {
     37          readOnly = value;
     38          OnReadOnlyChanged();
     39        }
     40      }
     41    }
     42
    3043    [Storable]
    3144    private int minimumFunctionDefinitions;
     
    102115    protected SymbolicExpressionGrammar(SymbolicExpressionGrammar original, Cloner cloner)
    103116      : base(original, cloner) {
    104       programRootSymbol = (ProgramRootSymbol)cloner.Clone(original.programRootSymbol);
    105       startSymbol = (StartSymbol)cloner.Clone(original.StartSymbol);
    106       defunSymbol = (Defun)cloner.Clone(original.defunSymbol);
    107       symbols = original.symbols
    108         .ToDictionary(x => x.Key, y => (ISymbol)cloner.Clone(y.Value));
     117      programRootSymbol = cloner.Clone(original.programRootSymbol);
     118      startSymbol = cloner.Clone(original.StartSymbol);
     119      defunSymbol = cloner.Clone(original.defunSymbol);
     120
    109121      maximumFunctionArguments = original.maximumFunctionArguments;
    110122      minimumFunctionArguments = original.minimumFunctionArguments;
     
    140152      }
    141153    }
     154
     155    public event EventHandler ReadOnlyChanged;
     156    protected virtual void OnReadOnlyChanged() {
     157      var handler = ReadOnlyChanged;
     158      if (handler != null)
     159        handler(this, EventArgs.Empty);
     160    }
     161
     162    #region IStatefulItem
     163    void IStatefulItem.InitializeState() { }
     164    void IStatefulItem.ClearState() {
     165      ReadOnly = false;
     166    }
     167    #endregion
    142168  }
    143169}
Note: See TracChangeset for help on using the changeset viewer.