From 94d7915bef33ad59d1bdfa791490268c682c5359 Mon Sep 17 00:00:00 2001 From: Francis Murtagh Date: Fri, 16 Aug 2019 17:45:07 +0100 Subject: IVGCVSW-3550 Create Command Handler Registry Change-Id: I51e34068d79ba660ae2f16b22ad2bb8191d473fa Signed-off-by: Francis Murtagh --- src/profiling/CommandHandlerRegistry.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/profiling/CommandHandlerRegistry.cpp (limited to 'src/profiling/CommandHandlerRegistry.cpp') diff --git a/src/profiling/CommandHandlerRegistry.cpp b/src/profiling/CommandHandlerRegistry.cpp new file mode 100644 index 0000000000..d392db0534 --- /dev/null +++ b/src/profiling/CommandHandlerRegistry.cpp @@ -0,0 +1,29 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "CommandHandlerRegistry.hpp" + +#include +#include + +void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version) +{ + BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr."); + CommandHandlerKey key(packetId, version); + registry[key] = functor; +} + +CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t packetId, uint32_t version) const +{ + CommandHandlerKey key(packetId, version); + + // Check that the requested key exists + if (registry.find(key) == registry.end()) + { + throw armnn::Exception("Functor with requested PacketId or Version does not exist."); + } + + return registry.at(key); +} -- cgit v1.2.1