aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/types.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-30 14:07:19 -0700
committerJosh Blum <josh@joshknows.com>2010-03-30 14:07:19 -0700
commitf9be69cae7c0fd9bca8b310ff79dd6aad958dc2b (patch)
tree42c05c3501de70c7eddf1aa46c301a6216d270f9 /host/lib/types.cpp
parent5a08586157ed23ebc1344583d21fa56fb27cbe52 (diff)
downloaduhd-f9be69cae7c0fd9bca8b310ff79dd6aad958dc2b.tar.gz
uhd-f9be69cae7c0fd9bca8b310ff79dd6aad958dc2b.tar.bz2
uhd-f9be69cae7c0fd9bca8b310ff79dd6aad958dc2b.zip
Added io type and otw type for describing types.
Diffstat (limited to 'host/lib/types.cpp')
-rw-r--r--host/lib/types.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/host/lib/types.cpp b/host/lib/types.cpp
index 3fde40596..bf9f8b895 100644
--- a/host/lib/types.cpp
+++ b/host/lib/types.cpp
@@ -23,10 +23,14 @@
#include <uhd/types/time_spec.hpp>
#include <uhd/types/device_addr.hpp>
#include <uhd/types/mac_addr.hpp>
+#include <uhd/types/otw_type.hpp>
+#include <uhd/types/io_type.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
+#include <boost/cstdint.hpp>
#include <stdexcept>
+#include <complex>
using namespace uhd;
@@ -210,3 +214,34 @@ std::string mac_addr_t::to_string(void) const{
% int(to_bytes()[3]) % int(to_bytes()[4]) % int(to_bytes()[5])
);
}
+
+/***********************************************************************
+ * otw type
+ **********************************************************************/
+otw_type_t::otw_type_t(void){
+ width = 0;
+ shift = 0;
+ byteorder = BO_NATIVE;
+}
+
+/***********************************************************************
+ * io type
+ **********************************************************************/
+static size_t tid_to_size(io_type_t::tid_t tid){
+ switch(tid){
+ case io_type_t::COMPLEX_FLOAT32: return sizeof(std::complex<float>);
+ case io_type_t::COMPLEX_INT16: return sizeof(std::complex<boost::int16_t>);
+ case io_type_t::COMPLEX_INT8: return sizeof(std::complex<boost::int8_t>);
+ default: throw std::runtime_error("unknown io type tid");
+ }
+}
+
+io_type_t::io_type_t(tid_t tid)
+: size(tid_to_size(tid)), tid(tid){
+ /* NOP */
+}
+
+io_type_t::io_type_t(size_t size)
+: size(size), tid(CUSTOM_TYPE){
+ /* NOP */
+}