ArmNN
 20.02
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 
8 #include <boost/assert.hpp>
9 #include <boost/format.hpp>
10 
11 namespace armnn
12 {
13 
14 namespace profiling
15 {
16 
18  uint32_t familyId,
19  uint32_t packetId,
20  uint32_t version)
21 {
22  BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
23 
24  CommandHandlerKey key(familyId, packetId, version);
25  registry[key] = functor;
26 }
27 
29 {
30  BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
31 
32  RegisterFunctor(functor, functor->GetFamilyId(), functor->GetPacketId(), functor->GetVersion());
33 }
34 
35 CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t familyId,uint32_t packetId, uint32_t version) const
36 {
37  CommandHandlerKey key(familyId, packetId, version);
38 
39  // Check that the requested key exists
40  if (registry.find(key) == registry.end())
41  {
43  boost::str(boost::format("Functor with requested PacketId=%1% and Version=%2% does not exist")
44  % packetId
45  % version));
46  }
47 
48  CommandHandlerFunctor* commandHandlerFunctor = registry.at(key);
49  if (commandHandlerFunctor == nullptr)
50  {
51  throw RuntimeException(
52  boost::str(boost::format("Invalid functor registered for PacketId=%1% and Version=%2%")
53  % packetId
54  % version));
55  }
56 
57  return commandHandlerFunctor;
58 }
59 
60 } // namespace profiling
61 
62 } // namespace armnn
CommandHandlerFunctor * GetFunctor(uint32_t familyId, uint32_t packetId, uint32_t version) const
Copyright (c) 2020 ARM Limited.
void RegisterFunctor(CommandHandlerFunctor *functor, uint32_t familyId, uint32_t packetId, uint32_t version)