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

paulmthompson / WhiskerToolbox / 18477247352

13 Oct 2025 08:18PM UTC coverage: 72.391% (+0.4%) from 71.943%
18477247352

push

github

web-flow
Merge pull request #140 from paulmthompson/kdtree

Jules PR

164 of 287 new or added lines in 3 files covered. (57.14%)

350 existing lines in 9 files now uncovered.

51889 of 71679 relevant lines covered (72.39%)

63071.54 hits per line

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

87.14
/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_Min_Point_Dist/line_min_point_dist.hpp"
15
#include "transforms/Lines/Line_Point_Extraction/line_point_extraction.hpp"
16
#include "transforms/Lines/Line_Proximity_Grouping/line_proximity_grouping.hpp"
17
#include "transforms/Lines/Line_Kalman_Grouping/line_kalman_grouping.hpp"
18
#include "transforms/Lines/Line_Resample/line_resample.hpp"
19
#include "transforms/Lines/Line_Subsegment/line_subsegment.hpp"
20
#include "transforms/Points/Point_Particle_Filter/point_particle_filter.hpp"
21
#include "transforms/Masks/Mask_Area/mask_area.hpp"
22
#include "transforms/Masks/Mask_Centroid/mask_centroid.hpp"
23
#include "transforms/Masks/Mask_Connected_Component/mask_connected_component.hpp"
24
#include "transforms/Masks/Mask_Hole_Filling/mask_hole_filling.hpp"
25
#include "transforms/Masks/Mask_Median_Filter/mask_median_filter.hpp"
26
#include "transforms/Masks/Mask_Principal_Axis/mask_principal_axis.hpp"
27
#include "transforms/Masks/Mask_Skeletonize/mask_skeletonize.hpp"
28
#include "transforms/Masks/Mask_To_Line/mask_to_line.hpp"
29
#include "transforms/Media/whisker_tracing.hpp"
30

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

39

40
TransformRegistry::TransformRegistry() {
74✔
41

42
    std::cout << "Initializing Operation Registry..." << std::endl;
74✔
43

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

72
    _computeApplicableOperations();
74✔
73
    std::cout << "Operation Registry Initialized." << std::endl;
74✔
74
}
74✔
75

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

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

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

104
void TransformRegistry::_registerOperation(std::unique_ptr<TransformOperation> op) {
1,998✔
105
    if (!op) return;
1,998✔
106
    std::string op_name = op->getName();
1,998✔
107
    if (name_to_operation_.count(op_name)) {
1,998✔
UNCOV
108
        std::cerr << "Warning: Operation with name '" << op_name << "' already registered." << std::endl;
×
UNCOV
109
        return;
×
110
    }
111
    std::cout << "Registering operation: " << op_name
112
              << " (Targets type index: " << op->getTargetInputTypeIndex().name() << ")"// Debug info
5,994✔
113
              << std::endl;
3,996✔
114
    name_to_operation_[op_name] = op.get();
1,998✔
115
    all_operations_.push_back(std::move(op));
1,998✔
116
}
1,998✔
117

118
void TransformRegistry::_computeApplicableOperations() {
74✔
119
    std::cout << "Computing applicable operations based on registered operations..." << std::endl;
74✔
120
    type_index_to_op_names_.clear();// Start fresh
74✔
121

122
    for (auto const & op_ptr: all_operations_) {
2,072✔
123
        if (!op_ptr) continue;
1,998✔
124
        // Get the type index this operation says it targets
125
        std::type_index target_type_index = op_ptr->getTargetInputTypeIndex();
1,998✔
126
        // Get the user-facing name of the operation
127
        std::string op_name = op_ptr->getName();
1,998✔
128

129
        // Add this operation's name to the list for its target type index
130
        type_index_to_op_names_[target_type_index].push_back(op_name);
1,998✔
131
    }
1,998✔
132

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