[3743] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[9456] | 3 | * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3743] | 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 |
|
---|
| 22 | using System;
|
---|
[1853] | 23 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[1556] | 24 |
|
---|
| 25 | namespace HeuristicLab.Persistence.Interfaces {
|
---|
| 26 |
|
---|
[3004] | 27 | /// <summary>
|
---|
| 28 | /// Common base class for defining a new serialization format.
|
---|
[3036] | 29 | /// </summary>
|
---|
| 30 | /// <typeparam name="SerialDataFormat">The type of the serial data format.</typeparam>
|
---|
[3017] | 31 | [StorableClass]
|
---|
[1564] | 32 | public abstract class FormatBase<SerialDataFormat> : IFormat<SerialDataFormat> where SerialDataFormat : ISerialData {
|
---|
[3016] | 33 |
|
---|
| 34 | /// <summary>
|
---|
| 35 | /// Gets the format's name.
|
---|
| 36 | /// </summary>
|
---|
| 37 | /// <value>The format's name.</value>
|
---|
[1564] | 38 | public abstract string Name { get; }
|
---|
[4806] | 39 |
|
---|
[3004] | 40 | /// <summary>
|
---|
| 41 | /// Datatype that describes the atoms used for serialization serialization.
|
---|
| 42 | /// </summary>
|
---|
[1564] | 43 | public Type SerialDataType { get { return typeof(SerialDataFormat); } }
|
---|
| 44 |
|
---|
[4806] | 45 | [StorableConstructor]
|
---|
| 46 | protected FormatBase(bool deserializing) { }
|
---|
| 47 | protected FormatBase() { }
|
---|
| 48 |
|
---|
[3004] | 49 | /// <summary>
|
---|
| 50 | /// Compares formats by name.
|
---|
[3036] | 51 | /// </summary>
|
---|
| 52 | /// <param name="f">The format.</param>
|
---|
| 53 | /// <returns>wheter this object and f are equal by name.</returns>
|
---|
[1564] | 54 | public bool Equals(FormatBase<SerialDataFormat> f) {
|
---|
| 55 | if (f == null)
|
---|
[1556] | 56 | return false;
|
---|
[1564] | 57 | return f.Name == this.Name;
|
---|
[1556] | 58 | }
|
---|
[1564] | 59 |
|
---|
[3004] | 60 | /// <summary>
|
---|
| 61 | /// Compares foramts by name.
|
---|
| 62 | /// </summary>
|
---|
[3036] | 63 | /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
|
---|
| 64 | /// <returns>
|
---|
| 65 | /// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
|
---|
| 66 | /// </returns>
|
---|
| 67 | /// <exception cref="T:System.NullReferenceException">
|
---|
| 68 | /// The <paramref name="obj"/> parameter is null.
|
---|
| 69 | /// </exception>
|
---|
[1564] | 70 | public override bool Equals(object obj) {
|
---|
[1566] | 71 | FormatBase<SerialDataFormat> f = obj as FormatBase<SerialDataFormat>;
|
---|
[1564] | 72 | return Equals(f);
|
---|
[1556] | 73 | }
|
---|
[1566] | 74 |
|
---|
[3036] | 75 | /// <summary>
|
---|
| 76 | /// Returns a hash code for this instance.
|
---|
| 77 | /// </summary>
|
---|
| 78 | /// <returns>
|
---|
| 79 | /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
|
---|
| 80 | /// </returns>
|
---|
[1574] | 81 | public override int GetHashCode() {
|
---|
| 82 | return Name.GetHashCode();
|
---|
| 83 | }
|
---|
| 84 |
|
---|
[1556] | 85 | }
|
---|
[1564] | 86 |
|
---|
[1556] | 87 | } |
---|