Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CloningRefactorBranch/HeuristicLab.Constraints/FalseConstraint.cs @ 885

Last change on this file since 885 was 885, checked in by gkronber, 15 years ago

Refactored cloning in HL.Core, HL.Data and HL.Constraints

#285 (Cloning could be improved by creating objects at the bottom of the cloning chain with 'new' instead of the top with Activator.CreateInstance())

File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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 System.Collections.Generic;
24using System.Text;
25using System.Xml;
26using HeuristicLab.Core;
27
28namespace HeuristicLab.Constraints {
29  public class FalseConstraint : ConstraintBase {
30    public override string Description {
31      get { return "This constraint is always false."; }
32    }
33    /// <summary>
34    /// Default constructor.
35    /// </summary>
36    public FalseConstraint() { }
37    /// <summary>
38    /// Copy constructor to create clones (deep).
39    /// </summary>
40    /// <param name="original">The original instance to be cloned.</param>
41    public FalseConstraint(FalseConstraint original) : this(original, new Dictionary<Guid, object>()) { }
42    /// <summary>
43    /// Copy constructor to create clones (deep) reusing already cloned object references.
44    /// </summary>
45    /// <param name="original">The instance to be cloned.</param>
46    /// <param name="clonedObjects">Already cloned objects (for referential integrity).</param>
47    protected FalseConstraint(FalseConstraint original, IDictionary<Guid, object> clonedObjects)
48      : base(original, clonedObjects) { }
49
50    public override IView CreateView() {
51      return new FalseConstraintView(this);
52    }
53
54    /// <summary>
55    /// Clones an instance using the copy constructor
56    /// reusing already cloned object references.
57    /// </summary>
58    /// <param name="clonedObjects">Already cloned objects (for referential integrity).</param>
59    /// <returns>A cloned (deep) instance</returns>
60    public override object Clone(IDictionary<Guid, object> clonedObjects) {
61      return new FalseConstraint(this, clonedObjects);
62    }
63
64    public override bool Check(IItem data) {
65      return false;
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.