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

paulmthompson / WhiskerToolbox / 18685379784

21 Oct 2025 01:25PM UTC coverage: 72.522% (+0.1%) from 72.391%
18685379784

push

github

paulmthompson
fix failing tests

18 of 40 new or added lines in 1 file covered. (45.0%)

1765 existing lines in 32 files now uncovered.

53998 of 74457 relevant lines covered (72.52%)

46177.73 hits per line

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

87.67
/src/DataManager/transforms/TransformRegistry.cpp
1
#include "TransformRegistry.hpp"
2

3
#include "transforms/AnalogTimeSeries/AnalogFilter/analog_filter.hpp"
4
#include "transforms/AnalogTimeSeries/AnalogHilbertPhase/analog_hilbert_phase.hpp"
5
#include "transforms/AnalogTimeSeries/Analog_Event_Threshold/analog_event_threshold.hpp"
6
#include "transforms/AnalogTimeSeries/Analog_Interval_Threshold/analog_interval_threshold.hpp"
7
#include "transforms/AnalogTimeSeries/Analog_Scaling/analog_scaling.hpp"
8
#include "transforms/DigitalIntervalSeries/Digital_Interval_Group/digital_interval_group.hpp"
9
#include "transforms/Lines/Line_Alignment/line_alignment.hpp"
10
#include "transforms/Lines/Line_Angle/line_angle.hpp"
11
#include "transforms/Lines/Line_Base_Flip/line_base_flip.hpp"
12
#include "transforms/Lines/Line_Clip/line_clip.hpp"
13
#include "transforms/Lines/Line_Curvature/line_curvature.hpp"
14
#include "transforms/Lines/Line_Group_To_Intervals/line_group_to_intervals.hpp"
15
#include "transforms/Lines/Line_Index_Grouping/line_index_grouping.hpp"
16
#include "transforms/Lines/Line_Min_Point_Dist/line_min_point_dist.hpp"
17
#include "transforms/Lines/Line_Point_Extraction/line_point_extraction.hpp"
18
#include "transforms/Lines/Line_Proximity_Grouping/line_proximity_grouping.hpp"
19
#include "transforms/Lines/Line_Kalman_Grouping/line_kalman_grouping.hpp"
20
#include "transforms/Lines/Line_Outlier_Detection/line_outlier_detection.hpp"
21
#include "transforms/Lines/Line_Resample/line_resample.hpp"
22
#include "transforms/Lines/Line_Subsegment/line_subsegment.hpp"
23
#include "transforms/Points/Point_Particle_Filter/point_particle_filter.hpp"
24
#include "transforms/Masks/Mask_Area/mask_area.hpp"
25
#include "transforms/Masks/Mask_Centroid/mask_centroid.hpp"
26
#include "transforms/Masks/Mask_Connected_Component/mask_connected_component.hpp"
27
#include "transforms/Masks/Mask_Hole_Filling/mask_hole_filling.hpp"
28
#include "transforms/Masks/Mask_Median_Filter/mask_median_filter.hpp"
29
#include "transforms/Masks/Mask_Principal_Axis/mask_principal_axis.hpp"
30
#include "transforms/Masks/Mask_Skeletonize/mask_skeletonize.hpp"
31
#include "transforms/Masks/Mask_To_Line/mask_to_line.hpp"
32
#include "transforms/Media/whisker_tracing.hpp"
33

34
#include <iostream>// For init messages
35
#include <map>
36
#include <memory>// unique_ptr
37
#include <string>
38
#include <typeindex>
39
#include <variant>// Needed for the public interface
40
#include <vector>
41

42

43
TransformRegistry::TransformRegistry() {
74✔
44

45
    std::cout << "Initializing Operation Registry..." << std::endl;
74✔
46

47
    _registerOperation(std::make_unique<MaskAreaOperation>());
74✔
48
    _registerOperation(std::make_unique<MaskCentroidOperation>());
74✔
49
    _registerOperation(std::make_unique<MaskConnectedComponentOperation>());
74✔
50
    _registerOperation(std::make_unique<MaskHoleFillingOperation>());
74✔
51
    _registerOperation(std::make_unique<MaskMedianFilterOperation>());
74✔
52
    _registerOperation(std::make_unique<MaskPrincipalAxisOperation>());
74✔
53
    _registerOperation(std::make_unique<MaskToLineOperation>());
74✔
54
    _registerOperation(std::make_unique<MaskSkeletonizeOperation>());
74✔
55
    _registerOperation(std::make_unique<EventThresholdOperation>());
74✔
56
    _registerOperation(std::make_unique<IntervalThresholdOperation>());
74✔
57
    _registerOperation(std::make_unique<HilbertPhaseOperation>());
74✔
58
    _registerOperation(std::make_unique<AnalogScalingOperation>());
74✔
59
    _registerOperation(std::make_unique<LineAngleOperation>());
74✔
60
    _registerOperation(std::make_unique<LineMinPointDistOperation>());
74✔
61
    _registerOperation(std::make_unique<LineAlignmentOperation>());
74✔
62
    _registerOperation(std::make_unique<LineBaseFlipTransform>());
74✔
63
    _registerOperation(std::make_unique<LineResampleOperation>());
74✔
64
    _registerOperation(std::make_unique<LineCurvatureOperation>());
74✔
65
    _registerOperation(std::make_unique<LineSubsegmentOperation>());
74✔
66
    _registerOperation(std::make_unique<LinePointExtractionOperation>());
74✔
67
    _registerOperation(std::make_unique<LineClipOperation>());
74✔
68
    _registerOperation(std::make_unique<LineProximityGroupingOperation>());
74✔
69
    _registerOperation(std::make_unique<LineKalmanGroupingOperation>());
74✔
70
    _registerOperation(std::make_unique<LineOutlierDetectionOperation>());
74✔
71
    _registerOperation(std::make_unique<LineIndexGroupingOperation>());
74✔
72
    _registerOperation(std::make_unique<LineGroupToIntervalsOperation>());
74✔
73
    _registerOperation(std::make_unique<PointParticleFilterOperation>());
74✔
74
    _registerOperation(std::make_unique<GroupOperation>());
74✔
75
    _registerOperation(std::make_unique<AnalogFilterOperation>());
74✔
76
    _registerOperation(std::make_unique<WhiskerTracingOperation>());
74✔
77

78
    _computeApplicableOperations();
74✔
79
    std::cout << "Operation Registry Initialized." << std::endl;
74✔
80
}
74✔
81

