3 #ifndef GRAIL_UTILITY_REASONER_SNAPSHOT_H
4 #define GRAIL_UTILITY_REASONER_SNAPSHOT_H
6 #include "UtilityEvaluatorSnapshot.h"
7 #include "Flatbuffers/UtilityReasonerSnapshot_generated.h"
18 float absoluteTime = 0.0f;
19 float relativeTime = 0.0f;
20 std::vector<UtilityEvaluatorSnapshot> evaluatorSnapshots{};
23 inline flatbuffers::Offset<generated::UtilityReasonerSnapshot> Pack(flatbuffers::FlatBufferBuilder& builder,
26 std::vector<flatbuffers::Offset<generated::UtilityEvaluatorSnapshot>> packedEvaluatorSnapshots{};
27 packedEvaluatorSnapshots.reserve(snapshot.evaluatorSnapshots.size());
28 std::for_each(snapshot.evaluatorSnapshots.begin(), snapshot.evaluatorSnapshots.end(),
29 [&packedEvaluatorSnapshots, &builder](
const auto& evaluatorSnapshot)
31 packedEvaluatorSnapshots.push_back(Pack(builder, evaluatorSnapshot));
33 return generated::CreateUtilityReasonerSnapshot(builder, snapshot.entityId, snapshot.absoluteTime,
34 snapshot.relativeTime,builder.CreateVector(packedEvaluatorSnapshots));
37 inline UtilityReasonerSnapshot Unpack(
const generated::UtilityReasonerSnapshot& snapshot)
39 UtilityReasonerSnapshot utilityReasonerSnapshot{snapshot.entityId(), snapshot.absoluteTime(), snapshot.relativeTime()};
40 utilityReasonerSnapshot.evaluatorSnapshots.reserve(snapshot.evaluatorSnapshots()->size());
41 for(
const auto& evaluation : *snapshot.evaluatorSnapshots())
43 utilityReasonerSnapshot.evaluatorSnapshots.emplace_back(Unpack(*evaluation));
45 return utilityReasonerSnapshot;