32 lines
1.4 KiB
C++
32 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <sp/protocol/GenericHandler.h>
|
|
#include <sp/protocol/Message.h>
|
|
|
|
|
|
namespace sp {
|
|
class PacketHandler;
|
|
|
|
using PacketID = std::uint8_t;
|
|
|
|
using PacketMessage = Message<
|
|
option::MsgIdType<PacketID>, // add id() operation
|
|
option::Handler<PacketHandler> // add dispatch() operation
|
|
>;
|
|
|
|
#define PacketConstructor(packetName) \
|
|
packetName##Packet() {} \
|
|
template <typename... Args> \
|
|
packetName##Packet(Args... args) { \
|
|
Construct(args...); \
|
|
}
|
|
|
|
#define DeclarePacket(packetName) \
|
|
class packetName##Packet : public sp::MessageBase<sp::PacketMessage, \
|
|
sp::option::DispatchImpl<packetName##Packet>, sp::option::FieldsImpl<packetName##Fields>>, \
|
|
sp::option::ToStringImpl<packetName##Packet>
|
|
|
|
|
|
|
|
} // namespace sp
|