#include <blitz/protocol/PacketFactory.h>

#include <array>
#include <cassert>
#include <functional>

namespace blitz {
namespace protocol {
namespace PacketFactory {

using PacketCreator = std::function<std::unique_ptr<Packet>()>;

#define DeclarePacket(PacketName, ...) std::make_unique<packets::PacketName>(),

static std::array<std::unique_ptr<Packet>, static_cast<std::size_t>(PacketType::PACKET_COUNT)> Packets;

void Init() {
	Packets = {

		DeclareAllPacket()

	};
}

const std::unique_ptr<Packet>& CreateReadOnlyPacket(PacketType a_Type) {
	assert(a_Type < PacketType::PACKET_COUNT);
	return Packets[static_cast<std::size_t>(a_Type)];
}

}  // namespace PacketFactory
}  // namespace protocol
}  // namespace blitz
