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