USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-g13c32cef
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> class UHD_API ref_vector{
22 public:
28  template <typename Ptr> ref_vector(Ptr *ptr):
29  _ptr(T(ptr)), _mem(_mem_t(&_ptr)), _size(1)
30  {
31  /* NOP */
32  }
33 
39  template <typename Vector> ref_vector(const Vector &vec):
40  _ptr(T()), _mem(_mem_t(&vec.front())), _size(vec.size())
41  {
42  /* NOP */
43  }
44 
51  ref_vector(const T *mem, size_t len):
52  _ptr(T()), _mem(_mem_t(mem)), _size(len)
53  {
54  /* NOP */
55  }
56 
58  const T &operator[](size_t index) const{
59  return _mem[index];
60  }
61 
63  size_t size(void) const{
64  return _size;
65  }
66 
67 private:
68  const T _ptr;
69  typedef T* _mem_t;
70  const _mem_t _mem;
71  const size_t _size;
72 };
73 
74 } //namespace uhd
75 
76 #endif /* INCLUDED_UHD_TYPES_REF_VECTOR_HPP */
ref_vector(Ptr *ptr)
Definition: ref_vector.hpp:28
size_t size(void) const
The number of elements in this container.
Definition: ref_vector.hpp:63
ref_vector(const T *mem, size_t len)
Definition: ref_vector.hpp:51
Definition: build_info.hpp:14
Definition: ref_vector.hpp:21
ref_vector(const Vector &vec)
Definition: ref_vector.hpp:39
#define UHD_API
Definition: config.h:63
const T & operator[](size_t index) const
Index operator gets the value of rv[index].
Definition: ref_vector.hpp:58