From 65b4431537f40e1e7539aeef06a7bbe07f30f013 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Mon, 15 Jul 2024 11:10:07 +0100 Subject: [PATCH] Add getData/setData to mock dummy handle This is to remain compatible with recent changes to PiMock --- source/mock/ur_mock_helpers.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/mock/ur_mock_helpers.hpp b/source/mock/ur_mock_helpers.hpp index 034d47c02d..b2cb9ca203 100644 --- a/source/mock/ur_mock_helpers.hpp +++ b/source/mock/ur_mock_helpers.hpp @@ -15,6 +15,7 @@ #include "ur_api.h" #include +#include #include #include #include @@ -36,6 +37,16 @@ struct dummy_handle_t_ { std::vector MStorage; unsigned char *MData = nullptr; size_t MSize; + + template T getDataAs() { + assert(MStorage.size() >= sizeof(T)); + return *reinterpret_cast(MStorage.data()); + } + + template T setDataAs(T Val) { + assert(MStorage.size() >= sizeof(T)); + return *reinterpret_cast(MStorage.data()) = Val; + } }; using dummy_handle_t = dummy_handle_t_ *;