UNCOV
82
std::vector<std::string> TransformRegistry::getOperationNamesForVariant(DataTypeVariant const & dataVariant) const {
×
83
    // Get the type_index of the type currently stored in the variant.
84
    // Note: std::variant::type() returns the type_index of the *alternative*,
85
    // which in our case IS the std::shared_ptr<T>. This matches what
86
    // getTargetInputTypeIndex() should return.
UNCOV
87
    auto current_type_index = std::visit([](auto & v) -> std::type_index { return typeid(v); }, dataVariant);
×
88

89
    // Look up the type index in the pre-computed map
90
    auto it = type_index_to_op_names_.find(current_type_index);
×
UNCOV
91
    if (it != type_index_to_op_names_.end()) {
×
UNCOV
92
        return it->second;// Return the pre-computed list of names
×
93
    } else {
94
        // No registered operation targets this specific type_index.
95
        // This is normal if a data type has no operations defined for it.
UNCOV
96
        return {};// Return empty vector
×
97
    }
98
}
99

100
TransformOperation * TransformRegistry::findOperationByName(std::string const & operation_name) const {
222✔
101
    auto it = name_to_operation_.find(operation_name);
222✔
102
    if (it != name_to_operation_.end()) {
222✔
103
        return it->second;
222✔
104
    } else {
105
        // std::cerr << "Warning: Requested operation name not found: '" << operation_name << "'" << std::endl;
UNCOV
106
        return nullptr;
×
107
    }
108
}
109

110
void TransformRegistry::_registerOperation(std::unique_ptr<TransformOperation> op) {
2,220✔
111
    if (!op) return;
2,220✔
112
    std::string op_name = op->getName();
2,220✔
113
    if (name_to_operation_.count(op_name)) {
2,220✔
UNCOV
114
        std::cerr << "Warning: Operation with name '" << op_name << "' already registered." << std::endl;
×
UNCOV
115
        return;
×
116
    }
117
    std::cout << "Registering operation: " << op_name
118
              << " (Targets type index: " << op->getTargetInputTypeIndex().name() << ")"// Debug info
6,660✔
119
              << std::endl;
4,440✔
120
    name_to_operation_[op_name] = op.get();
2,220✔
121
    all_operations_.push_back(std::move(op));
2,220✔
122
}
2,220✔
123

124
void TransformRegistry::_computeApplicableOperations() {
74✔
125
    std::cout << "Computing applicable operations based on registered operations..." << std::endl;
74✔
126
    type_index_to_op_names_.clear();// Start fresh
74✔
127

128
    for (auto const & op_ptr: all_operations_) {
2,294✔
129
        if (!op_ptr) continue;
2,220✔
130
        // Get the type index this operation says it targets
131
        std::type_index target_type_index = op_ptr->getTargetInputTypeIndex();
2,220✔
132
        // Get the user-facing name of the operation
133
        std::string op_name = op_ptr->getName();
2,220✔
134

135
        // Add this operation's name to the list for its target type index
136
        type_index_to_op_names_[target_type_index].push_back(op_name);
2,220✔
137
    }
2,220✔
138

139
    std::cout << "Finished computing applicable operations." << std::endl;
74✔
140
// Debug print (optional): shows mangled names for type_index keys internally
141
#ifndef NDEBUG// Example: Only print in debug builds
142
    for (auto const & pair: type_index_to_op_names_) {
518✔
143
        std::cout << "  TypeIndex Hash(" << pair.first.hash_code()
444✔
144
                  << ", Name=" << pair.first.name() << ") supports: ";
444✔
145
        for (auto const & name: pair.second) std::cout << "'" << name << "' ";
2,664✔
146
        std::cout << std::endl;
444✔
147
    }
148
#endif
149
}
74✔
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