ArmNN
 20.05
CommandHandlerRegistry.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
9 
10 #include <boost/format.hpp>
11 
12 namespace armnn
13 {
14 
15 namespace profiling
16 {
17 
19  uint32_t familyId,
20  uint32_t packetId,
21  uint32_t version)
22 {
23  ARMNN_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
24 
25  CommandHandlerKey key(familyId, packetId, version);
26  registry[key] = functor;
27 }
28 
30 {
31  ARMNN_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
32 
33  RegisterFunctor(functor, functor->GetFamilyId(), functor->GetPacketId(), functor->GetVersion());
34 }
35 
36 CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t familyId,uint32_t packetId, uint32_t version) const
37 {
38  CommandHandlerKey key(familyId, packetId, version);
39 
40  // Check that the requested key exists
41  if (registry.find(key) == registry.end())
42  {
44  boost::str(boost::format("Functor with requested PacketId=%1% and Version=%2% does not exist")
45  % packetId
46  % version));
47  }
48 
49  CommandHandlerFunctor* commandHandlerFunctor = registry.at(key);
50  if (commandHandlerFunctor == nullptr)
51  {
52  throw RuntimeException(
53  boost::str(boost::format("Invalid functor registered for PacketId=%1% and Version=%2%")
54  % packetId
55  % version));
56  }
57 
58  return commandHandlerFunctor;
59 }
60 
61 } // namespace profiling
62 
63 } // namespace armnn
CommandHandlerFunctor * GetFunctor(uint32_t familyId, uint32_t packetId, uint32_t version) const
Copyright (c) 2020 ARM Limited.
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
void RegisterFunctor(CommandHandlerFunctor *functor, uint32_t familyId, uint32_t packetId, uint32_t version)