using System.Collections.Generic; using System.Drawing; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Common.Resources; using HeuristicLab.Core; using HeuristicLab.Optimization; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Analysis.FitnessLandscape { [Item("Aggregator", "Base class of aggreagtors that aggregate results collected from several trajectories.")] [StorableClass] public abstract class Aggregator : NamedItem, IAggregator where T : class, IItem { public static new Image StaticItemImage { get { return VSImageLibrary.Database; } } public override bool CanChangeName { get { return false; } } protected List items = new List(); [StorableConstructor] protected Aggregator(bool deserializing) : base(deserializing) { } protected Aggregator(Aggregator original, Cloner cloner) : base(original, cloner) { items = original.items.Select(i => cloner.Clone(i)).Cast().ToList(); } public Aggregator() { name = ItemName; description = ItemDescription; } public virtual void MaybeAddResult(IResult result) { T t = result.Value as T; if (t != null) items.Add(t); } public virtual void Reset() { items.Clear(); } public abstract IResult CreateResult(); } }