aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/CommandHandlerRegistry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/profiling/CommandHandlerRegistry.cpp')
-rw-r--r--src/profiling/CommandHandlerRegistry.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/profiling/CommandHandlerRegistry.cpp b/src/profiling/CommandHandlerRegistry.cpp
new file mode 100644
index 0000000000..d392db0534
--- /dev/null
+++ b/src/profiling/CommandHandlerRegistry.cpp
@@ -0,0 +1,29 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "CommandHandlerRegistry.hpp"
+
+#include <boost/assert.hpp>
+#include <boost/log/trivial.hpp>
+
+void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version)
+{
+ BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr.");
+ CommandHandlerKey key(packetId, version);
+ registry[key] = functor;
+}
+
+CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t packetId, uint32_t version) const
+{
+ CommandHandlerKey key(packetId, version);
+
+ // Check that the requested key exists
+ if (registry.find(key) == registry.end())
+ {
+ throw armnn::Exception("Functor with requested PacketId or Version does not exist.");
+ }
+
+ return registry.at(key);
+}