USRP Hardware Driver and USRP Manual  Version: 3.15.0.0-4+b1satnogs1
UHD and USRP Manual
ref_vector.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #ifndef INCLUDED_UHD_TYPES_REF_VECTOR_HPP
9 #define INCLUDED_UHD_TYPES_REF_VECTOR_HPP
10 
11 #include <uhd/config.hpp>
12 #include <cstddef>
13 
14 namespace uhd {
15 
21 template <typename T>
23 {
24 public:
30  template <typename Ptr>
31  ref_vector(Ptr* ptr) : _ptr(T(ptr)), _mem(_mem_t(&_ptr)), _size(1)
32  {
33  /* NOP */
34  }
35 
41  template <typename Vector>
42  ref_vector(const Vector& vec)
43  : _ptr(T()), _mem(_mem_t(&vec.front())), _size(vec.size())
44  {
45  /* NOP */
46  }
47 
54  ref_vector(const T* mem, size_t len) : _ptr(T()), _mem(_mem_t(mem)), _size(len)
55  {
56  /* NOP */
57  }
58 
60  const T& operator[](size_t index) const
61  {
62  return _mem[index];
63  }
64 
66  size_t size(void) const
67  {
68  return _size;
69  }
70 
71 private:
72  const T _ptr;
73  typedef T* _mem_t;
74  const _mem_t _mem;
75  const size_t _size;
76 };
77 
78 } // namespace uhd
79 
80 #endif /* INCLUDED_UHD_TYPES_REF_VECTOR_HPP */
Definition: ref_vector.hpp:23
ref_vector(const T *mem, size_t len)
Definition: ref_vector.hpp:54
size_t size(void) const
The number of elements in this container.
Definition: ref_vector.hpp:66
const T & operator[](size_t index) const
Index operator gets the value of rv[index].
Definition: ref_vector.hpp:60
ref_vector(const Vector &vec)
Definition: ref_vector.hpp:42
ref_vector(Ptr *ptr)
Definition: ref_vector.hpp:31
#define UHD_API
Definition: config.h:68
Definition: build_info.hpp:13