#region License Information
/* HeuristicLab
* Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Persistence.Interfaces {
///
/// Common base class for defining a new serialization format.
///
/// The type of the serial data format.
[StorableClass]
public abstract class FormatBase : IFormat where SerialDataFormat : ISerialData {
///
/// Gets the format's name.
///
/// The format's name.
public abstract string Name { get; }
///
/// Datatype that describes the atoms used for serialization serialization.
///
public Type SerialDataType { get { return typeof(SerialDataFormat); } }
[StorableConstructor]
protected FormatBase(bool deserializing) { }
protected FormatBase() { }
///
/// Compares formats by name.
///
/// The format.
/// wheter this object and f are equal by name.
public bool Equals(FormatBase f) {
if (f == null)
return false;
return f.Name == this.Name;
}
///
/// Compares foramts by name.
///
/// The to compare with this instance.
///
/// true if the specified is equal to this instance; otherwise, false.
///
///
/// The parameter is null.
///
public override bool Equals(object obj) {
FormatBase f = obj as FormatBase;
return Equals(f);
}
///
/// Returns a hash code for this instance.
///
///
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
///
public override int GetHashCode() {
return Name.GetHashCode();
}
}
}