• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

paulmthompson / WhiskerToolbox / 17920603410

22 Sep 2025 03:39PM UTC coverage: 71.97% (-0.05%) from 72.02%
17920603410

push

github

paulmthompson
all tests pass

277 of 288 new or added lines in 8 files covered. (96.18%)

520 existing lines in 35 files now uncovered.

40275 of 55961 relevant lines covered (71.97%)

1225.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.72
/src/DataManager/utils/TableView/adapters/LineDataAdapter.cpp
1
#include "LineDataAdapter.h"
2

3
#include "Lines/Line_Data.hpp"
4

5
#include <stdexcept>
6

7
LineDataAdapter::LineDataAdapter(std::shared_ptr<LineData> lineData,
46✔
8
                                 std::shared_ptr<TimeFrame> timeFrame,
9
                                 std::string name)
46✔
10
    : m_lineData(std::move(lineData)),
46✔
11
      m_timeFrame(std::move(timeFrame)),
46✔
12
      m_name(std::move(name)) {
92✔
13
    if (!m_lineData) {
46✔
14
        throw std::invalid_argument("LineData cannot be null");
×
15
    }
16
}
46✔
17

18
auto LineDataAdapter::getName() const -> std::string const & {
27✔
19
    return m_name;
27✔
20
}
21

22
auto LineDataAdapter::getTimeFrame() const -> std::shared_ptr<TimeFrame> {
9✔
23
    return m_timeFrame;
9✔
24
}
25

26
auto LineDataAdapter::size() const -> size_t {
×
27
    // Count total number of lines across all time frames
28
    size_t totalLines = 0;
×
29
    for (auto const & [time, lines]: m_lineData->GetAllLinesAsRange()) {
×
30
        totalLines += lines.size();
×
31
    }
32
    return totalLines;
×
33
}
34

35
auto LineDataAdapter::getLines() -> std::vector<Line2D> {
×
36
    std::vector<Line2D> allLines;
×
37

38
    // Collect all lines from all time frames
39
    for (auto const & [time, lines]: m_lineData->GetAllLinesAsRange()) {
×
40
        allLines.insert(allLines.end(), lines.begin(), lines.end());
×
41
    }
42

43
    return allLines;
×
44
}
×
45

46
auto LineDataAdapter::getLinesInRange(TimeFrameIndex start,
8✔
47
                                      TimeFrameIndex end,
48
                                      TimeFrame const * target_timeFrame) -> std::vector<Line2D> {
49
    // Fast path: when start == end, avoid constructing a ranges pipeline.
50
    // Directly fetch the lines at the single time index using timeframe conversion.
51
    if (start == end) {
8✔
52
        auto const & lines_ref = m_lineData->getAtTime(start, target_timeFrame, m_timeFrame.get());
8✔
53
        return {lines_ref.begin(), lines_ref.end()};
24✔
54
    }
55

56
    // Use the LineData's built-in method to get lines in the time range.
57
    // This method handles the time frame conversion internally via a lazy view.
58
    auto lines_view = m_lineData->GetLinesInRange(TimeFrameInterval(start, end),
×
59
                                                  target_timeFrame,
60
                                                  m_timeFrame.get());
×
61

62
    // Materialize the view into a vector
63
    std::vector<Line2D> result;
×
64
    for (auto const & timeLinesPair: lines_view) {
×
65
        result.insert(result.end(), timeLinesPair.lines.begin(), timeLinesPair.lines.end());
×
66
    }
67

68
    return result;
×
69
}
×
70

71
bool LineDataAdapter::hasMultiSamples() const {
167✔
72
    // Check if any timestamp has more than one line
73
    for (auto const & [time, lines]: m_lineData->GetAllLinesAsRange()) {
457✔
74
        if (lines.size() > 1) {
408✔
75
            return true;
118✔
76
        }
77
    }
78
    return false;
49✔
79
}
80

81
auto LineDataAdapter::getEntityCountAt(TimeFrameIndex t) const -> size_t {
58✔
82
    auto const & lines_ref = m_lineData->getAtTime(t, m_timeFrame.get(), m_timeFrame.get());
58✔
83
    return lines_ref.size();
58✔
84
}
85

86
auto LineDataAdapter::getLineAt(TimeFrameIndex t, int entityIndex) const -> Line2D const * {
49✔
87
    auto const & lines_ref = m_lineData->getAtTime(t, m_timeFrame.get(), m_timeFrame.get());
49✔
88
    if (entityIndex < 0 || static_cast<size_t>(entityIndex) >= lines_ref.size()) {
49✔
89
        return nullptr;
×
90
    }
91
    return &lines_ref[static_cast<size_t>(entityIndex)];
49✔
92
}
93

UNCOV
94
EntityId LineDataAdapter::getEntityIdAt(TimeFrameIndex t, int entityIndex) const {
×
UNCOV
95
    auto const & ids = m_lineData->getEntityIdsAtTime(t);
×
UNCOV
96
    if (entityIndex < 0 || static_cast<size_t>(entityIndex) >= ids.size()) return 0;
×
UNCOV
97
    return ids[static_cast<size_t>(entityIndex)];
×
98
}
99

100
std::vector<EntityId> LineDataAdapter::getEntityIdsAtTime(TimeFrameIndex t,
55✔
101
                                                          TimeFrame const * target_timeframe) const {
102
    return m_lineData->getEntityIdsAtTime(t, target_timeframe, m_timeFrame.get());
55✔
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc