Matteo Martincigh | 2e7f6ad | 2019-07-24 09:54:26 +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 "IBackendInternal.hpp" |
| 9 | |
| 10 | #include <functional> |
| 11 | #include <memory> |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | class DynamicBackend |
| 17 | { |
| 18 | public: |
| 19 | using HandleCloser = std::function<void(const void*)>; |
| 20 | using HandlePtr = std::unique_ptr<void, HandleCloser>; |
| 21 | |
| 22 | explicit DynamicBackend(const void* sharedObjectHandle); |
| 23 | |
| 24 | /// Public dynamic backend functions |
| 25 | BackendId GetBackendId(); |
| 26 | BackendVersion GetBackendVersion(); |
| 27 | IBackendInternalUniquePtr GetBackend(); |
| 28 | |
| 29 | private: |
| 30 | template<typename BackendFunctionType> |
| 31 | BackendFunctionType SetFunctionPointer(const std::string& backendFunctionName); |
| 32 | |
| 33 | /// Backend function pointer types |
| 34 | using IdFunctionType = const char*(*)(); |
| 35 | using VersionFunctionType = void(*)(uint32_t*, uint32_t*); |
| 36 | using FactoryFunctionType = void*(*)(); |
| 37 | |
| 38 | /// Backend function pointers |
| 39 | IdFunctionType m_BackendIdFunction; |
| 40 | VersionFunctionType m_BackendVersionFunction; |
| 41 | FactoryFunctionType m_BackendFactoryFunction; |
| 42 | |
| 43 | /// Shared object handle |
| 44 | HandlePtr m_Handle; |
| 45 | }; |
| 46 | |
Matteo Martincigh | e54aa06 | 2019-08-05 14:12:11 +0100 | [diff] [blame^] | 47 | using DynamicBackendPtr = std::unique_ptr<DynamicBackend>; |
| 48 | |
Matteo Martincigh | 2e7f6ad | 2019-07-24 09:54:26 +0100 | [diff] [blame] | 49 | } // namespace armnn |