aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/CommandHandlerRegistry.cpp
blob: d392db05340f0642f5f20c88f1d29d24e8de164a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "CommandHandlerRegistry.hpp"

#include <boost/assert.hpp>
#include <boost/log/trivial.hpp>

void CommandHandlerRegistry::RegisterFunctor(CommandHandlerFunctor* functor, uint32_t packetId, uint32_t version)
{
    BOOST_ASSERT_MSG(functor, "Provided functor should not be a nullptr.");
    CommandHandlerKey key(packetId, version);
    registry[key] = functor;
}

CommandHandlerFunctor* CommandHandlerRegistry::GetFunctor(uint32_t packetId, uint32_t version) const
{
    CommandHandlerKey key(packetId, version);

    // Check that the requested key exists
    if (registry.find(key) == registry.end())
    {
        throw armnn::Exception("Functor with requested PacketId or Version does not exist.");
    }

    return registry.at(key);
}