USRP Hardware Driver and USRP Manual Version: 4.1.0.1
UHD and USRP Manual
discoverable_feature_getter_iface.hpp
Go to the documentation of this file.
1//
2// Copyright 2020 Ettus Research, a National Instruments Brand
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7#pragma once
8
9#include <uhd/exception.hpp>
11#include <vector>
12
13namespace uhd { namespace features {
14
18{
19public:
21
23 //
24 // Note that if the given feature type does not exist, this function will
25 // assert. The user should first check that the feature exists via the
26 // has_feature method.
27 // Usage:
28 // auto feature_ref = radio.get_feature<desired_feature_class>();
29 template <typename T>
31 {
32 auto p = get_feature_ptr(T::get_feature_id());
34 auto typed_p = dynamic_cast<T*>(p.get());
35 UHD_ASSERT_THROW(typed_p);
36 return *typed_p;
37 }
38
40 //
41 // This function should be used to gate functionality before calling
42 // get_feature().
43 template <typename T>
45 {
46 return bool(get_feature_ptr(T::get_feature_id()));
47 }
48
50 //
51 // Returns a vector (in no particular order) of the features that this
52 // device supports.
53 virtual std::vector<std::string> enumerate_features() = 0;
54
55private:
57 //
58 // If the feature does not exist on the device, returns a null pointer.
59 virtual discoverable_feature::sptr get_feature_ptr(
61};
62
63}} // namespace uhd::features
Definition: discoverable_feature_getter_iface.hpp:18
virtual std::vector< std::string > enumerate_features()=0
Enumerate all discoverable features present on the device.
T & get_feature()
Retrieves a feature of the specified type.
Definition: discoverable_feature_getter_iface.hpp:30
bool has_feature()
Determines whether a given feature exists.
Definition: discoverable_feature_getter_iface.hpp:44
feature_id_t
An enum of all features supported by the driver. When creating a new.
Definition: discoverable_feature.hpp:31
std::shared_ptr< discoverable_feature > sptr
Definition: discoverable_feature.hpp:27
#define UHD_ASSERT_THROW(code)
Definition: exception.hpp:322
Definition: build_info.hpp:12