From 38587f9009cb026cc455ecf39dff2ec6c60fc35e Mon Sep 17 00:00:00 2001 From: Alessandro Croci Date: Tue, 9 Apr 2024 14:19:07 +0200 Subject: [PATCH] Add getter method to DeviceRegistry to obtain a vector of device keys --- libraries/device-registry/DeviceRegistry.cc | 10 ++++++++++ libraries/device-registry/DeviceRegistry.hh | 2 ++ 2 files changed, 12 insertions(+) diff --git a/libraries/device-registry/DeviceRegistry.cc b/libraries/device-registry/DeviceRegistry.cc index d21552e..b93581d 100644 --- a/libraries/device-registry/DeviceRegistry.cc +++ b/libraries/device-registry/DeviceRegistry.cc @@ -120,6 +120,16 @@ yarp::dev::PolyDriver* DeviceRegistry::getDevice(const std::string& deviceDataba return tmp; } +std::vector DeviceRegistry::getDevicesKeys() const +{ + std::vector keys; + for (auto&& [key, value] : m_devicesMap) + keys.push_back(key); + return keys; +} + +// Private methods + void DeviceRegistry::removeDevice(const std::string& deviceDatabaseKey) { DevicesMap::iterator device = m_devicesMap.find(deviceDatabaseKey); diff --git a/libraries/device-registry/DeviceRegistry.hh b/libraries/device-registry/DeviceRegistry.hh index 7915526..568822e 100644 --- a/libraries/device-registry/DeviceRegistry.hh +++ b/libraries/device-registry/DeviceRegistry.hh @@ -22,6 +22,8 @@ public: void removeDevice(const std::string& deviceDatabaseKey); + std::vector getDevicesKeys() const; + private: DeviceRegistry(); static DeviceRegistry* s_handle;