Free cookie consent management tool by TermsFeed Policy Generator

source: branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Analysis/Aggregators/Aggregator.cs @ 7128

Last change on this file since 7128 was 7128, checked in by epitzer, 12 years ago

#1696 Integrate fitness landscape analysis plugins from Heureka! repository.

File size: 1.4 KB
Line 
1using System.Collections.Generic;
2using System.Drawing;
3using System.Linq;
4using HeuristicLab.Common;
5using HeuristicLab.Common.Resources;
6using HeuristicLab.Core;
7using HeuristicLab.Optimization;
8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
9
10namespace HeuristicLab.Analysis.FitnessLandscape {
11
12  [Item("Aggregator", "Base class of aggreagtors that aggregate results collected from several trajectories.")]
13  [StorableClass]
14  public abstract class Aggregator<T> : NamedItem, IAggregator where T : class, IItem {
15
16    public override Image ItemImage { get { return VSImageLibrary.Database; } }
17    public override bool CanChangeName { get { return false; } }
18
19    protected List<T> items = new List<T>();
20
21    [StorableConstructor]
22    protected Aggregator(bool deserializing) : base(deserializing) { }
23    protected Aggregator(Aggregator<T> original, Cloner cloner)
24      : base(original, cloner) {
25        items = original.items.Select(i => cloner.Clone<IItem>(i)).Cast<T>().ToList();
26    }
27    public Aggregator() {
28      name = ItemName;
29      description = ItemDescription;
30    }
31    public virtual void MaybeAddResult(IResult result) {
32      T t = result.Value as T;
33      if (t != null)
34        items.Add(t);
35    }
36    public virtual void Reset() {
37      items.Clear();
38    }
39    public abstract IResult CreateResult();
40  }
41}
Note: See TracBrowser for help on using the repository browser.