UHD 003.005.002-0-unknown

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
ref_vector.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17
18 #ifndef INCLUDED_UHD_TYPES_REF_VECTOR_HPP
19 #define INCLUDED_UHD_TYPES_REF_VECTOR_HPP
20
21 #include <uhd/config.hpp>
22
23 namespace uhd{
24
30 template <typename T> class UHD_API ref_vector{
31 public:
37 template <typename Ptr> ref_vector(Ptr *ptr):
38 _ptr(T(ptr)), _mem(_mem_t(&_ptr)), _size(1)
39 {
40 /* NOP */
41 }
42
48 template <typename Vector> ref_vector(const Vector &vec):
49 _ptr(T()), _mem(_mem_t(&vec.front())), _size(vec.size())
50 {
51 /* NOP */
52 }
53
60 ref_vector(const T *mem, size_t len):
61 _ptr(T()), _mem(_mem_t(mem)), _size(len)
62 {
63 /* NOP */
64 }
65
67 const T &operator[](size_t index) const{
68 return _mem[index];
69 }
70
72 size_t size(void) const{
73 return _size;
74 }
75
76 private:
77 const T _ptr;
78 typedef T* _mem_t;
79 const _mem_t _mem;
80 const size_t _size;
81 };
82
83 } //namespace uhd
84
85 #endif /* INCLUDED_UHD_TYPES_REF_VECTOR_HPP */
uhd::ref_vector::ref_vector
ref_vector(Ptr *ptr)
Definition: ref_vector.hpp:37
config.hpp
uhd::ref_vector::ref_vector
ref_vector(const T *mem, size_t len)
Definition: ref_vector.hpp:60
UHD_API
#define UHD_API
Definition: config.hpp:76
uhd::ref_vector
Definition: ref_vector.hpp:30
uhd::ref_vector::ref_vector
ref_vector(const Vector &vec)
Definition: ref_vector.hpp:48
uhd::ref_vector::operator[]
const T & operator[](size_t index) const
Index operator gets the value of rv[index].
Definition: ref_vector.hpp:67
uhd::ref_vector::size
size_t size(void) const
The number of elements in this container.
Definition: ref_vector.hpp:72