* @brief Processes a batch of timestamped frames into the SQLite database. */
| 184 | * @brief Processes a batch of timestamped frames into the SQLite database. |
| 185 | */ |
| 186 | void Sessions::ExportWorker::processItems(const std::vector<DataModel::TimestampedFramePtr>& items) |
| 187 | { |
| 188 | if (items.empty()) |
| 189 | return; |
| 190 | |
| 191 | if (!m_dbOpen) { |
| 192 | createDatabase(items.front()->data); |
| 193 | |
| 194 | if (!m_dbOpen) |
| 195 | return; |
| 196 | |
| 197 | m_steadyBaseline = items.front()->timestamp; |
| 198 | resetMonotonicClock(); |
| 199 | } |
| 200 | |
| 201 | m_db->transaction(); |
| 202 | for (const auto& frame : items) |
| 203 | writeFrameReadings(frame); |
| 204 | |
| 205 | if (!m_db->commit()) [[unlikely]] { |
| 206 | qWarning() << "[Sessions::Export] commit() failed:" << m_db->lastError().text(); |
| 207 | m_db->rollback(); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * @brief Creates the SQLite database file and writes the schema and session. |