//This file is part of the reprodyne project and is licensed under the terms of the LGPL-3.0-only #pragma once #include "scopecontainers.h" namespace reprodyne { template class Program { std::optional frameCounter; protected: ScopeContainer scopes; public: Program() {} Program(ScopeContainer cont): scopes(cont) {} void openScope(void* ptr) { scopes.openScope(ptr); } void markFrame() { if(!frameCounter) frameCounter = 0; else ++(*frameCounter); } unsigned int readFrameId() { if(!frameCounter) throw std::logic_error("Call to intercept before reprodyne_mark_frame is forbidden."); return *frameCounter; } template T intercept(void* scopePtr, const char* subscopeKey, const T indeterminate) { return scopes.at(scopePtr).intercept(readFrameId(), subscopeKey, indeterminate); } template void serialize(void* scopePtr, const char* subscopeKey, const Ts... serialValue) { scopes.at(scopePtr).serialize(readFrameId(), subscopeKey, serialValue...); } void assertCompleteRead() { scopes.assertCompleteRead(); } }; class ProgramRecorder : public Program { flatbuffers::FlatBufferBuilder builder; public: ProgramRecorder(): Program(ScopeContainerRecorder(builder)) {} void save(const char* path); }; class ProgramPlayer : public Program { std::vector loadedBuffer; public: ProgramPlayer(const char* path); }; }//reprodyne