Build: Add XCB_LIBS; Skeleton: mlo_initializeInd, mlo_attachDeviceReq
* Renamed some of the Sense API lib classes (CSensorDeviceDesc=>CSenseDeviceDesc, SensorDeviceDesc=>SenseDeviceDesc). * Moved SenseApiDesc into /include/user/senseApiDesc. * Add conversion constructor to convert from SenseDeviceDesc to * Wireframe mlo_initializeInd to call xcb_connect(). * Add $(XCB_LIBS) to libxcbXorg_LDFLAGS. * Wireframe mlo_attachDeviceReq().
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <senseApis/senseApiLib.h>
|
||||
#include <opts.h>
|
||||
#include <user/senseApiDesc.h>
|
||||
#include <deviceManager/deviceManager.h>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@@ -117,6 +118,19 @@ SenseApiManager::getSenseApiLib(const std::string& libraryPath)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::reference_wrapper<SenseApiLib>>
|
||||
SenseApiManager::getSenseApiLibByApiName(const std::string& apiName)
|
||||
{
|
||||
auto it = std::find_if(senseApiLibs.begin(), senseApiLibs.end(),
|
||||
[&apiName](const std::unique_ptr<SenseApiLib>& lib) {
|
||||
return lib->getSenseApiDesc()->name == apiName;
|
||||
}
|
||||
);
|
||||
|
||||
if (it != senseApiLibs.end()) { return **it; }
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void SenseApiManager::unloadSenseApiLib(const std::string& libraryPath)
|
||||
{
|
||||
auto it = std::find_if(senseApiLibs.begin(), senseApiLibs.end(),
|
||||
@@ -193,5 +207,61 @@ void SenseApiManager::finalizeAllSenseApiLibs(void)
|
||||
}
|
||||
}
|
||||
|
||||
void SenseApiManager::attachSenseDevice(
|
||||
const SenseDeviceSpec& spec)
|
||||
{
|
||||
auto libOpt = getSenseApiLibByApiName(spec.api);
|
||||
if (!libOpt)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": No library found for API '"
|
||||
+ spec.api + "'");
|
||||
}
|
||||
auto& lib = libOpt.value().get();
|
||||
if (!lib.getSenseApiDesc()->sal_mgmt_libOps->attachDeviceReq)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": attachDeviceReq() is NULL for library '"
|
||||
+ lib.libraryPath + "'");
|
||||
}
|
||||
CSenseDeviceSpec cSpec(spec);
|
||||
lib.getSenseApiDesc()->sal_mgmt_libOps->attachDeviceReq(&cSpec);
|
||||
}
|
||||
|
||||
void SenseApiManager::detachSenseDevice(
|
||||
const SenseDeviceSpec& spec)
|
||||
{
|
||||
auto libOpt = getSenseApiLibByApiName(spec.api);
|
||||
if (!libOpt)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": No library found for API '"
|
||||
+ spec.api + "'");
|
||||
}
|
||||
auto& lib = libOpt.value().get();
|
||||
if (!lib.getSenseApiDesc()->sal_mgmt_libOps->detachDeviceReq)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": detachDeviceReq() is NULL for library '"
|
||||
+ lib.libraryPath + "'");
|
||||
}
|
||||
CSenseDeviceSpec cSpec(spec);
|
||||
lib.getSenseApiDesc()->sal_mgmt_libOps->detachDeviceReq(&cSpec);
|
||||
}
|
||||
|
||||
void SenseApiManager::attachAllSenseDevicesFromSpecs(void)
|
||||
{
|
||||
for (const auto& spec : DeviceManager::senseDeviceSpecs) {
|
||||
attachSenseDevice(spec.get());
|
||||
}
|
||||
}
|
||||
|
||||
void SenseApiManager::detachAllSenseDevices(void)
|
||||
{
|
||||
for (const auto& spec : DeviceManager::senseDeviceSpecs) {
|
||||
detachSenseDevice(spec.get());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sense_api
|
||||
} // namespace hk
|
||||
|
||||
Reference in New Issue
Block a user