#pragma once

#include "blitz/protocol/Protocol.h"

#include <map>
#include <vector>

namespace blitz {
namespace protocol {

class PacketHandler;

class PacketDispatcher {
  private:
	std::map<PacketType, std::vector<PacketHandler*>> m_Handlers;

  public:
	PacketDispatcher() = default;

	PacketDispatcher(const PacketDispatcher& rhs) = delete;
	PacketDispatcher& operator=(const PacketDispatcher& rhs) = delete;
	PacketDispatcher(PacketDispatcher&& rhs) = delete;
	PacketDispatcher& operator=(PacketDispatcher&& rhs) = delete;

	void Dispatch(const PacketPtr& packet);

	void RegisterHandler(PacketType type, PacketHandler* handler);
	void UnregisterHandler(PacketType type, PacketHandler* handler);
	void UnregisterHandler(PacketHandler* handler);
};

}  // namespace protocol
}  // namespace blitz
