From 1e016e49e82c430197a90a018fbc7613cc654088 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 3 Mar 2020 16:07:42 -0800 Subject: uhd: Add calibration container class This adds uhd::usrp::cal::container, which serves as a base class for calibration data. It also provides the interp_mode enum class which can be useful for future calibration classes. --- host/include/uhd/cal/CMakeLists.txt | 2 ++ host/include/uhd/cal/container.hpp | 50 ++++++++++++++++++++++++++++++++++ host/include/uhd/cal/interpolation.hpp | 16 +++++++++++ 3 files changed, 68 insertions(+) create mode 100644 host/include/uhd/cal/container.hpp create mode 100644 host/include/uhd/cal/interpolation.hpp (limited to 'host') diff --git a/host/include/uhd/cal/CMakeLists.txt b/host/include/uhd/cal/CMakeLists.txt index 6c8355fec..b3f724d2e 100644 --- a/host/include/uhd/cal/CMakeLists.txt +++ b/host/include/uhd/cal/CMakeLists.txt @@ -6,6 +6,8 @@ UHD_INSTALL(FILES database.hpp + container.hpp + interpolation.hpp DESTINATION ${INCLUDE_DIR}/uhd/cal COMPONENT headers ) diff --git a/host/include/uhd/cal/container.hpp b/host/include/uhd/cal/container.hpp new file mode 100644 index 000000000..c3035c610 --- /dev/null +++ b/host/include/uhd/cal/container.hpp @@ -0,0 +1,50 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_CAL_CONTAINER_HPP +#define INCLUDED_LIBUHD_CAL_CONTAINER_HPP + +#include +#include +#include +#include +#include + +namespace uhd { namespace usrp { namespace cal { + +/*! Generic parent class for calibration data + * + * Derive any class that stores cal data which needs to be stored/retrieved from + * this parent class. + */ +class UHD_API container +{ +public: + virtual ~container() = default; + + //! Return a serialized version of this container + virtual std::vector serialize() = 0; + + //! Populate this class from the serialized data + virtual void deserialize(const std::vector& data) = 0; + + //! Generic factory for cal data from serialized data + // + // \tparam container_type The class type of cal data which should be + // generated from \p data + // \param data The serialized data to be turned into the cal class + template + static std::shared_ptr make(const std::vector& data) + { + auto cal_data = container_type::make(); + cal_data->deserialize(data); + return cal_data; + } +}; + +}}} // namespace uhd::usrp::cal + +#endif /* INCLUDED_LIBUHD_CAL_CONTAINER_HPP */ diff --git a/host/include/uhd/cal/interpolation.hpp b/host/include/uhd/cal/interpolation.hpp new file mode 100644 index 000000000..5cdbcfa54 --- /dev/null +++ b/host/include/uhd/cal/interpolation.hpp @@ -0,0 +1,16 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_CAL_INTERP_HPP +#define INCLUDED_LIBUHD_CAL_INTERP_HPP + +namespace uhd { namespace usrp { namespace cal { + +enum class interp_mode { NEAREST_NEIGHBOR, LINEAR }; + +}}} // namespace uhd::usrp::cal + +#endif /* INCLUDED_LIBUHD_CAL_INTERP_HPP */ -- cgit v1.2.3