USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-gdca39145
UHD and USRP Manual
ref_vector.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011 Ettus Research LLC
3 //
4 // SPDX-License-Identifier: GPL-3.0
5 //
6 
7 #ifndef INCLUDED_UHD_TYPES_REF_VECTOR_HPP
8 #define INCLUDED_UHD_TYPES_REF_VECTOR_HPP
9 
10 #include <uhd/config.hpp>
11 #include <cstddef>
12 
13 namespace uhd{
14 
20 template <typename T> class UHD_API ref_vector{
21 public:
27  template <typename Ptr> ref_vector(Ptr *ptr):
28  _ptr(T(ptr)), _mem(_mem_t(&_ptr)), _size(1)
29  {
30  /* NOP */
31  }
32 
38  template <typename Vector> ref_vector(const Vector &vec):
39  _ptr(T()), _mem(_mem_t(&vec.front())), _size(vec.size())
40  {
41  /* NOP */
42  }
43 
50  ref_vector(const T *mem, size_t len):
51  _ptr(T()), _mem(_mem_t(mem)), _size(len)
52  {
53  /* NOP */
54  }
55 
57  const T &operator[](size_t index) const{
58  return _mem[index];
59  }
60 
62  size_t size(void) const{
63  return _size;
64  }
65 
66 private:
67  const T _ptr;
68  typedef T* _mem_t;
69  const _mem_t _mem;
70  const size_t _size;
71 };
72 
73 } //namespace uhd
74 
75 #endif /* INCLUDED_UHD_TYPES_REF_VECTOR_HPP */
ref_vector(Ptr *ptr)
Definition: ref_vector.hpp:27
size_t size(void) const
The number of elements in this container.
Definition: ref_vector.hpp:62
ref_vector(const T *mem, size_t len)
Definition: ref_vector.hpp:50
Definition: build_info.hpp:14
Definition: ref_vector.hpp:20
ref_vector(const Vector &vec)
Definition: ref_vector.hpp:38
#define UHD_API
Definition: config.h:62
const T & operator[](size_t index) const
Index operator gets the value of rv[index].
Definition: ref_vector.hpp:57