Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceReintegration/HeuristicLab.Common/3.3/DeepCloneable.cs @ 14929

Last change on this file since 14929 was 14929, checked in by gkronber, 7 years ago

#2520 fixed unit tests for new persistence: loading & storing all samples

File size: 2.1 KB
Line 
1using HeuristicLab.Persistence;
2#region License Information
3/* HeuristicLab
4 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 *
6 * This file is part of HeuristicLab.
7 *
8 * HeuristicLab is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * HeuristicLab is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 */
21#endregion
22
23
24namespace HeuristicLab.Common {
25  /// <summary>
26  /// Represents a base class for all deeply cloneable objects.
27  /// </summary>
28  [StorableType("c184f5d2-596e-4b10-a25a-7a87fbf3d4de")]
29  public abstract class DeepCloneable : IDeepCloneable {
30    protected DeepCloneable(DeepCloneable original, Cloner cloner) {
31      cloner.RegisterClonedObject(original, this);
32    }
33    protected DeepCloneable() { }
34
35    /// <summary>
36    /// Creates a deep clone of this instance.
37    /// </summary>
38    /// <remarks>
39    /// This method is the entry point for creating a deep clone of a whole object graph.
40    /// </remarks>
41    /// <returns>A clone of this instance.</returns>
42    public object Clone() {
43      return Clone(new Cloner());
44    }
45
46    /// <summary>
47    /// Creates a deep clone of this instance.
48    /// </summary>
49    /// <remarks>This method should not be called directly. It is used for creating clones of
50    /// objects which are contained in the object that is currently cloned.</remarks>
51    /// <param name="cloner">The cloner which is responsible for keeping track of all already
52    /// cloned objects.</param>
53    /// <returns>A clone of this instance.</returns>
54    public abstract IDeepCloneable Clone(Cloner cloner);
55  }
56}
Note: See TracBrowser for help on using the repository browser.