Francis Murtagh | 94d7915 | 2019-08-16 17:45:07 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "CommandHandlerFunctor.hpp" |
| 9 | #include "CommandHandlerKey.hpp" |
| 10 | |
| 11 | #include <boost/functional/hash.hpp> |
Aron Virginas-Tar | e898db9 | 2019-08-22 12:56:34 +0100 | [diff] [blame] | 12 | |
Francis Murtagh | 94d7915 | 2019-08-16 17:45:07 +0100 | [diff] [blame] | 13 | #include <unordered_map> |
| 14 | |
Aron Virginas-Tar | e898db9 | 2019-08-22 12:56:34 +0100 | [diff] [blame] | 15 | namespace armnn |
| 16 | { |
| 17 | |
| 18 | namespace profiling |
| 19 | { |
| 20 | |
Francis Murtagh | 94d7915 | 2019-08-16 17:45:07 +0100 | [diff] [blame] | 21 | struct CommandHandlerHash |
| 22 | { |
| 23 | std::size_t operator() (const CommandHandlerKey& commandHandlerKey) const |
| 24 | { |
| 25 | std::size_t seed = 0; |
| 26 | boost::hash_combine(seed, commandHandlerKey.GetPacketId()); |
| 27 | boost::hash_combine(seed, commandHandlerKey.GetVersion()); |
| 28 | return seed; |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | class CommandHandlerRegistry |
| 33 | { |
| 34 | public: |
| 35 | CommandHandlerRegistry() = default; |
| 36 | |
| 37 | void RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version); |
| 38 | |
| 39 | CommandHandlerFunctor* GetFunctor(uint32_t packetId, uint32_t version) const; |
| 40 | |
| 41 | private: |
| 42 | std::unordered_map<CommandHandlerKey, CommandHandlerFunctor*, CommandHandlerHash> registry; |
Aron Virginas-Tar | e898db9 | 2019-08-22 12:56:34 +0100 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | } // namespace profiling |
| 46 | |
| 47 | } // namespace armnn |