SenseApiMgr: add initialize/finalizeAllSenseApiLibs()

Also, SenseApiDesc: initializeInd() now takes void. We no longer
try to pass a struct of marionette-role ops into the libs. We'll
be using message queueing for the handshake side of async calls now.
This commit is contained in:
2025-01-12 09:44:49 -04:00
parent c8a7a6678f
commit b85d6f76a6
5 changed files with 51 additions and 3 deletions
@@ -25,7 +25,14 @@ public:
std::optional<std::reference_wrapper<SenseApiLib>> getSenseApiLib(
const std::string& libraryPath);
void unloadSenseApiLib(const std::string& libraryPath);
void initializeSenseApiLib(SenseApiLib& lib);
void finalizeSenseApiLib(SenseApiLib& lib);
void loadAllSenseApiLibsFromOptions(void);
void unloadAllSenseApiLibs(void);
void initializeAllSenseApiLibs(void);
void finalizeAllSenseApiLibs(void);
std::string stringifyLibs() const;
+41
View File
@@ -135,6 +135,11 @@ void SenseApiManager::unloadSenseApiLib(const std::string& libraryPath)
<< libraryPath << '\n';
}
void SenseApiManager::unloadAllSenseApiLibs(void)
{
senseApiLibs.clear();
}
void SenseApiManager::loadAllSenseApiLibsFromOptions()
{
const auto& options = OptionParser::getOptions();
@@ -152,5 +157,41 @@ std::string SenseApiManager::stringifyLibs() const
return result;
}
void SenseApiManager::initializeSenseApiLib(SenseApiLib& lib)
{
if (!lib.getSenseApiDesc()->sal_mgmt_libOps->initializeInd)
{
throw std::runtime_error(
std::string(__func__) + ": initializeInd() is NULL for library '"
+ lib.libraryPath + "'");
}
lib.getSenseApiDesc()->sal_mgmt_libOps->initializeInd();
}
void SenseApiManager::finalizeSenseApiLib(SenseApiLib& lib)
{
if (!lib.getSenseApiDesc()->sal_mgmt_libOps->finalizeInd)
{
throw std::runtime_error(
std::string(__func__) + ": finalizeInd() is NULL for library '"
+ lib.libraryPath + "'");
}
lib.getSenseApiDesc()->sal_mgmt_libOps->finalizeInd();
}
void SenseApiManager::initializeAllSenseApiLibs(void)
{
for (auto& lib : senseApiLibs) {
initializeSenseApiLib(*lib);
}
}
void SenseApiManager::finalizeAllSenseApiLibs(void)
{
for (auto& lib : senseApiLibs) {
finalizeSenseApiLib(*lib);
}
}
} // namespace sense_api
} // namespace hk
+1 -1
View File
@@ -33,7 +33,7 @@ struct Csal_mgmt_hkOps
sal_mho_detachDeviceAckFn *detachDeviceAck;
};
typedef int (sal_mlo_initializeIndFn)(Csal_mgmt_hkOps *hkOps);
typedef int (sal_mlo_initializeIndFn)(void);
typedef int (sal_mlo_finalizeIndFn)(void);
typedef int (sal_mlo_attachDeviceReqFn)(void);
typedef int (sal_mlo_detachDeviceReqFn)(void);
+1
View File
@@ -90,6 +90,7 @@ static int initializeHarikoff(int argc, char **argv, char **envp)
DeviceManager::getInstance().parseAllDeviceSpecs();
std::cout << DeviceManager::stringifyDeviceSpecs() << std::endl;
sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions();
sense_api::SenseApiManager::getInstance().initializeAllSenseApiLibs();
std::cout << sense_api::SenseApiManager::getInstance().stringifyLibs()
<< std::endl;
+1 -2
View File
@@ -41,9 +41,8 @@ const CSenseApiDesc *HK_GET_SENSE_API_DESC_FN_NAME(void)
}
static sal_mlo_initializeIndFn xcbXorg_initializeInd;
int xcbXorg_initializeInd(Csal_mgmt_hkOps *hkOps)
int xcbXorg_initializeInd(void)
{
(void)hkOps;
std::cerr << "XcbXorg::sal_mlo_initializeInd\n";
return 0;
}