Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 11813 was 7202, checked in by epitzer, 13 years ago

#1696: Add static item image according to #1651

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 static new Image StaticItemImage { 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.