Add stringifiers to SenseApi related classes

This commit is contained in:
2025-01-11 06:40:43 -04:00
parent 8aa28a877e
commit c6577b1155
4 changed files with 28 additions and 0 deletions
+15
View File
@@ -51,6 +51,15 @@ public:
std::string name; std::string name;
// These are the implexors whose APIs this lib exports. // These are the implexors whose APIs this lib exports.
std::vector<ExportedImplexorApiDesc> exportedImplexorApis; std::vector<ExportedImplexorApiDesc> exportedImplexorApis;
std::string stringify() const {
std::string result = "Name: " + name + "\n";
result += "Exported Implexor APIs:\n";
for (const auto& api : exportedImplexorApis) {
result += " - " + api.name + "\n";
}
return result;
}
}; };
class SenseApiLib class SenseApiLib
@@ -111,6 +120,12 @@ public:
* descriptor. * descriptor.
*/ */
SenseApiDesc senseApiDesc; SenseApiDesc senseApiDesc;
std::string stringify() const {
std::string result = "Library Path: " + libraryPath + "\n";
result += "Sense API Descriptor: " + senseApiDesc.stringify() + "\n";
return result;
}
}; };
} // namespace sense_api } // namespace sense_api
@@ -26,6 +26,8 @@ public:
void unloadSenseApiLib(const std::string& libraryPath); void unloadSenseApiLib(const std::string& libraryPath);
void loadAllSenseApiLibsFromOptions(void); void loadAllSenseApiLibsFromOptions(void);
std::string stringifyLibs() const;
private: private:
SenseApiManager() = default; SenseApiManager() = default;
~SenseApiManager() = default; ~SenseApiManager() = default;
+9
View File
@@ -151,5 +151,14 @@ void SenseApiManager::loadAllSenseApiLibsFromOptions()
} }
} }
std::string SenseApiManager::stringifyLibs() const
{
std::string result;
for (const auto& lib : senseApiLibs) {
result += lib->stringify() + "\n";
}
return result;
}
} // namespace sense_api } // namespace sense_api
} // namespace hk } // namespace hk
+2
View File
@@ -90,6 +90,8 @@ static int initializeHarikoff(int argc, char **argv, char **envp)
DeviceManager::getInstance().parseAllDeviceSpecs(); DeviceManager::getInstance().parseAllDeviceSpecs();
std::cout << DeviceManager::stringifyDeviceSpecs() << std::endl; std::cout << DeviceManager::stringifyDeviceSpecs() << std::endl;
sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions(); sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions();
std::cout << sense_api::SenseApiManager::getInstance().stringifyLibs()
<< std::endl;
/* Start the threads */ /* Start the threads */
for (const auto& [id, componentThread] for (const auto& [id, componentThread]