diff options
author | Francis Murtagh <francis.murtagh@arm.com> | 2019-08-16 17:45:07 +0100 |
---|---|---|
committer | Francis Murtagh <francis.murtagh@arm.com> | 2019-08-16 17:45:12 +0100 |
commit | 94d7915bef33ad59d1bdfa791490268c682c5359 (patch) | |
tree | 98a1732cd744bf79d4165e5745f95c1cae5075fe /src/profiling/CommandHandlerRegistry.cpp | |
parent | 8ab53f05071b020ab864b82d2edfefb28e427ec8 (diff) | |
download | armnn-94d7915bef33ad59d1bdfa791490268c682c5359.tar.gz |
IVGCVSW-3550 Create Command Handler Registry
Change-Id: I51e34068d79ba660ae2f16b22ad2bb8191d473fa
Signed-off-by: Francis Murtagh <francis.murtagh@arm.com>
Diffstat (limited to 'src/profiling/CommandHandlerRegistry.cpp')
-rw-r--r-- | src/profiling/CommandHandlerRegistry.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
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 <boost/assert.hpp> +#include <boost/log/trivial.hpp> + +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); +} |