From 2bf2a8f2d2a4477818bfa91cae64fb663fdf88c3 Mon Sep 17 00:00:00 2001 From: jcorgan Date: Sun, 26 Jul 2009 20:01:02 +0000 Subject: Merged r11491:11494 from jcorgan/pmt into trunk. Moves pmt types functions into pmt:: from gruel:: Trunk passes distcheck. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11495 221aa14e-8319-0410-a670-987f0aec2ac5 --- gruel/src/lib/pmt/pmt_int.h | 227 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 gruel/src/lib/pmt/pmt_int.h (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h new file mode 100644 index 000000000..9aac322a7 --- /dev/null +++ b/gruel/src/lib/pmt/pmt_int.h @@ -0,0 +1,227 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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, or (at your option) + * any later version. + * + * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_PMT_INT_H +#define INCLUDED_PMT_INT_H + +#include +#include + +/* + * EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION! + * + * See pmt.h for the public interface + */ + +#define PMT_LOCAL_ALLOCATOR 0 // define to 0 or 1 +namespace pmt { + +class pmt_base : boost::noncopyable { +protected: + pmt_base(){}; + virtual ~pmt_base(); + +public: + virtual bool is_bool() const { return false; } + virtual bool is_symbol() const { return false; } + virtual bool is_number() const { return false; } + virtual bool is_integer() const { return false; } + virtual bool is_real() const { return false; } + virtual bool is_complex() const { return false; } + virtual bool is_null() const { return false; } + virtual bool is_pair() const { return false; } + virtual bool is_vector() const { return false; } + virtual bool is_dict() const { return false; } + virtual bool is_any() const { return false; } + + virtual bool is_uniform_vector() const { return false; } + virtual bool is_u8vector() const { return false; } + virtual bool is_s8vector() const { return false; } + virtual bool is_u16vector() const { return false; } + virtual bool is_s16vector() const { return false; } + virtual bool is_u32vector() const { return false; } + virtual bool is_s32vector() const { return false; } + virtual bool is_u64vector() const { return false; } + virtual bool is_s64vector() const { return false; } + virtual bool is_f32vector() const { return false; } + virtual bool is_f64vector() const { return false; } + virtual bool is_c32vector() const { return false; } + virtual bool is_c64vector() const { return false; } + +# if (PMT_LOCAL_ALLOCATOR) + void *operator new(size_t); + void operator delete(void *, size_t); +#endif +}; + +class pmt_bool : public pmt_base +{ +public: + pmt_bool(); + //~pmt_bool(){} + + bool is_bool() const { return true; } +}; + + +class pmt_symbol : public pmt_base +{ + std::string d_name; + pmt_t d_next; + +public: + pmt_symbol(const std::string &name); + //~pmt_symbol(){} + + bool is_symbol() const { return true; } + const std::string name() { return d_name; } + + pmt_t next() { return d_next; } // symbol table link + void set_next(pmt_t next) { d_next = next; } +}; + +class pmt_integer : public pmt_base +{ + long d_value; + +public: + pmt_integer(long value); + //~pmt_integer(){} + + bool is_number() const { return true; } + bool is_integer() const { return true; } + long value() const { return d_value; } +}; + +class pmt_real : public pmt_base +{ + double d_value; + +public: + pmt_real(double value); + //~pmt_real(){} + + bool is_number() const { return true; } + bool is_real() const { return true; } + double value() const { return d_value; } +}; + +class pmt_complex : public pmt_base +{ + std::complex d_value; + +public: + pmt_complex(std::complex value); + //~pmt_complex(){} + + bool is_number() const { return true; } + bool is_complex() const { return true; } + std::complex value() const { return d_value; } +}; + +class pmt_null : public pmt_base +{ +public: + pmt_null(); + //~pmt_null(){} + + bool is_null() const { return true; } +}; + +class pmt_pair : public pmt_base +{ + pmt_t d_car; + pmt_t d_cdr; + +public: + pmt_pair(const pmt_t& car, const pmt_t& cdr); + //~pmt_pair(){}; + + bool is_pair() const { return true; } + pmt_t car() const { return d_car; } + pmt_t cdr() const { return d_cdr; } + + void set_car(pmt_t car) { d_car = car; } + void set_cdr(pmt_t cdr) { d_cdr = cdr; } +}; + +class pmt_vector : public pmt_base +{ + std::vector d_v; + +public: + pmt_vector(size_t len, pmt_t fill); + //~pmt_vector(); + + bool is_vector() const { return true; } + pmt_t ref(size_t k) const; + void set(size_t k, pmt_t obj); + void fill(pmt_t fill); + size_t length() const { return d_v.size(); } + + pmt_t _ref(size_t k) const { return d_v[k]; } +}; + +class pmt_dict : public pmt_base +{ + pmt_t d_alist; // list of (key . value) pairs + +public: + pmt_dict(); + //~pmt_dict(); + + bool is_dict() const { return true; } + void set(pmt_t key, pmt_t value); + pmt_t ref(pmt_t key, pmt_t default_value) const; + bool has_key(pmt_t key) const; + pmt_t items() const; + pmt_t keys() const; + pmt_t values() const; +}; + +class pmt_any : public pmt_base +{ + boost::any d_any; + +public: + pmt_any(const boost::any &any); + //~pmt_any(); + + bool is_any() const { return true; } + const boost::any &ref() const { return d_any; } + void set(const boost::any &any) { d_any = any; } +}; + + +class pmt_uniform_vector : public pmt_base +{ +public: + bool is_uniform_vector() const { return true; } + virtual const void *uniform_elements(size_t &len) = 0; + virtual void *uniform_writable_elements(size_t &len) = 0; + virtual size_t length() const = 0; +}; + +#include "pmt_unv_int.h" + +} /* namespace pmt */ + +#endif /* INCLUDED_PMT_INT_H */ -- cgit From ad36dccd88eafec6efb8f2428fb21f54d6894cfc Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Fri, 14 Aug 2009 14:04:11 -0700 Subject: Applied patch c1258.diff from Stephan Bruns (ticket:359) This patch changes pmt_t to use boost intrusive pointers. Patch was modified to apply to new pmt location since the original patch was created, and add missing include file. Signed-off-by: Johnathan Corgan --- gruel/src/lib/pmt/pmt_int.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 9aac322a7..ba865b418 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -24,6 +24,7 @@ #include #include +#include /* * EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION! @@ -35,8 +36,10 @@ namespace pmt { class pmt_base : boost::noncopyable { + mutable boost::detail::atomic_count count_; + protected: - pmt_base(){}; + pmt_base() : count_(0) {}; virtual ~pmt_base(); public: @@ -66,6 +69,9 @@ public: virtual bool is_c32vector() const { return false; } virtual bool is_c64vector() const { return false; } + friend void intrusive_ptr_add_ref(pmt_base* p); + friend void intrusive_ptr_release(pmt_base* p); + # if (PMT_LOCAL_ALLOCATOR) void *operator new(size_t); void operator delete(void *, size_t); -- cgit From 7ca21b2eb16ed1495001cdd62d58a9d51dd3f436 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 14 Aug 2009 18:53:35 -0700 Subject: Added most of the support for a new PMT type: tuple. More QA code coming soon. --- gruel/src/lib/pmt/pmt_int.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 9aac322a7..ed47249b1 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -48,6 +48,7 @@ public: virtual bool is_complex() const { return false; } virtual bool is_null() const { return false; } virtual bool is_pair() const { return false; } + virtual bool is_tuple() const { return false; } virtual bool is_vector() const { return false; } virtual bool is_dict() const { return false; } virtual bool is_any() const { return false; } @@ -180,6 +181,22 @@ public: pmt_t _ref(size_t k) const { return d_v[k]; } }; +class pmt_tuple : public pmt_base +{ + std::vector d_v; + +public: + pmt_tuple(size_t len); + //~pmt_tuple(); + + bool is_tuple() const { return true; } + pmt_t ref(size_t k) const; + size_t length() const { return d_v.size(); } + + pmt_t _ref(size_t k) const { return d_v[k]; } + void _set(size_t k, pmt_t v) { d_v[k] = v; } +}; + class pmt_dict : public pmt_base { pmt_t d_alist; // list of (key . value) pairs -- cgit From cbbe4816f99ac934427823c43d2f6f3f1c5f7995 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Mon, 8 Mar 2010 17:08:09 -0800 Subject: Convert pmt_dict type into an immutable data structure. This change allows us to safely pass dicts in messages. --- gruel/src/lib/pmt/pmt_int.h | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 7581845f8..50683ffb5 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. + * Copyright 2006,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -107,9 +107,9 @@ public: class pmt_integer : public pmt_base { +public: long d_value; -public: pmt_integer(long value); //~pmt_integer(){} @@ -120,9 +120,9 @@ public: class pmt_real : public pmt_base { +public: double d_value; -public: pmt_real(double value); //~pmt_real(){} @@ -133,9 +133,9 @@ public: class pmt_complex : public pmt_base { +public: std::complex d_value; -public: pmt_complex(std::complex value); //~pmt_complex(){} @@ -155,10 +155,10 @@ public: class pmt_pair : public pmt_base { +public: pmt_t d_car; pmt_t d_cdr; -public: pmt_pair(const pmt_t& car, const pmt_t& cdr); //~pmt_pair(){}; @@ -203,23 +203,6 @@ public: void _set(size_t k, pmt_t v) { d_v[k] = v; } }; -class pmt_dict : public pmt_base -{ - pmt_t d_alist; // list of (key . value) pairs - -public: - pmt_dict(); - //~pmt_dict(); - - bool is_dict() const { return true; } - void set(pmt_t key, pmt_t value); - pmt_t ref(pmt_t key, pmt_t default_value) const; - bool has_key(pmt_t key) const; - pmt_t items() const; - pmt_t keys() const; - pmt_t values() const; -}; - class pmt_any : public pmt_base { boost::any d_any; -- cgit From c986a2add25920eabacfd620a1a2132cd7e4981d Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sat, 11 Sep 2010 13:06:10 -0700 Subject: Add support for uint64_t to pmt. --- gruel/src/lib/pmt/pmt_int.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 50683ffb5..ea28e37b4 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -47,6 +47,7 @@ public: virtual bool is_symbol() const { return false; } virtual bool is_number() const { return false; } virtual bool is_integer() const { return false; } + virtual bool is_uint64() const { return false; } virtual bool is_real() const { return false; } virtual bool is_complex() const { return false; } virtual bool is_null() const { return false; } @@ -118,6 +119,19 @@ public: long value() const { return d_value; } }; +class pmt_uint64 : public pmt_base +{ +public: + uint64_t d_value; + + pmt_uint64(uint64_t value); + //~pmt_uint64(){} + + bool is_number() const { return true; } + bool is_uint64() const { return true; } + uint64_t value() const { return d_value; } +}; + class pmt_real : public pmt_base { public: -- cgit From 947ae1cf5c16f5b3c6222b6ee9ad1a3b4075dd25 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 20 Jul 2011 17:55:28 -0700 Subject: gruel: API declaration macros for gruel class and function symbols --- gruel/src/lib/pmt/pmt_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index ea28e37b4..3a5cd382b 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -35,7 +35,7 @@ #define PMT_LOCAL_ALLOCATOR 0 // define to 0 or 1 namespace pmt { -class pmt_base : boost::noncopyable { +class GRUEL_API pmt_base : boost::noncopyable { mutable boost::detail::atomic_count count_; protected: -- cgit From 6cf6dc9c76bbacbecdb808c451ede9031668b34c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 3 Apr 2012 14:50:06 -0700 Subject: pmt: added advanded pmt_set_deleter (c++ only) --- gruel/src/lib/pmt/pmt_int.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 3a5cd382b..745dbc666 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -38,8 +38,15 @@ namespace pmt { class GRUEL_API pmt_base : boost::noncopyable { mutable boost::detail::atomic_count count_; +public: + static void default_deleter(pmt_base *p){ + delete p; + } + + boost::function deleter_; + protected: - pmt_base() : count_(0) {}; + pmt_base() : count_(0), deleter_(&pmt::pmt_base::default_deleter) {}; virtual ~pmt_base(); public: -- cgit From f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 13 Apr 2012 18:36:53 -0400 Subject: Removed whitespace and added dtools/bin/remove-whitespace as a tool to do this in the future. The sed script was provided by Moritz Fischer. --- gruel/src/lib/pmt/pmt_int.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 745dbc666..bd2b5fe5a 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -1,19 +1,19 @@ /* -*- c++ -*- */ /* * Copyright 2006,2009,2010 Free Software Foundation, Inc. - * + * * This file is part of GNU Radio - * + * * GNU Radio 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, or (at your option) * any later version. - * + * * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -101,7 +101,7 @@ class pmt_symbol : public pmt_base { std::string d_name; pmt_t d_next; - + public: pmt_symbol(const std::string &name); //~pmt_symbol(){} -- cgit From 54f27eed4991daa41ccba37789a250abdab020a9 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Mon, 16 Apr 2012 16:21:58 -0700 Subject: Revert "Merge remote branch 'jblum-github/pmt_set_deleter'" This reverts commit f88b8cf5508d3ba446cb94f800c56d34279cf91e, reversing changes made to a87ac60f15c2593ececb02ba16ab842c20e760d2. --- gruel/src/lib/pmt/pmt_int.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'gruel/src/lib/pmt/pmt_int.h') diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 745dbc666..3a5cd382b 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -38,15 +38,8 @@ namespace pmt { class GRUEL_API pmt_base : boost::noncopyable { mutable boost::detail::atomic_count count_; -public: - static void default_deleter(pmt_base *p){ - delete p; - } - - boost::function deleter_; - protected: - pmt_base() : count_(0), deleter_(&pmt::pmt_base::default_deleter) {}; + pmt_base() : count_(0) {}; virtual ~pmt_base(); public: -- cgit