#pragma once // Copyright (c) 2018-2019 David Burkett // Distributed under the MIT software license, see the accompanying // file LICENSE or http://www.opensource.org/licenses/mit-license.php. #include #include // Forward Declarations template class BigInt; class Commitment; namespace mw { using Hash = BigInt<32, std::allocator>; } #define IMPL_SERIALIZED(T) \ std::vector Serialized() const noexcept final \ { \ std::vector serialized; \ CVectorWriter stream(SER_NETWORK, PROTOCOL_VERSION, serialized, 0); \ ::Serialize(stream, *this); \ return serialized; \ } \ static T Deserialize(const std::vector& serialized) \ { \ T obj; \ VectorReader stream(SER_NETWORK, PROTOCOL_VERSION, serialized, 0); \ stream >> obj; \ return obj; \ } #define IMPL_SERIALIZABLE(T, obj) \ IMPL_SERIALIZED(T) \ SERIALIZE_METHODS(T, obj) namespace Traits { class ISerializable { public: virtual ~ISerializable() = default; // // Serializes object into a byte vector. // virtual std::vector Serialized() const noexcept = 0; }; class IPrintable { public: virtual ~IPrintable() = default; virtual std::string Format() const = 0; }; class ICommitted { public: virtual ~ICommitted() = default; virtual const Commitment& GetCommitment() const noexcept = 0; }; class IHashable { public: virtual ~IHashable() = default; virtual const mw::Hash& GetHash() const noexcept = 0; }; }