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.Core/3.3/Engine.cs

    r4477 r4722  
    4646    private System.Timers.Timer timer;
    4747
     48    [StorableConstructor]
     49    protected Engine(bool deserializing)
     50      : base(deserializing) {
     51      pausePending = stopPending = false;
     52      timer = new System.Timers.Timer(100);
     53      timer.AutoReset = true;
     54      timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
     55    }
     56    protected Engine(Engine original, Cloner cloner)
     57      : base(original, cloner) {
     58      if (original.ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));
     59      log = cloner.Clone(original.log);
     60      executionStack = new Stack<IOperation>();
     61      IOperation[] contexts = original.executionStack.ToArray();
     62      for (int i = contexts.Length - 1; i >= 0; i--)
     63        executionStack.Push(cloner.Clone(contexts[i]));
     64      pausePending = original.pausePending;
     65      stopPending = original.stopPending;
     66      timer = new System.Timers.Timer(100);
     67      timer.AutoReset = true;
     68      timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
     69    }
    4870    protected Engine()
    4971      : base() {
     
    5476      timer.AutoReset = true;
    5577      timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    56     }
    57     [StorableConstructor]
    58     protected Engine(bool deserializing)
    59       : base(deserializing) {
    60       pausePending = stopPending = false;
    61       timer = new System.Timers.Timer(100);
    62       timer.AutoReset = true;
    63       timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    64     }
    65 
    66     public override IDeepCloneable Clone(Cloner cloner) {
    67       if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));
    68       Engine clone = (Engine)base.Clone(cloner);
    69       clone.log = (ILog)cloner.Clone(log);
    70       IOperation[] contexts = executionStack.ToArray();
    71       for (int i = contexts.Length - 1; i >= 0; i--)
    72         clone.executionStack.Push((IOperation)cloner.Clone(contexts[i]));
    73       clone.pausePending = pausePending;
    74       clone.stopPending = stopPending;
    75       return clone;
    7678    }
    7779
Note: See TracChangeset for help on using the changeset viewer.