libs: added callback-connector to SDK

This commit is contained in:
hedger 2024-02-19 09:34:51 +00:00
parent b15787053a
commit 02a827da38
No known key found for this signature in database
GPG Key ID: BC19012910E3C2CF
4 changed files with 15 additions and 4 deletions

View File

@ -48,4 +48,6 @@ libs = env.BuildModules(
],
)
env.Append(SDK_HEADERS=[File("#/lib/callback-connector/callback-connector.h")])
Return("libs")

View File

@ -1,10 +1,13 @@
#ifndef CALLBACKCONNECTOR_H
#define CALLBACKCONNECTOR_H
#ifdef __cplusplus
#include <functional>
namespace cbc {
namespace Details {
template <std::size_t Tag, typename T, typename Ret, typename... Args> class FuncMemberWrapper {
template <std::size_t Tag, typename T, typename Ret, typename... Args>
class FuncMemberWrapper {
public:
FuncMemberWrapper() = delete;
using member_fun_t = Ret (T::*)(Args...);
@ -43,7 +46,8 @@ template <std::size_t Tag, typename T, typename Ret, typename... Args>
typename FuncMemberWrapper<Tag, T, Ret, Args...>::const_member_fun_t
FuncMemberWrapper<Tag, T, Ret, Args...>::const_member{};
template <typename Functor, typename Ret, typename... Args> struct FunctorWrapper {
template <typename Functor, typename Ret, typename... Args>
struct FunctorWrapper {
public:
static std::function<Ret(Args...)> functor;
static auto instatiate(Functor fn) {
@ -75,7 +79,8 @@ auto const_instantiate(T* t, Ret (T::*ptr)(Args...) const) {
return FuncMemberWrapper<tag, T, Ret, Args...>::instantiate(t, ptr);
}
template <std::size_t tag, typename T, typename Func> auto const_instantiate(T* t, Func ptr) {
template <std::size_t tag, typename T, typename Func>
auto const_instantiate(T* t, Func ptr) {
return const_instantiate(t, ptr);
}
@ -91,9 +96,11 @@ auto obtain_connector(T* t, Ret (T::*ptr)(Args...) const) {
return Details::FuncMemberWrapper<tag, T, Ret, Args...>::instantiate(t, ptr);
}
template <typename Functor> auto obtain_connector(Functor functor) {
template <typename Functor>
auto obtain_connector(Functor functor) {
return Details::deducer(std::move(functor), &Functor::operator());
}
} //end of cbc scope
#endif // __cplusplus
#endif // CALLBACKCONNECTOR_H

View File

@ -40,6 +40,7 @@ Header,+,applications/services/storage/storage.h,,
Header,+,lib/bit_lib/bit_lib.h,,
Header,+,lib/ble_profile/extra_profiles/hid_profile.h,,
Header,+,lib/ble_profile/extra_services/hid_service.h,,
Header,+,lib/callback-connector/callback-connector.h,,
Header,+,lib/datetime/datetime.h,,
Header,+,lib/digital_signal/digital_sequence.h,,
Header,+,lib/digital_signal/digital_signal.h,,

1 entry status name type params
40 Header + lib/bit_lib/bit_lib.h
41 Header + lib/ble_profile/extra_profiles/hid_profile.h
42 Header + lib/ble_profile/extra_services/hid_service.h
43 Header + lib/callback-connector/callback-connector.h
44 Header + lib/datetime/datetime.h
45 Header + lib/digital_signal/digital_sequence.h
46 Header + lib/digital_signal/digital_signal.h

View File

@ -41,6 +41,7 @@ Header,+,applications/services/storage/storage.h,,
Header,+,lib/bit_lib/bit_lib.h,,
Header,+,lib/ble_profile/extra_profiles/hid_profile.h,,
Header,+,lib/ble_profile/extra_services/hid_service.h,,
Header,+,lib/callback-connector/callback-connector.h,,
Header,+,lib/datetime/datetime.h,,
Header,+,lib/digital_signal/digital_sequence.h,,
Header,+,lib/digital_signal/digital_signal.h,,

1 entry status name type params
41 Header + lib/bit_lib/bit_lib.h
42 Header + lib/ble_profile/extra_profiles/hid_profile.h
43 Header + lib/ble_profile/extra_services/hid_service.h
44 Header + lib/callback-connector/callback-connector.h
45 Header + lib/datetime/datetime.h
46 Header + lib/digital_signal/digital_sequence.h
47 Header + lib/digital_signal/digital_signal.h