Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceOverhaul/HeuristicLab.Operators/3.3/CheckedMultiOperator.cs @ 16189

Last change on this file since 16189 was 14711, checked in by gkronber, 8 years ago

#2520

  • renamed StorableClass -> StorableType
  • changed persistence to use GUIDs instead of type names
File size: 3.1 KB
RevLine 
[2773]1#region License Information
2/* HeuristicLab
[12012]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[2773]4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
[9934]22using System;
[9838]23using System.Collections.Generic;
[9934]24using System.Linq;
[4722]25using HeuristicLab.Common;
[2773]26using HeuristicLab.Core;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Operators {
30  /// <summary>
[3616]31  /// A base class for operators which apply arbitrary many other operators of a specific type that can be checked or unchecked.
[2773]32  /// </summary>
[3822]33  [Item("CheckedMultiOperator", "A base class for operators which apply arbitrary many other operators of a specific type that can be checked or unchecked.")]
[14711]34  [StorableType("390272F8-3B06-4121-B7F6-2FC713A45613")]
[9159]35  public abstract class CheckedMultiOperator<T> : MultiOperator<T>, ICheckedMultiOperator<T> where T : class, IOperator {
[3591]36    /// <summary>
37    /// Gets the operators of the checked multi operator
38    /// </summary>
39    public new ICheckedItemList<T> Operators {
40      get { return (ICheckedItemList<T>)base.Operators; }
41      protected set { base.Operators = value; }
[2773]42    }
[4722]43
44    [StorableConstructor]
45    protected CheckedMultiOperator(bool deserializing) : base(deserializing) { }
46    protected CheckedMultiOperator(CheckedMultiOperator<T> original, Cloner cloner)
47      : base(original, cloner) {
48    }
[3591]49    /// <summary>
50    /// Creates a new instance of CheckedMultiOperator
51    /// </summary>
52    public CheckedMultiOperator()
[2773]53      : base() {
[3591]54      Operators = new CheckedItemList<T>();
[2773]55    }
[9838]56
57    public override void CollectParameterValues(IDictionary<string, IItem> values) {
[9934]58      foreach (var param in Parameters.OfType<IValueParameter>().Except(OperatorParameters)) {
59        var children = GetCollectedValues(param);
60        foreach (var c in children) {
61          if (String.IsNullOrEmpty(c.Key))
62            values.Add(param.Name, c.Value);
63          else values.Add(param.Name + "." + c.Key, c.Value);
64        }
65      }
[9838]66      foreach (var opParam in OperatorParameters) {
67        var op = opParam.Value;
68        var @checked = Operators.ItemChecked(op);
[9934]69        if (!@checked) continue;
70        var children = GetCollectedValues(opParam);
71        foreach (var c in children) {
72          if (String.IsNullOrEmpty(c.Key))
73            values.Add(opParam.Name, c.Value);
74          else values.Add(opParam.Name + "." + c.Key, c.Value);
75        }
[9838]76      }
77    }
[2773]78  }
79}
Note: See TracBrowser for help on using the repository browser.