10 #ifndef ST_MESSAGE_HPP
11 #define ST_MESSAGE_HPP
15 #include <ST_util/linear_frame_allocator_256.hpp>
23 static ST::linear_frame_allocator_256<message> allocator;
24 std::shared_ptr<void> data;
28 uint32_t base_data0 = 0;
29 uint16_t base_data1 = 0;
30 uint8_t base_data2 = 0;
34 [[nodiscard]]
void *
get_data()
const;
44 explicit message(uint8_t name,
const std::shared_ptr<void> &data =
nullptr) {
45 this->msg_name = name;
54 message(uint8_t name, uint32_t base_data0,
const std::shared_ptr<void> &data =
nullptr) {
55 this->msg_name = name;
56 this->base_data0 = base_data0;
60 static void *
operator new(size_t) {
61 return allocator.allocate();
64 static void operator delete(
void *) {}
67 if (data !=
nullptr) {
74 static_assert(
sizeof(
message) == 24,
"sizeof message is not 24");
81 return this->data.get();
88 return &(*allocator.allocate() = *
this);
A message object passed around in the message bus. Holds anything created with make_data<>().
message * make_copy() const
message(uint8_t name, const std::shared_ptr< void > &data=nullptr)