SRSDK  0.10.39
Loading...
Searching...
No Matches
experimental.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace leia {
7
8template <class _Fp>
10
11template <class R, class... Args>
12class ExperimentalAPIEntry<R(Args...)> {
13public:
14 ExperimentalAPIEntry(const char* name, int32_t version) : _name(name), _version(version)
15 {
16 }
17
18 using Func = R (*)(Args...);
19
20 void Load(leia_core_library* coreLibrary)
21 {
22 _func = reinterpret_cast<Func>(leia_get_experimental_api(coreLibrary, _name, _version));
23 }
24
25 R operator()(Args... args) const
26 {
27 return _func(std::forward<Args>(args)...);
28 }
29
30 explicit operator bool() const
31 {
32 return _func != nullptr;
33 }
34
35private:
36 const char* const _name;
37 int32_t const _version;
38
39 Func _func = nullptr;
40};
41
42#define LEIA_CXX_DECLARE_EXPERIMENTAL_API_ENTRY(T) \
43 ExperimentalAPIEntry<typename std::remove_pointer<T>::type> T \
44 { \
45 #T, T##_VERSION \
46 }
47
48} // namespace leia
void Load(leia_core_library *coreLibrary)
Definition experimental.hpp:20
R(*)(Args...) Func
Definition experimental.hpp:18
R operator()(Args... args) const
Definition experimental.hpp:25
ExperimentalAPIEntry(const char *name, int32_t version)
Definition experimental.hpp:14
Definition experimental.hpp:9
BEGIN_CAPI_DECL LEIA_NODISCARD LEIASDK_API void * leia_get_experimental_api(struct leia_core_library *, const char *name, int32_t version)
Get experimental API entry point.
Definition types.hpp:10
Core library.
Definition library.h:17