xrp style wpilib comms
Loading...
Searching...
No Matches
message_type.h
Go to the documentation of this file.
1#pragma once
2#include <cstdint>
4public:
5 virtual int getTag() = 0;
6 virtual bool hasId() = 0;
7 virtual uint8_t getId() = 0;
8 virtual void* getData() = 0;
9 virtual void setData(const void* data) = 0;
10 virtual int toNetworkBuffer(char* buffer, int pos, int end) = 0;
11 virtual int fromNetworkBuffer(char* buf, int pos, int end) = 0;
12 virtual ~MessageType() { }
13
14protected:
15};
16
17template <typename T>
18struct tag_type {
19 static constexpr uint8_t value = 0; // Default value, should be specialized for each type
20};
21
22#define TYPE_TO_TAG_VAL(type) (tag_type<type>::value)
23
24#define HAS_ID(type) (tag_type<type>::hasId)
Definition message_type.h:3
virtual int toNetworkBuffer(char *buffer, int pos, int end)=0
virtual uint8_t getId()=0
virtual int fromNetworkBuffer(char *buf, int pos, int end)=0
virtual void * getData()=0
virtual int getTag()=0
virtual void setData(const void *data)=0
virtual ~MessageType()
Definition message_type.h:12
virtual bool hasId()=0
Definition message_type.h:18
static constexpr uint8_t value
Definition message_type.h:19