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

paulmthompson / WhiskerToolbox / 14801014238

02 May 2025 06:24PM UTC coverage: 16.234% (-1.3%) from 17.527%
14801014238

push

github

paulmthompson
add outline for hilbert transform. Add datatransform documentation

0 of 35 new or added lines in 2 files covered. (0.0%)

61 existing lines in 2 files now uncovered.

319 of 1965 relevant lines covered (16.23%)

1.63 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

2
#include <iostream>// For init messages
3
#include <map>
4
#include <memory>// unique_ptr
5
#include <string>
6
#include <typeindex>
7
#include <variant>// Needed for the public interface
8
#include <vector>
9

10
#include "TransformRegistry.hpp"
11

12
#include "transforms/Masks/mask_area.hpp"
13
#include "transforms/AnalogTimeSeries/analog_event_threshold.hpp"
14
#include "transforms/AnalogTimeSeries/analog_interval_threshold.hpp"
15
#include "transforms/AnalogTimeSeries/analog_hilbert_phase.hpp"
16

17

UNCOV
18
TransformRegistry::TransformRegistry() {
×
19

UNCOV
20
    std::cout << "Initializing Operation Registry..." << std::endl;
×
21

22
    _registerOperation(std::make_unique<MaskAreaOperation>());
×
23
    _registerOperation(std::make_unique<EventThresholdOperation>());
×
UNCOV
24
    _registerOperation(std::make_unique<IntervalThresholdOperation>());
×
NEW
25
    _registerOperation(std::make_unique<HilbertPhaseOperation>());
×
26

27
    _computeApplicableOperations();
×
28
    std::cout << "Operation Registry Initialized." << std::endl;
×
UNCOV
29
}
×
30

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

38
    // Look up the type index in the pre-computed map
39
    auto it = type_index_to_op_names_.find(current_type_index);
×
40
    if (it != type_index_to_op_names_.end()) {
×
UNCOV
41
        return it->second;// Return the pre-computed list of names
×
42
    } else {
43
        // No registered operation targets this specific type_index.
44
        // This is normal if a data type has no operations defined for it.
UNCOV
45
        return {};// Return empty vector
×
46
    }
47
}
48

49
TransformOperation * TransformRegistry::findOperationByName(std::string const & operation_name) const {
×
50
    auto it = name_to_operation_.find(operation_name);
×
51
    if (it != name_to_operation_.end()) {
×
UNCOV
52
        return it->second;
×
53
    } else {
54
        // std::cerr << "Warning: Requested operation name not found: '" << operation_name << "'" << std::endl;
UNCOV
55
        return nullptr;
×
56
    }
57
}
58

59
void TransformRegistry::_registerOperation(std::unique_ptr<TransformOperation> op) {
×
60
    if (!op) return;
×
61
    std::string op_name = op->getName();
×
62
    if (name_to_operation_.count(op_name)) {
×
63
        std::cerr << "Warning: Operation with name '" << op_name << "' already registered." << std::endl;
×
UNCOV
64
        return;
×
65
    }
66
    std::cout << "Registering operation: " << op_name
67
              << " (Targets type index: " << op->getTargetInputTypeIndex().name() << ")"// Debug info
×
68
              << std::endl;
×
69
    name_to_operation_[op_name] = op.get();
×
70
    all_operations_.push_back(std::move(op));
×
UNCOV
71
}
×
72

73
void TransformRegistry::_computeApplicableOperations() {
×
74
    std::cout << "Computing applicable operations based on registered operations..." << std::endl;
×
UNCOV
75
    type_index_to_op_names_.clear();// Start fresh
×
76

77
    for (auto const & op_ptr: all_operations_) {
×
UNCOV
78
        if (!op_ptr) continue;
×
79
        // Get the type index this operation says it targets
UNCOV
80
        std::type_index target_type_index = op_ptr->getTargetInputTypeIndex();
×
81
        // Get the user-facing name of the operation
UNCOV
82
        std::string op_name = op_ptr->getName();
×
83

84
        // Add this operation's name to the list for its target type index
85
        type_index_to_op_names_[target_type_index].push_back(op_name);
×
UNCOV
86
    }
×
87

UNCOV
88
    std::cout << "Finished computing applicable operations." << std::endl;
×
89
// Debug print (optional): shows mangled names for type_index keys internally
90
#ifndef NDEBUG// Example: Only print in debug builds
91
    for (auto const & pair: type_index_to_op_names_) {
×
92
        std::cout << "  TypeIndex Hash(" << pair.first.hash_code()
×
93
                  << ", Name=" << pair.first.name() << ") supports: ";
×
94
        for (auto const & name: pair.second) std::cout << "'" << name << "' ";
×
UNCOV
95
        std::cout << std::endl;
×
96
    }
97
#endif
UNCOV
98
}
×
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