Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/EmptyAlgorithm.cs @ 5469

Last change on this file since 5469 was 5344, checked in by swagner, 14 years ago

Worked on OKB (#1174)

File size: 3.2 KB
RevLine 
[5344]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
22using System;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Optimization;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Clients.OKB {
29  [Item("Empty Algorithm", "A dummy algorithm which serves as a placeholder and cannot be executed.")]
30  [StorableClass]
31  public sealed class EmptyAlgorithm : HeuristicLab.Optimization.Algorithm {
32    private string exceptionMessage;
33
34    public override bool CanChangeName {
35      get { return false; }
36    }
37    public override bool CanChangeDescription {
38      get { return false; }
39    }
40
41    private ResultCollection results;
42    public override Optimization.ResultCollection Results {
43      get { return results; }
44    }
45
46    #region Persistence Properties
47    [Storable(Name = "ExceptionMessage")]
48    private string ExceptionMessage {
49      get { return exceptionMessage; }
50      set { exceptionMessage = value; }
51    }
52    #endregion
53
54    [StorableConstructor]
55    private EmptyAlgorithm(bool deserializing)
56      : base(deserializing) {
57      this.results = new ResultCollection();
58    }
59    private EmptyAlgorithm(EmptyAlgorithm original, Cloner cloner)
60      : base(original, cloner) {
61      this.exceptionMessage = original.exceptionMessage;
62      this.results = new ResultCollection();
63    }
64    public EmptyAlgorithm()
65      : base() {
66      results = new ResultCollection();
67    }
68    public EmptyAlgorithm(string exceptionMessage)
69      : this() {
70      this.exceptionMessage = exceptionMessage;
71    }
72
73    public override IDeepCloneable Clone(Cloner cloner) {
74      return new EmptyAlgorithm(this, cloner);
75    }
76
77    public override void Prepare() {
78      throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot prepare an EmptyAlgorithm." : exceptionMessage);
79    }
80    public override void Start() {
81      throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot start an EmptyAlgorithm." : exceptionMessage);
82    }
83    public override void Pause() {
84      throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot pause an EmptyAlgorithm." : exceptionMessage);
85    }
86    public override void Stop() {
87      throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot stop an EmptyAlgorithm." : exceptionMessage);
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.