Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (13 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs

    r4533 r4722  
    167167      stopPending = false;
    168168    }
    169 
    170169    [StorableHook(HookType.AfterDeserialization)]
     170    private void AfterDeserialization() {
     171      Initialize();
     172    }
     173
     174    private BatchRun(BatchRun original, Cloner cloner)
     175      : base(original, cloner) {
     176      executionState = original.executionState;
     177      executionTime = original.executionTime;
     178      algorithm = cloner.Clone(original.algorithm);
     179      repetitions = original.repetitions;
     180      repetitionsCounter = original.repetitionsCounter;
     181      runs = cloner.Clone(original.runs);
     182      stopPending = original.stopPending;
     183      Initialize();
     184    }
     185    public override IDeepCloneable Clone(Cloner cloner) {
     186      if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));
     187      return new BatchRun(this, cloner);
     188    }
     189
    171190    private void Initialize() {
    172191      if (algorithm != null) RegisterAlgorithmEvents();
    173192      if (runs != null) RegisterRunsEvents();
    174     }
    175 
    176     public override IDeepCloneable Clone(Cloner cloner) {
    177       if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));
    178       BatchRun clone = (BatchRun)base.Clone(cloner);
    179       clone.executionState = executionState;
    180       clone.executionTime = executionTime;
    181       clone.algorithm = (IAlgorithm)cloner.Clone(algorithm);
    182       clone.repetitions = repetitions;
    183       clone.repetitionsCounter = repetitionsCounter;
    184       clone.runs = (RunCollection)cloner.Clone(runs);
    185       clone.stopPending = stopPending;
    186       clone.Initialize();
    187       return clone;
    188193    }
    189194
Note: See TracChangeset for help on using the changeset viewer.