Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
func_resolver.hpp
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2024 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24#pragma once
25
26#include <cstdint>
27#include <string>
28
29#include <jau/os/dyn_linker.hpp>
30
31namespace jau::os {
32
33 /** \addtogroup OSSup
34 *
35 * @{
36 */
37
38 /** Interface callers may use ProcAddressHelper's
39 * {@link com.jogamp.gluegen.runtime.ProcAddressTable#reset(com.jogamp.common.os.DynamicLookupHelper) reset}
40 * helper method to install function pointers into a
41 * ProcAddressTable. This must typically be written with native
42 * code. */
44 public:
45 virtual ~DynamicLookup() noexcept = default;
46
47 /** Returns the function handle for function `funcName` gathered within the associated native library. */
48 virtual DynamicLinker::symhandle_t dynamicLookupFunction(const std::string& funcName) const noexcept = 0;
49
50 /** Returns the function handle for function `funcName` gathered globally within all loaded libraries. */
51 virtual DynamicLinker::symhandle_t dynamicLookupFunctionGlobal(const std::string& funcName) const noexcept = 0;
52
53 /**
54 * Queries whether function 'funcName' is available.
55 */
56 bool isFunctionAvailable(const std::string& funcName) const noexcept {
57 return 0 != dynamicLookupFunction(funcName);
58 }
59 };
60
62 public:
63 /**
64 * Resolves the name of the function bound to the method and returns the address.
65 * <p>
66 * Implementation shall ensure {@link SecurityUtil#checkLinkPermission(String)} is performed.
67 * </p>
68 * @throws SecurityException if user is not granted access for the library set.
69 */
70 DynamicLinker::symhandle_t resolve(const std::string& name, const DynamicLookup& lookup) const noexcept;
71 };
72
73 /**@}*/
74
75}
Low level secure dynamic linker access.
Definition: dyn_linker.hpp:45
void * symhandle_t
symbol handle within a library
Definition: dyn_linker.hpp:50
Interface callers may use ProcAddressHelper's reset helper method to install function pointers into a...
bool isFunctionAvailable(const std::string &funcName) const noexcept
Queries whether function 'funcName' is available.
virtual DynamicLinker::symhandle_t dynamicLookupFunction(const std::string &funcName) const noexcept=0
Returns the function handle for function funcName gathered within the associated native library.
virtual DynamicLinker::symhandle_t dynamicLookupFunctionGlobal(const std::string &funcName) const noexcept=0
Returns the function handle for function funcName gathered globally within all loaded libraries.
virtual ~DynamicLookup() noexcept=default
DynamicLinker::symhandle_t resolve(const std::string &name, const DynamicLookup &lookup) const noexcept
Resolves the name of the function bound to the method and returns the address.
Author: Sven Gothel sgothel@jausoft.com Copyright (c) 2024 Gothel Software e.K.
Definition: dyn_linker.hpp:37
STL namespace.