Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterBinding/HeuristicLab.Persistence/3.3/Core/FormatBase.cs @ 8381

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

Fixed GPL license headers #893

File size: 2.9 KB
Line 
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.Persistence.Default.CompositeSerializers.Storable;
24
25namespace HeuristicLab.Persistence.Interfaces {
26
27  /// <summary>
28  /// Common base class for defining a new serialization format.
29  /// </summary>
30  /// <typeparam name="SerialDataFormat">The type of the serial data format.</typeparam>
31  [StorableClass]
32  public abstract class FormatBase<SerialDataFormat> : IFormat<SerialDataFormat> where SerialDataFormat : ISerialData {
33
34    /// <summary>
35    /// Gets the format's name.
36    /// </summary>
37    /// <value>The format's name.</value>
38    public abstract string Name { get; }
39   
40    /// <summary>
41    /// Datatype that describes the atoms used for serialization serialization.
42    /// </summary>
43    public Type SerialDataType { get { return typeof(SerialDataFormat); } }
44
45    /// <summary>
46    /// Compares formats by name.
47    /// </summary>
48    /// <param name="f">The format.</param>
49    /// <returns>wheter this object and f are equal by name.</returns>
50    public bool Equals(FormatBase<SerialDataFormat> f) {
51      if (f == null)
52        return false;
53      return f.Name == this.Name;
54    }
55
56    /// <summary>
57    /// Compares foramts by name.
58    /// </summary>
59    /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
60    /// <returns>
61    ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
62    /// </returns>
63    /// <exception cref="T:System.NullReferenceException">
64    /// The <paramref name="obj"/> parameter is null.
65    /// </exception>
66    public override bool Equals(object obj) {
67      FormatBase<SerialDataFormat> f = obj as FormatBase<SerialDataFormat>;
68      return Equals(f);
69    }
70
71    /// <summary>
72    /// Returns a hash code for this instance.
73    /// </summary>
74    /// <returns>
75    /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
76    /// </returns>
77    public override int GetHashCode() {
78      return Name.GetHashCode();
79    }
80
81  }
82
83}
Note: See TracBrowser for help on using the repository browser.