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

paulmthompson / WhiskerToolbox / 17846711083

19 Sep 2025 02:28AM UTC coverage: 72.02% (+0.08%) from 71.942%
17846711083

push

github

paulmthompson
event in interval computer works with entity ids

259 of 280 new or added lines in 6 files covered. (92.5%)

268 existing lines in 17 files now uncovered.

40247 of 55883 relevant lines covered (72.02%)

1227.29 hits per line

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

70.37
/src/DataManager/utils/TableView/interfaces/IColumnComputer.h
1
#ifndef ICOLUMN_COMPUTER_H
2
#define ICOLUMN_COMPUTER_H
3

4
#include "utils/TableView/core/ExecutionPlan.h"
5
#include "utils/TableView/columns/IColumn.h"
6
#include "Entity/EntityTypes.hpp"
7

8
#include <memory>
9
#include <string>
10
#include <variant>
11
#include <vector>
12

13
/**
14
 * @brief Templated interface for computing column values in a batch operation.
15
 * 
16
 * This interface defines the strategy for computing all values in a column
17
 * in a single batch operation. Different implementations can provide
18
 * different computation strategies (direct access, interval reductions,
19
 * transformations, etc.). The template parameter T allows for heterogeneous
20
 * column types.
21
 */
22
template<typename T>
23
class IColumnComputer {
24
public:
25
    virtual ~IColumnComputer() = default;
608✔
26

27
    // Make this class non-copyable and non-movable since it's a pure interface
28
    IColumnComputer(IColumnComputer const &) = delete;
29
    IColumnComputer & operator=(IColumnComputer const &) = delete;
30
    IColumnComputer(IColumnComputer &&) = delete;
31
    IColumnComputer & operator=(IColumnComputer &&) = delete;
32

33
    /**
34
     * @brief The core batch computation method.
35
     * 
36
     * This method performs the actual computation of all column values
37
     * based on the provided execution plan. The execution plan contains
38
     * the cached access patterns (indices or intervals) for the data source.
39
     * 
40
     * @param plan The execution plan containing cached access patterns.
41
     * @return Vector of computed values for the entire column.
42
     */
43
    [[nodiscard]] virtual auto compute(ExecutionPlan const & plan) const -> std::vector<T> = 0;
44

45
    /**
46
     * @brief Declares dependencies on other columns.
47
     * 
48
     * For transformed columns that depend on other columns, this method
49
     * returns the names of the columns that must be computed first.
50
     * 
51
     * @return Vector of column names this computer depends on.
52
     */
53
    [[nodiscard]] virtual auto getDependencies() const -> std::vector<std::string> {
305✔
54
        return {};
305✔
55
    }
56

57
    /**
58
     * @brief Declares the required data source.
59
     * 
60
     * This method returns the name of the data source that this computer
61
     * needs to access (e.g., "LFP", "Spikes.x").
62
     * 
63
     * @return The name of the required data source.
64
     */
65
    [[nodiscard]] virtual auto getSourceDependency() const -> std::string = 0;
66

67
    /**
68
     * @brief Gets the EntityID structure type for this computer.
69
     * 
70
     * This indicates whether the computer provides no EntityIDs, simple EntityIDs
71
     * (one per row), or complex EntityIDs (multiple per row).
72
     * 
73
     * @return The EntityID structure type for this computer.
74
     */
UNCOV
75
    [[nodiscard]] virtual EntityIdStructure getEntityIdStructure() const { 
×
UNCOV
76
        return EntityIdStructure::None; 
×
77
    }
78

79
    /**
80
     * @brief Computes all EntityIDs for the column using the high-level variant approach.
81
     * 
82
     * The returned variant contains one of:
83
     * - std::monostate: No EntityIDs available
84
     * - std::vector<EntityId>: One EntityID per row (simple)
85
     * - std::vector<std::vector<EntityId>>: Multiple EntityIDs per row (complex)
86
     * 
87
     * Note: Shared EntityID collections are typically handled at the Column level
88
     * for table transforms, not at the computer level.
89
     * 
90
     * @param plan The execution plan used for computation.
91
     * @return ColumnEntityIds variant containing the EntityIDs for this column.
92
     */
UNCOV
93
    [[nodiscard]] virtual ColumnEntityIds computeColumnEntityIds(ExecutionPlan const & plan) const { 
×
94
        (void)plan; 
UNCOV
95
        return std::monostate{}; 
×
96
    }
97

98
    /**
99
     * @brief Computes EntityIDs for a specific row.
100
     * 
101
     * This is a convenience method that works across all EntityID structures.
102
     * 
103
     * @param plan The execution plan used for computation.
104
     * @param row_index The row index to get EntityIDs for.
105
     * @return Vector of EntityIDs for the specified row. Empty if not available.
106
     */
107
    [[nodiscard]] virtual std::vector<EntityId> computeCellEntityIds(ExecutionPlan const & plan, size_t row_index) const {
40✔
108
        auto structure = getEntityIdStructure();
40✔
109
        if (structure == EntityIdStructure::None) {
40✔
110
            return {};
2✔
111
        }
112
        
113
        auto column_entities = computeColumnEntityIds(plan);
38✔
114
        
115
        switch (structure) {
38✔
116
            case EntityIdStructure::Simple: {
18✔
117
                auto& entities = std::get<std::vector<EntityId>>(column_entities);
18✔
118
                return (row_index < entities.size()) ? std::vector<EntityId>{entities[row_index]} : std::vector<EntityId>{};
54✔
119
            }
120
            case EntityIdStructure::Complex: {
20✔
121
                auto& entity_matrix = std::get<std::vector<std::vector<EntityId>>>(column_entities);
20✔
122
                return (row_index < entity_matrix.size()) ? entity_matrix[row_index] : std::vector<EntityId>{};
20✔
123
            }
UNCOV
124
            case EntityIdStructure::Shared:
×
125
                // Shared collections not typically used at computer level
UNCOV
126
                return {};
×
UNCOV
127
            case EntityIdStructure::None:
×
128
            default:
UNCOV
129
                return {};
×
130
        }
131
    }
38✔
132

133
    /**
134
     * @brief Checks if this computer can provide EntityID information.
135
     * @return True if EntityIDs are available, false otherwise.
136
     */
137
    [[nodiscard]] virtual bool hasEntityIds() const { 
16✔
138
        return getEntityIdStructure() != EntityIdStructure::None; 
16✔
139
    }
140

141
protected:
142
    // Protected constructor to allow derived classes to construct
143
    IColumnComputer() = default;
608✔
144
};
145

146
#endif// ICOLUMN_COMPUTER_H
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