* @brief Caches per-channel sample values keyed by timestamp (or sample index as fallback). */
| 108 | * @brief Caches per-channel sample values keyed by timestamp (or sample index as fallback). |
| 109 | */ |
| 110 | bool OnSample(uint64_t sample, uint64_t record_id, const std::vector<uint8_t>& record) override |
| 111 | { |
| 112 | if (record_id != m_recordId) |
| 113 | return true; |
| 114 | |
| 115 | uint64_t cacheKey = sample; |
| 116 | if (m_groupTimeChannel) { |
| 117 | double ts = 0.0; |
| 118 | const bool success = GetEngValue(*m_groupTimeChannel, record_id, record, ts); |
| 119 | if (!success) |
| 120 | GetChannelValue(*m_groupTimeChannel, record_id, record, ts); |
| 121 | |
| 122 | cacheKey = static_cast<uint64_t>(ts * 1'000'000'000.0); |
| 123 | m_timestampCache[cacheKey] = ts; |
| 124 | } |
| 125 | |
| 126 | auto cacheIt = m_cache.find(cacheKey); |
| 127 | if (cacheIt == m_cache.end()) |
| 128 | cacheIt = m_cache.emplace(cacheKey, std::vector<double>(m_allChannels.size(), 0.0)).first; |
| 129 | |
| 130 | auto activeIt = m_activeChannels.find(cacheKey); |
| 131 | if (activeIt == m_activeChannels.end()) |
| 132 | activeIt = |
| 133 | m_activeChannels.emplace(cacheKey, std::vector<bool>(m_allChannels.size(), false)).first; |
| 134 | |
| 135 | auto& values = cacheIt->second; |
| 136 | auto& active = activeIt->second; |
| 137 | |
| 138 | std::vector<QString>* strings = nullptr; |
| 139 | if (m_hasStringChannels) { |
| 140 | auto strIt = m_stringCache.find(cacheKey); |
| 141 | if (strIt == m_stringCache.end()) |
| 142 | strIt = m_stringCache.emplace(cacheKey, std::vector<QString>(m_allChannels.size())).first; |
| 143 | |
| 144 | strings = &strIt->second; |
| 145 | } |
| 146 | |
| 147 | for (auto* channel : m_groupChannels) { |
| 148 | if (!channel) |
| 149 | continue; |
| 150 | |
| 151 | auto it = m_channelIndexMap.find(channel); |
| 152 | if (it == m_channelIndexMap.end()) |
| 153 | continue; |
| 154 | |
| 155 | if (strings && isStringChannel(channel)) { |
| 156 | std::string text; |
| 157 | const bool success = GetEngValue(*channel, record_id, record, text); |
| 158 | if (!success) |
| 159 | (void)GetChannelValue(*channel, record_id, record, text); |
| 160 | |
| 161 | (*strings)[it->second] = QString::fromStdString(text); |
| 162 | active[it->second] = true; |
| 163 | continue; |
| 164 | } |
| 165 | |
| 166 | double value = 0.0; |
| 167 | const bool success = GetEngValue(*channel, record_id, record, value); |
nothing calls this directly
no test coverage detected