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

paulmthompson / WhiskerToolbox / 18117112849

30 Sep 2025 02:44AM UTC coverage: 70.161% (+0.03%) from 70.132%
18117112849

push

github

paulmthompson
hungarian algorithm is actually used

60 of 77 new or added lines in 2 files covered. (77.92%)

352 existing lines in 12 files now uncovered.

45125 of 64316 relevant lines covered (70.16%)

1116.85 hits per line

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

52.63
/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,
88✔
8
                                 std::shared_ptr<TimeFrame> timeFrame,
9
                                 std::string name)
88✔
10
    : m_lineData(std::move(lineData)),
88✔
11
      m_timeFrame(std::move(timeFrame)),
88✔
12
      m_name(std::move(name)) {
176✔
13
    if (!m_lineData) {
88✔
14
        throw std::invalid_argument("LineData cannot be null");
×
15
    }
16
}
88✔
17

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

22
auto LineDataAdapter::getTimeFrame() const -> std::shared_ptr<TimeFrame> {
21✔
23
    return m_timeFrame;
21✔
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();
×
UNCOV
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());
×
UNCOV
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());
×
UNCOV
66
    }
×
67

68
    return result;
×
69
}
×
70

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

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

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

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

100
std::vector<EntityId> LineDataAdapter::getEntityIdsAtTime(TimeFrameIndex t,
137✔
101
                                                          TimeFrame const * target_timeframe) const {
102
    return m_lineData->getEntityIdsAtTime(t, target_timeframe, m_timeFrame.get());
137✔
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