constructor for packets
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <sp/protocol/Message.h>
|
||||
#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
|
||||
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> \
|
||||
> {}
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user