USRP Hardware Driver and Device Manual  Version: 4.11.0.0-0-g0d7ed3b1
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 
13 namespace uhd { namespace features {
14 
18 {
19 public:
21 
30  template <typename T>
32  {
33  auto p = get_feature_ptr(T::get_feature_id());
35  auto typed_p = dynamic_cast<T*>(p.get());
36  UHD_ASSERT_THROW(typed_p);
37  return *typed_p;
38  }
39 
45  template <typename T>
46  bool has_feature()
47  {
48  return bool(get_feature_ptr(T::get_feature_id()));
49  }
50 
56  virtual std::vector<std::string> enumerate_features() = 0;
57 
58 private:
63  virtual discoverable_feature::sptr get_feature_ptr(
64  discoverable_feature::feature_id_t feature_id) = 0;
65 };
66 
67 }} // 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.
bool has_feature()
Determines whether a given feature exists.
Definition: discoverable_feature_getter_iface.hpp:46
T & get_feature()
Retrieves a feature of the specified type.
Definition: discoverable_feature_getter_iface.hpp:31
feature_id_t
Definition: discoverable_feature.hpp:33
std::shared_ptr< discoverable_feature > sptr
Definition: discoverable_feature.hpp:28
#define UHD_API
Definition: config.h:87
#define UHD_ASSERT_THROW(code)
Definition: exception.hpp:321
Definition: build_info.hpp:12