* @brief Processes a batch of console data items, routing to per-device files. */
| 68 | * @brief Processes a batch of console data items, routing to per-device files. |
| 69 | */ |
| 70 | void Console::ExportWorker::processItems(const std::vector<ExportDataPtr>& items) |
| 71 | { |
| 72 | if (items.empty()) |
| 73 | return; |
| 74 | |
| 75 | if (!IO::ConnectionManager::instance().isConnected()) |
| 76 | return; |
| 77 | |
| 78 | for (const auto& dataPtr : items) { |
| 79 | const int devId = dataPtr->deviceId; |
| 80 | auto it = m_deviceFiles.find(devId); |
| 81 | if (it == m_deviceFiles.end() || !it->second.file || !it->second.file->isOpen()) |
| 82 | createFile(devId); |
| 83 | |
| 84 | it = m_deviceFiles.find(devId); |
| 85 | if (it != m_deviceFiles.end() && it->second.stream && it->second.stream->device()) { |
| 86 | *it->second.stream << dataPtr->data; |
| 87 | it->second.stream->flush(); |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @brief Closes all per-device output files. |
nothing calls this directly
no test coverage detected