Francis Murtagh | 94d7915 | 2019-08-16 17:45:07 +0100 | [diff] [blame] | 1 | // |
| 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 | |
| 11 | void 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 | |
| 18 | CommandHandlerFunctor* 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 | } |