This commit is contained in:
2024-07-20 00:45:22 +02:00
parent 159867e747
commit 3eb3eadd4b
5 changed files with 73 additions and 27 deletions

View File

@@ -1,20 +1,34 @@
#pragma once
#include <blitz/protocol/Packets.h>
/**
* \file PacketVisitor.h
* \brief File containing the blitz::protocol::PacketVisitor class
*/
#include <blitz/protocol/PacketDeclare.h>
#include <blitz/protocol/Packets.h>
namespace blitz {
namespace protocol {
#define DeclarePacket(PacketName, ...) \
#define DeclarePacket(PacketName, ...) \
/** This function is called when the packet processed by PacketVisitor::Check is a PacketName */ \
virtual void Visit(const packets::PacketName&) {}
/**
* \class PacketVisitor
* \brief This class uses double-dispatch in order to find the real type of a packet
*/
class PacketVisitor {
protected:
PacketVisitor() {}
virtual ~PacketVisitor() {}
public:
/**
* \brief Calls the right PacketVisitor::Visit method corresponding to the real type of the packet
* \param packet the Packet to visit
*/
void Check(const Packet& packet);
DeclareAllPacket()