mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
MPI
This commit is contained in:
42
components/flatbuffers/MPIMessageBuilder.cpp
Normal file
42
components/flatbuffers/MPIMessageBuilder.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Created by Johnathon Slightham on 2025-06-30.
|
||||
//
|
||||
|
||||
#include "MPIMessageBuilder.h"
|
||||
|
||||
#include "SerializedMessage.h"
|
||||
|
||||
namespace Flatbuffers {
|
||||
SerializedMessage MPIMessageBuilder::build_mpi_message(
|
||||
const Messaging::MessageType type,
|
||||
const uint8_t sender,
|
||||
const uint8_t destination,
|
||||
const uint16_t sequence_number,
|
||||
const bool is_durable,
|
||||
const uint8_t tag,
|
||||
const std::vector<uint8_t>& payload) {
|
||||
builder_.Clear();
|
||||
|
||||
const auto payload_vector = builder_.CreateVector(payload);
|
||||
|
||||
const auto message = Messaging::CreateMPIMessage(
|
||||
builder_,
|
||||
type,
|
||||
sender,
|
||||
destination,
|
||||
sequence_number,
|
||||
is_durable,
|
||||
static_cast<int>(payload.size()),
|
||||
tag,
|
||||
payload_vector
|
||||
);
|
||||
|
||||
builder_.Finish(message);
|
||||
|
||||
return {builder_.GetBufferPointer(), builder_.GetSize()};
|
||||
}
|
||||
|
||||
const Messaging::MPIMessage* MPIMessageBuilder::parse_mpi_message(const uint8_t* buffer) {
|
||||
return flatbuffers::GetRoot<Messaging::MPIMessage>(buffer);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user