3 #ifndef GRAIL_BLACKBOARD_STATE_H
4 #define GRAIL_BLACKBOARD_STATE_H
6 #include "Flatbuffers/BlackboardState_generated.h"
18 std::map<std::string, std::string> data{};
21 inline flatbuffers::Offset<generated::BlackboardState> Pack(flatbuffers::FlatBufferBuilder& builder,
24 std::vector<flatbuffers::Offset<generated::StringStringMap>> packedData{};
25 packedData.reserve(blackboardState.data.size());
26 std::for_each(blackboardState.data.begin(), blackboardState.data.end(),
27 [&packedData, &builder](
const auto& blackboardEntry)
29 packedData.push_back(generated::CreateStringStringMap(builder,
30 builder.CreateString(blackboardEntry.first), builder.CreateString(blackboardEntry.second)));
32 return generated::CreateBlackboardState(builder, builder.CreateString(blackboardState.name), builder.CreateVector(packedData));
35 inline BlackboardState Unpack(
const generated::BlackboardState& snapshot)
37 BlackboardState blackboardState{snapshot.name()->str()};
38 for(
const auto& entry : *snapshot.data())
40 blackboardState.data.insert({entry->key()->str(), entry->value()->str()});
42 return blackboardState;