summaryrefslogtreecommitdiff
path: root/pmt/src/lib/unv_template.cc.t
diff options
context:
space:
mode:
authoreb2006-08-03 23:34:56 +0000
committereb2006-08-03 23:34:56 +0000
commit0f53423b1973cf31a44fafe6b2a28e37061527f7 (patch)
tree9870ba8e7f327224fb0e4f88d595e5bcaf3ee65b /pmt/src/lib/unv_template.cc.t
parentbf12a22d5abddc7ff79ca5584da87fa414564ab2 (diff)
downloadgnuradio-0f53423b1973cf31a44fafe6b2a28e37061527f7.tar.gz
gnuradio-0f53423b1973cf31a44fafe6b2a28e37061527f7.tar.bz2
gnuradio-0f53423b1973cf31a44fafe6b2a28e37061527f7.zip
merged interim/pmt changes r2243:2248 into the trunk
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3127 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'pmt/src/lib/unv_template.cc.t')
-rw-r--r--pmt/src/lib/unv_template.cc.t118
1 files changed, 118 insertions, 0 deletions
diff --git a/pmt/src/lib/unv_template.cc.t b/pmt/src/lib/unv_template.cc.t
new file mode 100644
index 000000000..904829da7
--- /dev/null
+++ b/pmt/src/lib/unv_template.cc.t
@@ -0,0 +1,118 @@
+////////////////////////////////////////////////////////////////////////////
+// pmt_@TAG@vector
+////////////////////////////////////////////////////////////////////////////
+
+static pmt_@TAG@vector *
+_@TAG@vector(pmt_t x)
+{
+ return dynamic_cast<pmt_@TAG@vector*>(x.get());
+}
+
+
+pmt_@TAG@vector::pmt_@TAG@vector(size_t k, @TYPE@ fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_@TAG@vector::pmt_@TAG@vector(size_t k, const @TYPE@ *data)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = data[i];
+}
+
+@TYPE@
+pmt_@TAG@vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw pmt_out_of_range("pmt_@TAG@vector_ref", pmt_from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_@TAG@vector::set(size_t k, @TYPE@ x)
+{
+ if (k >= length())
+ throw pmt_out_of_range("pmt_@TAG@vector_set", pmt_from_long(k));
+ d_v[k] = x;
+}
+
+const @TYPE@ *
+pmt_@TAG@vector::elements(size_t &len)
+{
+ len = length();
+ return &d_v[0];
+}
+
+@TYPE@ *
+pmt_@TAG@vector::writeable_elements(size_t &len)
+{
+ len = length();
+ return &d_v[0];
+}
+
+const void*
+pmt_@TAG@vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(@TYPE@);
+ return &d_v[0];
+}
+
+void*
+pmt_@TAG@vector::uniform_writeable_elements(size_t &len)
+{
+ len = length() * sizeof(@TYPE@);
+ return &d_v[0];
+}
+
+bool
+pmt_is_@TAG@vector(pmt_t obj)
+{
+ return obj->is_@TAG@vector();
+}
+
+pmt_t
+pmt_make_@TAG@vector(size_t k, @TYPE@ fill)
+{
+ return pmt_t(new pmt_@TAG@vector(k, fill));
+}
+
+pmt_t
+pmt_init_@TAG@vector(size_t k, const @TYPE@ *data)
+{
+ return pmt_t(new pmt_@TAG@vector(k, data));
+}
+
+@TYPE@
+pmt_@TAG@vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_@TAG@vector())
+ throw pmt_wrong_type("pmt_@TAG@vector_ref", vector);
+ return _@TAG@vector(vector)->ref(k);
+}
+
+void
+pmt_@TAG@vector_set(pmt_t vector, size_t k, @TYPE@ obj)
+{
+ if (!vector->is_@TAG@vector())
+ throw pmt_wrong_type("pmt_@TAG@vector_set", vector);
+ _@TAG@vector(vector)->set(k, obj);
+}
+
+const @TYPE@ *
+pmt_@TAG@vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_@TAG@vector())
+ throw pmt_wrong_type("pmt_@TAG@vector_elements", vector);
+ return _@TAG@vector(vector)->elements(len);
+}
+
+@TYPE@ *
+pmt_@TAG@vector_writeable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_@TAG@vector())
+ throw pmt_wrong_type("pmt_@TAG@vector_writeable_elements", vector);
+ return _@TAG@vector(vector)->writeable_elements(len);
+}