• 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

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

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

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

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

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

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

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

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

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

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

99
    /**
100
     * @brief Computes EntityIDs for a specific row.
101
     * 
102
     * This is a convenience method that works across all EntityID structures.
103
     * 
104
     * @param plan The execution plan used for computation.
105
     * @param row_index The row index to get EntityIDs for.
106
     * @return Vector of EntityIDs for the specified row. Empty if not available.
107
     */
UNCOV
108
    [[nodiscard]] virtual std::vector<EntityId> computeCellEntityIds(ExecutionPlan const & plan, size_t row_index) const {
×
UNCOV
109
        auto structure = getEntityIdStructure();
×
UNCOV
110
        if (structure == EntityIdStructure::None) {
×
UNCOV
111
            return {};
×
112
        }
113

UNCOV
114
        auto column_entities = computeColumnEntityIds(plan);
×
115

UNCOV
116
        switch (structure) {
×
UNCOV
117
            case EntityIdStructure::Simple: {
×
UNCOV
118
                auto & entities = std::get<std::vector<EntityId>>(column_entities);
×
UNCOV
119
                return (row_index < entities.size()) ? std::vector<EntityId>{entities[row_index]} : std::vector<EntityId>{};
×
120
            }
UNCOV
121
            case EntityIdStructure::Complex: {
×
UNCOV
122
                auto & entity_matrix = std::get<std::vector<std::vector<EntityId>>>(column_entities);
×
UNCOV
123
                return (row_index < entity_matrix.size()) ? entity_matrix[row_index] : std::vector<EntityId>{};
×
124
            }
UNCOV
125
            case EntityIdStructure::Shared:
×
126
                // Shared collections not typically used at computer level
127
                return {};
×
UNCOV
128
            case EntityIdStructure::None:
×
129
            default:
UNCOV
130
                return {};
×
131
        }
UNCOV
132
    }
×
133

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

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

147
#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