//This file is part of the reprodyne project and is licensed under the terms of the LGPL-3.0-only #pragma once #include #include #include #include "schema_generated.h" namespace reprodyne { class ScopeHandlerRecorder { flatbuffers::FlatBufferBuilder& builder; struct SubScopeEntry { std::vector> theDubbles; std::vector> serialStrings; std::vector> validationVideoHash; }; std::map subScopes; public: ScopeHandlerRecorder(flatbuffers::FlatBufferBuilder& builder): builder(builder) {} //builder builder builder double intercept(const unsigned int frameId, const char* subscopeKey, const double indeterminate) { subScopes[subscopeKey].theDubbles.push_back(CreateIndeterminateDoubleEntry(builder, frameId, indeterminate)); return indeterminate; } //int intercept(const unsigned int frameId, const char* subscopeKey, const int indeterminate) //{ return saveValue(subScopes[subscopeKey].theInts, frameId, indeterminate); } void serialize(const unsigned int frameId, const char* subscopeKey, const char* val) { subScopes[subscopeKey].serialStrings.push_back(CreateValidationStringEntry(builder, frameId, builder.CreateString(val))); } void serialize(const unsigned int frameId, const char* subscopeKey, const int unsigned width, const unsigned int height, std::vector hash) { subScopes[subscopeKey].validationVideoHash.push_back(CreateValidationVideoSHA256Entry(builder, frameId, width, height, builder.CreateVector(hash))); } flatbuffers::Offset buildOrdinalScopeFlatbuffer(flatbuffers::FlatBufferBuilder& builder); }; class ScopeHandlerPlayer { public: typedef const OrdinalScopeTapeEntry BufferType; private: const BufferType* myBuffer; struct LastReadPos { int indeterminateDoublePos = 0; int validationStringPos = 0; int validationVideoHashPos = 0; }; std::map readPosMap; const KeyedScopeTapeEntry* getKeyedEntry(const char* subscopeKey); void checkReadPastEnd(const int size, const int pos); void checkFrame(const unsigned int frameId1, const unsigned int frameId2, const char* moreSpecifically); public: ScopeHandlerPlayer(BufferType* buf): myBuffer(buf) {} double intercept(const unsigned int frameId, const char* subscopeKey, const double indeterminate); //int intercept(const unsigned int frameId, const char* subscopeKey, const int indeterminate); void serialize(const unsigned int frameId, const char* subscopeKey, const char* val); void serialize(const unsigned int frameId, const char* subscopeKey, const unsigned int width, const unsigned int height, std::vector hash); void assertCompletReed(); }; }//reprodyne