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

paulmthompson / WhiskerToolbox / 15430655463

04 Jun 2025 12:26AM UTC coverage: 40.974% (+17.1%) from 23.832%
15430655463

push

github

paulmthompson
fix self copy with mask data

5 of 5 new or added lines in 2 files covered. (100.0%)

945 existing lines in 24 files now uncovered.

3003 of 7329 relevant lines covered (40.97%)

731.35 hits per line

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

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

3
#include "transforms/Masks/mask_area.hpp"
4
#include "transforms/Masks/mask_to_line.hpp"
5
#include "transforms/Masks/mask_skeletonize.hpp"
6
#include "transforms/AnalogTimeSeries/analog_event_threshold.hpp"
7
#include "transforms/AnalogTimeSeries/analog_interval_threshold.hpp"
8
#include "transforms/AnalogTimeSeries/analog_hilbert_phase.hpp"
9
#include "transforms/AnalogTimeSeries/analog_scaling.hpp"
10
#include "transforms/Lines/line_angle.hpp"
11
#include "transforms/Lines/line_min_point_dist.hpp"
12
#include "transforms/Lines/line_resample.hpp"
13
#include "transforms/Lines/line_curvature.hpp"
14
#include "transforms/Lines/line_subsegment.hpp"
15
#include "transforms/Lines/line_point_extraction.hpp"
16
#include "transforms/Lines/line_clip.hpp"
17

18
#include <iostream>// For init messages
19
#include <map>
20
#include <memory>// unique_ptr
21
#include <string>
22
#include <typeindex>
23
#include <variant>// Needed for the public interface
24
#include <vector>
25

26

27
TransformRegistry::TransformRegistry() {
×
28

29
    std::cout << "Initializing Operation Registry..." << std::endl;
×
30

31
    _registerOperation(std::make_unique<MaskAreaOperation>());
×
UNCOV
32
    _registerOperation(std::make_unique<MaskToLineOperation>());
×
UNCOV
33
    _registerOperation(std::make_unique<MaskSkeletonizeOperation>());
×
UNCOV
34
    _registerOperation(std::make_unique<EventThresholdOperation>());
×
UNCOV
35
    _registerOperation(std::make_unique<IntervalThresholdOperation>());
×
36
    _registerOperation(std::make_unique<HilbertPhaseOperation>());
×
UNCOV
37
    _registerOperation(std::make_unique<AnalogScalingOperation>());
×
UNCOV
38
    _registerOperation(std::make_unique<LineAngleOperation>());
×
39
    _registerOperation(std::make_unique<LineMinPointDistOperation>());
×
40
    _registerOperation(std::make_unique<LineResampleOperation>());
×
41
    _registerOperation(std::make_unique<LineCurvatureOperation>());
×
UNCOV
42
    _registerOperation(std::make_unique<LineSubsegmentOperation>());
×
UNCOV
43
    _registerOperation(std::make_unique<LinePointExtractionOperation>());
×
UNCOV
44
    _registerOperation(std::make_unique<LineClipOperation>());
×
45

UNCOV
46
    _computeApplicableOperations();
×
UNCOV
47
    std::cout << "Operation Registry Initialized." << std::endl;
×
UNCOV
48
}
×
49

50
std::vector<std::string> TransformRegistry::getOperationNamesForVariant(DataTypeVariant const & dataVariant) const {
×
51
    // Get the type_index of the type currently stored in the variant.
52
    // Note: std::variant::type() returns the type_index of the *alternative*,
53
    // which in our case IS the std::shared_ptr<T>. This matches what
54
    // getTargetInputTypeIndex() should return.
55
    auto current_type_index = std::visit([](auto & v) -> std::type_index { return typeid(v); }, dataVariant);
×
56

57
    // Look up the type index in the pre-computed map
UNCOV
58
    auto it = type_index_to_op_names_.find(current_type_index);
×
59
    if (it != type_index_to_op_names_.end()) {
×
60
        return it->second;// Return the pre-computed list of names
×
61
    } else {
62
        // No registered operation targets this specific type_index.
63
        // This is normal if a data type has no operations defined for it.
64
        return {};// Return empty vector
×
65
    }
66
}
67

68
TransformOperation * TransformRegistry::findOperationByName(std::string const & operation_name) const {
×
69
    auto it = name_to_operation_.find(operation_name);
×
70
    if (it != name_to_operation_.end()) {
×
71
        return it->second;
×
72
    } else {
73
        // std::cerr << "Warning: Requested operation name not found: '" << operation_name << "'" << std::endl;
74
        return nullptr;
×
75
    }
76
}
77

78
void TransformRegistry::_registerOperation(std::unique_ptr<TransformOperation> op) {
×
UNCOV
79
    if (!op) return;
×
80
    std::string op_name = op->getName();
×
UNCOV
81
    if (name_to_operation_.count(op_name)) {
×
82
        std::cerr << "Warning: Operation with name '" << op_name << "' already registered." << std::endl;
×
UNCOV
83
        return;
×
84
    }
85
    std::cout << "Registering operation: " << op_name
86
              << " (Targets type index: " << op->getTargetInputTypeIndex().name() << ")"// Debug info
×
UNCOV
87
              << std::endl;
×
88
    name_to_operation_[op_name] = op.get();
×
UNCOV
89
    all_operations_.push_back(std::move(op));
×
UNCOV
90
}
×
91

92
void TransformRegistry::_computeApplicableOperations() {
×
93
    std::cout << "Computing applicable operations based on registered operations..." << std::endl;
×
94
    type_index_to_op_names_.clear();// Start fresh
×
95

UNCOV
96
    for (auto const & op_ptr: all_operations_) {
×
UNCOV
97
        if (!op_ptr) continue;
×
98
        // Get the type index this operation says it targets
UNCOV
99
        std::type_index target_type_index = op_ptr->getTargetInputTypeIndex();
×
100
        // Get the user-facing name of the operation
UNCOV
101
        std::string op_name = op_ptr->getName();
×
102

103
        // Add this operation's name to the list for its target type index
UNCOV
104
        type_index_to_op_names_[target_type_index].push_back(op_name);
×
UNCOV
105
    }
×
106

UNCOV
107
    std::cout << "Finished computing applicable operations." << std::endl;
×
108
// Debug print (optional): shows mangled names for type_index keys internally
109
#ifndef NDEBUG// Example: Only print in debug builds
UNCOV
110
    for (auto const & pair: type_index_to_op_names_) {
×
UNCOV
111
        std::cout << "  TypeIndex Hash(" << pair.first.hash_code()
×
UNCOV
112
                  << ", Name=" << pair.first.name() << ") supports: ";
×
UNCOV
113
        for (auto const & name: pair.second) std::cout << "'" << name << "' ";
×
UNCOV
114
        std::cout << std::endl;
×
115
    }
116
#endif
UNCOV
117
}
×
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