blob: 61d45b0fd236e4f0bd4dea284aa2e025c1325241 [file] [log] [blame]
Francis Murtagh94d79152019-08-16 17:45:07 +01001//
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-Tare898db92019-08-22 12:56:34 +010012
Francis Murtagh94d79152019-08-16 17:45:07 +010013#include <unordered_map>
14
Aron Virginas-Tare898db92019-08-22 12:56:34 +010015namespace armnn
16{
17
18namespace profiling
19{
20
Francis Murtagh94d79152019-08-16 17:45:07 +010021struct 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
32class CommandHandlerRegistry
33{
34public:
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
41private:
42 std::unordered_map<CommandHandlerKey, CommandHandlerFunctor*, CommandHandlerHash> registry;
Aron Virginas-Tare898db92019-08-22 12:56:34 +010043};
44
45} // namespace profiling
46
47} // namespace armnn