67 std::string payload(map);
68 payload.push_back(
'\0');
69 payload.append(
reinterpret_cast<const char *
>(&load_id),
sizeof(load_id));
70 const auto append_field = [&payload](uint8_t kind,
const std::optional<std::string> &value) {
74 const uint32_t size =
static_cast<uint32_t
>(value->size());
75 payload.push_back(
static_cast<char>(kind));
76 payload.append(
reinterpret_cast<const char *
>(&size),
sizeof(size));
77 payload.append(*value);
79 append_field(1u, extras.opendrive);
80 append_field(2u, extras.generation_parameters);
92 const auto end_of_map = payload.find(
'\0');
93 request.
map = std::string(payload.substr(0u, end_of_map));
95 (end_of_map == std::string_view::npos) ||
99 std::memcpy(&request.
load_id, payload.data() + end_of_map + 1u,
sizeof(request.
load_id));
101 while (payload.size() - offset >= 1u +
sizeof(uint32_t)) {
102 const uint8_t kind =
static_cast<uint8_t
>(payload[offset]);
104 std::memcpy(&size, payload.data() + offset + 1u,
sizeof(size));
105 offset += 1u +
sizeof(uint32_t);
106 if (size > payload.size() - offset) {
111 const std::string value(payload.substr(offset, size));
115 }
else if (kind == 2u) {
126 message.append(
reinterpret_cast<const char *
>(&load_id),
sizeof(load_id));
137 if (load_id_bytes.empty()) {
144 std::memcpy(&load_id, load_id_bytes.data(),
sizeof(load_id));
uint32_t load_map_id_type
Identifies one LOAD_MAP broadcast.
constexpr std::size_t kMaxMultiGpuMessageBytes
Largest message either end accepts: a frame (capped at 1 GiB by the primary) plus room for its header...
std::string MakeLoadMapPayload(std::string_view map, load_map_id_type load_id, const LoadMapExtras &extras={})
LOAD_MAP payload: the NUL-terminated map path, the load id, then the extras as [u8 kind][u32 size][by...
LoadMapRequest ParseLoadMapPayload(std::string_view payload)
constexpr std::string_view kTokenNotReadyMarker
GET_TOKEN reply when the secondary cannot resolve the sensor to a stream (or the request is malformed...
std::optional< load_map_id_type > ParseEpisodeReadyMessage(std::string_view payload)
Load id of an episode-ready message (0 for a bare marker), or nullopt if payload is not one.
std::string MakeEpisodeReadyMessage(load_map_id_type load_id)
Episode-ready message: the marker followed by the load id of the LOAD_MAP that started the episode,...
constexpr std::string_view kEpisodeReadyMarker
Sent unprompted by a secondary, on the same channel as command responses, to signal that its episode ...
This file contains definitions of common data structures used in traffic manager.
GET_TOKEN request payload.