senseApiMgr: new method: loadAllSenseApisFromOptions
This method dlopens() all senseApi libs that were referenced by device specs.
This commit is contained in:
@@ -24,6 +24,7 @@ public:
|
|||||||
std::optional<std::reference_wrapper<SenseApiLib>> getSenseApiLib(
|
std::optional<std::reference_wrapper<SenseApiLib>> getSenseApiLib(
|
||||||
const std::string& libraryPath);
|
const std::string& libraryPath);
|
||||||
void unloadSenseApiLib(const std::string& libraryPath);
|
void unloadSenseApiLib(const std::string& libraryPath);
|
||||||
|
void loadAllSenseApiLibsFromOptions(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SenseApiManager() = default;
|
SenseApiManager() = default;
|
||||||
|
|||||||
@@ -116,5 +116,13 @@ void SenseApiManager::unloadSenseApiLib(const std::string& libraryPath)
|
|||||||
<< libraryPath << '\n';
|
<< libraryPath << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SenseApiManager::loadAllSenseApiLibsFromOptions()
|
||||||
|
{
|
||||||
|
const auto& options = OptionParser::getOptions();
|
||||||
|
for (const auto& libPath : options.senseApiLibs) {
|
||||||
|
loadSenseApiLib(libPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sense_api
|
} // namespace sense_api
|
||||||
} // namespace hk
|
} // namespace hk
|
||||||
|
|||||||
@@ -3,10 +3,13 @@
|
|||||||
#include <opts.h>
|
#include <opts.h>
|
||||||
#include <mind.h>
|
#include <mind.h>
|
||||||
#include <deviceManager/deviceManager.h>
|
#include <deviceManager/deviceManager.h>
|
||||||
|
#include <senseApis/senseApiManager.h>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
using namespace hk;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OptionParser &options = OptionParser::getOptions();
|
OptionParser &options = OptionParser::getOptions();
|
||||||
hk::Mind mind;
|
hk::Mind mind;
|
||||||
@@ -30,6 +33,7 @@ try {
|
|||||||
DeviceManager::getInstance().collateAllDeviceSpecs(options);
|
DeviceManager::getInstance().collateAllDeviceSpecs(options);
|
||||||
DeviceManager::getInstance().parseAllDeviceSpecs();
|
DeviceManager::getInstance().parseAllDeviceSpecs();
|
||||||
std::cout << DeviceManager::printDeviceSpecs() << std::endl;
|
std::cout << DeviceManager::printDeviceSpecs() << std::endl;
|
||||||
|
sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions();
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
std::cerr << "Exception occurred: " << e.what() << std::endl;
|
std::cerr << "Exception occurred: " << e.what() << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user