From 48121ec84cbf1c564360ecf786270c9c2c458727 Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Tue, 9 Sep 2025 12:02:40 -0400 Subject: [PATCH] SenseApiMgr: Provide ComponentThread::getSelf access to libs --- include/user/senseApiDesc.h | 9 +++++++++ smocore/senseApis/senseApiManager.cpp | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/user/senseApiDesc.h b/include/user/senseApiDesc.h index 7813e4c..6b514e8 100644 --- a/include/user/senseApiDesc.h +++ b/include/user/senseApiDesc.h @@ -60,6 +60,15 @@ struct SmoCallbacks */ std::optional (*searchForLibInSmoSearchPaths)( const std::string& libraryPath); + + /** + * @brief Get the current ComponentThread instance + * @return Shared pointer to the current ComponentThread + * + * This function provides access to the current ComponentThread instance, + * equivalent to calling ComponentThread::getSelf(). + */ + std::shared_ptr (*ComponentThread_getSelf)(void); }; struct Sal_Mgmt_LibOps diff --git a/smocore/senseApis/senseApiManager.cpp b/smocore/senseApis/senseApiManager.cpp index 1476d97..c8f9170 100644 --- a/smocore/senseApis/senseApiManager.cpp +++ b/smocore/senseApis/senseApiManager.cpp @@ -66,12 +66,19 @@ static std::optional searchForLibInSmoSearchPaths( return std::nullopt; } +/* Local static function to wrap ComponentThread::getSelf for SmoCallbacks */ +static std::shared_ptr ComponentThread_getSelf() +{ + return ComponentThread::getSelf(); +} + /* Hooks to be provided to senseApiLibs, enabling them to call into Salmanoff * code. */ static SmoCallbacks smoCallbacks = { - .searchForLibInSmoSearchPaths = searchForLibInSmoSearchPaths + .searchForLibInSmoSearchPaths = searchForLibInSmoSearchPaths, + .ComponentThread_getSelf = ComponentThread_getSelf }; /* Static file-scope threading model object for senseApi libraries */