+string HardwareDevice::display_name(
+ const DeviceManager &device_manager) const {
+ const auto hw_dev = hardware_device();
+
+ // If we can find another device with the same model/vendor then
+ // we have at least two such devices and need to distinguish them.
+ const auto &devices = device_manager.devices();
+ const bool multiple_dev = hw_dev && any_of(
+ devices.begin(), devices.end(),
+ [&](shared_ptr<devices::HardwareDevice> dev) {
+ return dev->hardware_device()->vendor() ==
+ hw_dev->vendor() &&
+ dev->hardware_device()->model() ==
+ hw_dev->model() &&
+ dev->device_ != device_;
+ });
+
+ vector<string> parts = {device_->vendor(), device_->model()};
+
+ if (multiple_dev) {
+ parts.push_back(device_->version());
+ parts.push_back(device_->serial_number());
+
+ if ((device_->serial_number().length() == 0) &&
+ (device_->connection_id().length() > 0))
+ parts.push_back("(" + device_->connection_id() + ")");
+ }
+
+ return join(parts, " ");
+}
+