SenseDevSpec: add NULL checks stringify, ostream::<<

This commit is contained in:
2025-01-13 07:05:05 -04:00
parent 3f9b406fb2
commit 8e94e829d0
2 changed files with 52 additions and 23 deletions
+2 -19
View File
@@ -15,33 +15,16 @@ std::vector<std::unique_ptr<ExtrospectorDeviceSpec>>
std::vector<std::reference_wrapper<SenseDeviceSpec>>
DeviceManager::senseDeviceSpecs;
std::ostream& operator<<(
std::ostream& os, const SenseDeviceSpec& spec)
{
os << "Device: " << spec.sensorType << ", Implexor: "
<< spec.implexor << ", API: " << spec.api
<< ", API Params: (";
for (auto it = spec.apiParams.begin(); it != spec.apiParams.end(); ++it) {
os << *it << (it + 1 == spec.apiParams.end() ? "" : " ");
}
os << "), Provider: " << spec.provider << ", Provider Params: (";
for (auto it = spec.providerParams.begin(); it != spec.providerParams.end(); ++it) {
os << *it << (it + 1 == spec.providerParams.end() ? "" : " ");
}
os << "), Device Selector: " << spec.deviceSelector << std::endl;
return os;
}
const std::string DeviceManager::stringifyDeviceSpecs(void)
{
std::ostringstream oss;
for (const auto& spec : DeviceManager::interoceptorDeviceSpecs) {
oss << "Interoceptor " << *spec;
oss << "Interoceptor " << CSenseDeviceSpec(*spec);
}
for (const auto& spec : DeviceManager::extrospectorDeviceSpecs) {
oss << "Extrospector " << *spec;
oss << "Extrospector " << CSenseDeviceSpec(*spec);
}
return oss.str();