Ignore:
Timestamp:
10/29/10 19:02:32 (9 years ago)
Author:
mkommend
Message:

Refactored ArtificialAntProble (ticket #922).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/AntTrail.cs

    r4068 r4676  
    8989      Initialize();
    9090    }
     91
    9192    [StorableConstructor]
    9293    private AntTrail(bool deserializing) : base(deserializing) { }
     94    [StorableHook(HookType.AfterDeserialization)]
     95    private void AfterDeserialization() {
     96      Initialize();
     97    }
     98    private AntTrail(AntTrail original, Cloner cloner)
     99      : base(original, cloner) {
     100      expression = cloner.Clone(original.expression);
     101      world = cloner.Clone(original.world);
     102      maxTimeSteps = cloner.Clone(original.maxTimeSteps);
     103      Initialize();
     104    }
     105    public override IDeepCloneable Clone(Cloner cloner) {
     106      return new AntTrail(this, cloner);
     107    }
    93108
    94     [StorableHook(HookType.AfterDeserialization)]
    95109    private void Initialize() {
    96110      //if (expression != null) RegisterSymbolicExpressionTreeEvents();
     
    99113    }
    100114
    101     public override IDeepCloneable Clone(Cloner cloner) {
    102       AntTrail clone = new AntTrail();
    103       cloner.RegisterClonedObject(this, clone);
    104       clone.expression = (SymbolicExpressionTree)cloner.Clone(expression);
    105       clone.world = (BoolMatrix)cloner.Clone(world);
    106       clone.maxTimeSteps = (IntValue)cloner.Clone(maxTimeSteps);
    107       clone.Initialize();
    108       return clone;
    109     }
    110 
    111115    #region Events
    112116    public event EventHandler SymbolicExpressionTreeChanged;
    113117    private void OnSymbolicExpressionTreeChanged() {
    114118      var changed = SymbolicExpressionTreeChanged;
    115       if (changed != null)
    116         changed(this, EventArgs.Empty);
     119      if (changed != null) changed(this, EventArgs.Empty);
    117120    }
    118121    public event EventHandler WorldChanged;
    119122    private void OnWorldChanged() {
    120123      var changed = WorldChanged;
    121       if (changed != null)
    122         changed(this, EventArgs.Empty);
     124      if (changed != null) changed(this, EventArgs.Empty);
    123125    }
    124126    public event EventHandler MaxTimeStepsChanged;
    125127    private void OnMaxTimeStepsChanged() {
    126128      var changed = MaxTimeStepsChanged;
    127       if (changed != null)
    128         changed(this, EventArgs.Empty);
     129      if (changed != null) changed(this, EventArgs.Empty);
    129130    }
    130131
Note: See TracChangeset for help on using the changeset viewer.