diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-10-07 12:35:21 +0100 |
---|---|---|
committer | Jim Flynn Arm <jim.flynn@arm.com> | 2019-10-08 08:22:51 +0000 |
commit | c2728f95086c54aa842e4c1dae8f3b5c290a72fa (patch) | |
tree | 82002c3d0c97abfeed905d0e922579dab09b2c31 /src/profiling/CommandHandlerRegistry.cpp | |
parent | e61ffd00a37f02338129e92d65be2f01600014c0 (diff) | |
download | armnn-c2728f95086c54aa842e4c1dae8f3b5c290a72fa.tar.gz |
IVGCVSW-3937 Refactor and improve the CommandHandleRegistry class
* Added simplified RegisterFunctor method
* Code refactoring
* Updated the unit tests accordingly
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Change-Id: Iee941d898facd9c1ab5366e87c611c99a0468830
Diffstat (limited to 'src/profiling/CommandHandlerRegistry.cpp')
-rw-r--r-- | src/profiling/CommandHandlerRegistry.cpp | 28 |
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 |