blob: 43419deea454a79d784c6c03860aa5e580c897e2 [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
Jim Flynn397043f2019-10-17 17:37:10 +010037 void RegisterFunctor(CommandHandlerFunctor* functor, uint32_t familyId, uint32_t packetId, uint32_t version);
Francis Murtagh94d79152019-08-16 17:45:07 +010038
Matteo Martincighc2728f92019-10-07 12:35:21 +010039 void RegisterFunctor(CommandHandlerFunctor* functor);
40
Jim Flynn397043f2019-10-17 17:37:10 +010041 CommandHandlerFunctor* GetFunctor(uint32_t familyId, uint32_t packetId, uint32_t version) const;
Francis Murtagh94d79152019-08-16 17:45:07 +010042
43private:
44 std::unordered_map<CommandHandlerKey, CommandHandlerFunctor*, CommandHandlerHash> registry;
Aron Virginas-Tare898db92019-08-22 12:56:34 +010045};
46
47} // namespace profiling
48
49} // namespace armnn