blob: d392db05340f0642f5f20c88f1d29d24e8de164a [file] [log] [blame]
Francis Murtagh94d79152019-08-16 17:45:07 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "CommandHandlerRegistry.hpp"
7
8#include <boost/assert.hpp>
9#include <boost/log/trivial.hpp>
10
11void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version)
12{
13 BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr.");
14 CommandHandlerKey key(packetId, version);
15 registry[key] = functor;
16}
17
18CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t packetId, uint32_t version) const
19{
20 CommandHandlerKey key(packetId, version);
21
22 // Check that the requested key exists
23 if (registry.find(key) == registry.end())
24 {
25 throw armnn::Exception("Functor with requested PacketId or Version does not exist.");
26 }
27
28 return registry.at(key);
29}