• 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

86.76
/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_Clip/line_clip.hpp"
12
#include "transforms/Lines/Line_Curvature/line_curvature.hpp"
13
#include "transforms/Lines/Line_Min_Point_Dist/line_min_point_dist.hpp"
14
#include "transforms/Lines/Line_Point_Extraction/line_point_extraction.hpp"
15
#include "transforms/Lines/Line_Proximity_Grouping/line_proximity_grouping.hpp"
16
#include "transforms/Lines/Line_Kalman_Grouping/line_kalman_grouping.hpp"
17
#include "transforms/Lines/Line_Resample/line_resample.hpp"
18
#include "transforms/Lines/Line_Subsegment/line_subsegment.hpp"
19
#include "transforms/Masks/Mask_Area/mask_area.hpp"
20
#include "transforms/Masks/Mask_Centroid/mask_centroid.hpp"
21
#include "transforms/Masks/Mask_Connected_Component/mask_connected_component.hpp"
22
#include "transforms/Masks/Mask_Hole_Filling/mask_hole_filling.hpp"
23
#include "transforms/Masks/Mask_Median_Filter/mask_median_filter.hpp"
24
#include "transforms/Masks/Mask_Principal_Axis/mask_principal_axis.hpp"
25
#include "transforms/Masks/Mask_Skeletonize/mask_skeletonize.hpp"
26
#include "transforms/Masks/Mask_To_Line/mask_to_line.hpp"
27
#include "transforms/Media/whisker_tracing.hpp"
28

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

37

38
TransformRegistry::TransformRegistry() {
74✔
39

40
    std::cout << "Initializing Operation Registry..." << std::endl;
74✔
41

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

68
    _computeApplicableOperations();
74✔
69
    std::cout << "Operation Registry Initialized." << std::endl;
74✔
70
}
74✔
71

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

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

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

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

114
void TransformRegistry::_computeApplicableOperations() {
74✔
115
    std::cout << "Computing applicable operations based on registered operations..." << std::endl;
74✔
116
    type_index_to_op_names_.clear();// Start fresh
74✔
117

118
    for (auto const & op_ptr: all_operations_) {
1,924✔
119
        if (!op_ptr) continue;
1,850✔
120
        // Get the type index this operation says it targets
121
        std::type_index target_type_index = op_ptr->getTargetInputTypeIndex();
1,850✔
122
        // Get the user-facing name of the operation
123
        std::string op_name = op_ptr->getName();
1,850✔
124

125
        // Add this operation's name to the list for its target type index
126
        type_index_to_op_names_[target_type_index].push_back(op_name);
1,850✔
127
    }
1,850✔
128

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