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

mavlink / MAVSDK / 11944365474

21 Nov 2024 12:43AM UTC coverage: 43.566% (+4.9%) from 38.691%
11944365474

Pull #2386

github

web-flow
Merge 2f8c5b774 into c963c5161
Pull Request #2386: camera: support multiple cameras within one instance

1352 of 2024 new or added lines in 47 files covered. (66.8%)

55 existing lines in 9 files now uncovered.

13857 of 31807 relevant lines covered (43.57%)

291.5 hits per line

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

87.5
/src/mavsdk/core/mavlink_parameter_subscription.cpp
1
#include "mavlink_parameter_subscription.h"
2

3
#include <algorithm>
4

5
namespace mavsdk {
6

UNCOV
7
void MavlinkParameterSubscription::subscribe_param_float_changed(
×
8
    const std::string& name, const ParamFloatChangedCallback& callback, const void* cookie)
9
{
UNCOV
10
    subscribe_param_changed<float>(name, callback, cookie);
×
UNCOV
11
}
×
12

13
void MavlinkParameterSubscription::subscribe_param_int_changed(
42✔
14
    const std::string& name, const ParamIntChangedCallback& callback, const void* cookie)
15
{
16
    subscribe_param_changed<int>(name, callback, cookie);
42✔
17
}
42✔
18

19
void MavlinkParameterSubscription::subscribe_param_custom_changed(
8✔
20
    const std::string& name, const ParamCustomChangedCallback& callback, const void* cookie)
21
{
22
    subscribe_param_changed<std::string>(name, callback, cookie);
8✔
23
}
8✔
24

25
void MavlinkParameterSubscription::find_and_call_subscriptions_value_changed(
37✔
26
    const std::string& param_name, const ParamValue& value)
27
{
28
    std::lock_guard<std::mutex> lock(_param_changed_subscriptions_mutex);
37✔
29
    for (const auto& subscription : _param_changed_subscriptions) {
450✔
30
        if (subscription.param_name != param_name) {
413✔
31
            continue;
376✔
32
        }
33
        LogDebug() << "Param " << param_name << " changed";
37✔
34
        // We have a subscription on this param name, now check if the subscription is for the right
35
        // type and call the callback when matching
36
        if (std::get_if<ParamFloatChangedCallback>(&subscription.callback) && value.get_float()) {
37✔
UNCOV
37
            std::get<ParamFloatChangedCallback>(subscription.callback)(value.get_float().value());
×
38
        } else if (
71✔
39
            std::get_if<ParamIntChangedCallback>(&subscription.callback) && value.get_int()) {
71✔
40
            std::get<ParamIntChangedCallback>(subscription.callback)(value.get_int().value());
32✔
41
        } else if (
7✔
42
            std::get_if<ParamCustomChangedCallback>(&subscription.callback) && value.get_custom()) {
7✔
43
            std::get<ParamCustomChangedCallback>(subscription.callback)(value.get_custom().value());
2✔
44
        } else {
45
            // The callback we have set is not for this type.
46
            LogErr() << "Type and callback mismatch";
3✔
47
        }
48
    }
49
}
37✔
50

51
void MavlinkParameterSubscription::unsubscribe_all_params_changed(const void* cookie)
8✔
52
{
53
    std::lock_guard<std::mutex> lock(_param_changed_subscriptions_mutex);
8✔
54

55
    _param_changed_subscriptions.erase(
32✔
56
        std::remove_if(
16✔
57
            _param_changed_subscriptions.begin(),
58
            _param_changed_subscriptions.end(),
59
            [&](const auto& subscription) { return subscription.cookie == cookie; }),
50✔
60
        _param_changed_subscriptions.end());
16✔
61
}
8✔
62

63
} // namespace mavsdk
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