Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DebugEngine/OperatorTrace.cs @ 4995

Last change on this file since 4995 was 4993, checked in by epitzer, 14 years ago

Create own class for OperatorTrace, remove unnecessary event handlers, prevent flickering while stepping, permanently highlight execution context's scope (#47)

File size: 1.5 KB
Line 
1using System.Collections.Generic;
2using System.Linq;
3using HeuristicLab.Collections;
4using HeuristicLab.Common;
5using HeuristicLab.Core;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.DebugEngine {
9
10  [StorableClass]
11  public class OperatorTrace : ObservableList<IOperator>, IContent, IDeepCloneable {
12
13    public OperatorTrace()
14      : base() {
15    }
16    public OperatorTrace(int capacity)
17      : base(capacity) {
18    }
19    public OperatorTrace(IEnumerable<IOperator> collection)
20      : base(collection) {
21    }
22
23    [StorableConstructor]
24    protected OperatorTrace(bool deserializing) : base(deserializing) { }
25    protected OperatorTrace(OperatorTrace original, Cloner cloner) {
26      cloner.RegisterClonedObject(original, this);
27      AddRange(original.Select(op => cloner.Clone(op)));
28    }
29    public object Clone() {
30      return Clone(new Cloner());
31    }
32    public virtual IDeepCloneable Clone(Cloner cloner) {
33      return new OperatorTrace(this, cloner);
34    }
35    public virtual void ReplaceAll(IEnumerable<IOperator> operators) {
36      var oldList = list;
37      list = new List<IOperator>(operators);
38      if (oldList.Count != list.Count)
39        OnPropertyChanged("Count");
40      OnPropertyChanged("Item[]");
41      OnCollectionReset(
42        list.Select((op, i) => new IndexedItem<IOperator>(i, op)),
43        oldList.Select((op, i) => new IndexedItem<IOperator>(i, op)));
44    }
45
46  }
47}
Note: See TracBrowser for help on using the repository browser.