blob: 97313475ffd527e75cf4b1446d64ddafbcdee998 [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
Aron Virginas-Tare898db92019-08-22 12:56:34 +010011namespace armnn
12{
13
14namespace profiling
15{
16
Francis Murtagh94d79152019-08-16 17:45:07 +010017void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version)
18{
19 BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr.");
20 CommandHandlerKey key(packetId, version);
21 registry[key] = functor;
22}
23
24CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t packetId, uint32_t version) const
25{
26 CommandHandlerKey key(packetId, version);
27
28 // Check that the requested key exists
29 if (registry.find(key) == registry.end())
30 {
31 throw armnn::Exception("Functor with requested PacketId or Version does not exist.");
32 }
33
34 return registry.at(key);
35}
Aron Virginas-Tare898db92019-08-22 12:56:34 +010036
37} // namespace profiling
38
39} // namespace armnn