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.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/profiling/CommandHandlerRegistry.cpp b/src/profiling/CommandHandlerRegistry.cpp
index 97313475ff..bd9b318835 100644
--- a/src/profiling/CommandHandlerRegistry.cpp
+++ b/src/profiling/CommandHandlerRegistry.cpp
@@ -6,7 +6,7 @@
#include "CommandHandlerRegistry.hpp"
#include <boost/assert.hpp>
-#include <boost/log/trivial.hpp>
+#include <boost/format.hpp>
namespace armnn
{
@@ -16,11 +16,19 @@ namespace profiling
void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version)
{
- BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr.");
+ BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
+
CommandHandlerKey key(packetId, version);
registry[key] = functor;
}
+void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor)
+{
+ BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr");
+
+ RegisterFunctor(functor, functor->GetPacketId(), functor->GetVersion());
+}
+
CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t packetId, uint32_t version) const
{
CommandHandlerKey key(packetId, version);
@@ -28,10 +36,22 @@ CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t packetId, uin
// Check that the requested key exists
if (registry.find(key) == registry.end())
{
- throw armnn::Exception("Functor with requested PacketId or Version does not exist.");
+ throw armnn::InvalidArgumentException(
+ boost::str(boost::format("Functor with requested PacketId=%1% and Version=%2% does not exist")
+ % packetId
+ % version));
+ }
+
+ CommandHandlerFunctor* commandHandlerFunctor = registry.at(key);
+ if (commandHandlerFunctor == nullptr)
+ {
+ throw RuntimeException(
+ boost::str(boost::format("Invalid functor registered for PacketId=%1% and Version=%2%")
+ % packetId
+ % version));
}
- return registry.at(key);
+ return commandHandlerFunctor;
}
} // namespace profiling