All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
ref_vector.hpp
Go to the documentation of this file.
//
// Copyright 2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef INCLUDED_UHD_TYPES_REF_VECTOR_HPP
#define INCLUDED_UHD_TYPES_REF_VECTOR_HPP
#include <uhd/config.hpp>
namespace uhd{
template <typename T> class UHD_API ref_vector{
public:
template <typename Ptr> ref_vector(Ptr *ptr):
_ptr(T(ptr)), _mem(_mem_t(&_ptr)), _size(1)
{
/* NOP */
}
template <typename Vector> ref_vector(const Vector &vec):
_ptr(T()), _mem(_mem_t(&vec.front())), _size(vec.size())
{
/* NOP */
}
ref_vector(const T *mem, size_t len):
_ptr(T()), _mem(_mem_t(mem)), _size(len)
{
/* NOP */
}
const T &operator[](size_t index) const{
return _mem[index];
}
size_t size(void) const{
return _size;
}
private:
const T _ptr;
typedef T* _mem_t;
const _mem_t _mem;
const size_t _size;
};
} //namespace uhd
#endif /* INCLUDED_UHD_TYPES_REF_VECTOR_HPP */