GNU Radio 3.6.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2006,2009,2010 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 #ifndef INCLUDED_PMT_INT_H 00023 #define INCLUDED_PMT_INT_H 00024 00025 #include <gruel/pmt.h> 00026 #include <boost/utility.hpp> 00027 #include <boost/detail/atomic_count.hpp> 00028 00029 /* 00030 * EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION! 00031 * 00032 * See pmt.h for the public interface 00033 */ 00034 00035 #define PMT_LOCAL_ALLOCATOR 0 // define to 0 or 1 00036 namespace pmt { 00037 00038 class GRUEL_API pmt_base : boost::noncopyable { 00039 mutable boost::detail::atomic_count count_; 00040 00041 public: 00042 static void default_deleter(pmt_base *p){ 00043 delete p; 00044 } 00045 00046 boost::function<void(pmt_base *)> deleter_; 00047 00048 protected: 00049 pmt_base() : count_(0), deleter_(&pmt::pmt_base::default_deleter) {}; 00050 virtual ~pmt_base(); 00051 00052 public: 00053 virtual bool is_bool() const { return false; } 00054 virtual bool is_symbol() const { return false; } 00055 virtual bool is_number() const { return false; } 00056 virtual bool is_integer() const { return false; } 00057 virtual bool is_uint64() const { return false; } 00058 virtual bool is_real() const { return false; } 00059 virtual bool is_complex() const { return false; } 00060 virtual bool is_null() const { return false; } 00061 virtual bool is_pair() const { return false; } 00062 virtual bool is_tuple() const { return false; } 00063 virtual bool is_vector() const { return false; } 00064 virtual bool is_dict() const { return false; } 00065 virtual bool is_any() const { return false; } 00066 00067 virtual bool is_uniform_vector() const { return false; } 00068 virtual bool is_u8vector() const { return false; } 00069 virtual bool is_s8vector() const { return false; } 00070 virtual bool is_u16vector() const { return false; } 00071 virtual bool is_s16vector() const { return false; } 00072 virtual bool is_u32vector() const { return false; } 00073 virtual bool is_s32vector() const { return false; } 00074 virtual bool is_u64vector() const { return false; } 00075 virtual bool is_s64vector() const { return false; } 00076 virtual bool is_f32vector() const { return false; } 00077 virtual bool is_f64vector() const { return false; } 00078 virtual bool is_c32vector() const { return false; } 00079 virtual bool is_c64vector() const { return false; } 00080 00081 friend void intrusive_ptr_add_ref(pmt_base* p); 00082 friend void intrusive_ptr_release(pmt_base* p); 00083 00084 # if (PMT_LOCAL_ALLOCATOR) 00085 void *operator new(size_t); 00086 void operator delete(void *, size_t); 00087 #endif 00088 }; 00089 00090 class pmt_bool : public pmt_base 00091 { 00092 public: 00093 pmt_bool(); 00094 //~pmt_bool(){} 00095 00096 bool is_bool() const { return true; } 00097 }; 00098 00099 00100 class pmt_symbol : public pmt_base 00101 { 00102 std::string d_name; 00103 pmt_t d_next; 00104 00105 public: 00106 pmt_symbol(const std::string &name); 00107 //~pmt_symbol(){} 00108 00109 bool is_symbol() const { return true; } 00110 const std::string name() { return d_name; } 00111 00112 pmt_t next() { return d_next; } // symbol table link 00113 void set_next(pmt_t next) { d_next = next; } 00114 }; 00115 00116 class pmt_integer : public pmt_base 00117 { 00118 public: 00119 long d_value; 00120 00121 pmt_integer(long value); 00122 //~pmt_integer(){} 00123 00124 bool is_number() const { return true; } 00125 bool is_integer() const { return true; } 00126 long value() const { return d_value; } 00127 }; 00128 00129 class pmt_uint64 : public pmt_base 00130 { 00131 public: 00132 uint64_t d_value; 00133 00134 pmt_uint64(uint64_t value); 00135 //~pmt_uint64(){} 00136 00137 bool is_number() const { return true; } 00138 bool is_uint64() const { return true; } 00139 uint64_t value() const { return d_value; } 00140 }; 00141 00142 class pmt_real : public pmt_base 00143 { 00144 public: 00145 double d_value; 00146 00147 pmt_real(double value); 00148 //~pmt_real(){} 00149 00150 bool is_number() const { return true; } 00151 bool is_real() const { return true; } 00152 double value() const { return d_value; } 00153 }; 00154 00155 class pmt_complex : public pmt_base 00156 { 00157 public: 00158 std::complex<double> d_value; 00159 00160 pmt_complex(std::complex<double> value); 00161 //~pmt_complex(){} 00162 00163 bool is_number() const { return true; } 00164 bool is_complex() const { return true; } 00165 std::complex<double> value() const { return d_value; } 00166 }; 00167 00168 class pmt_null : public pmt_base 00169 { 00170 public: 00171 pmt_null(); 00172 //~pmt_null(){} 00173 00174 bool is_null() const { return true; } 00175 }; 00176 00177 class pmt_pair : public pmt_base 00178 { 00179 public: 00180 pmt_t d_car; 00181 pmt_t d_cdr; 00182 00183 pmt_pair(const pmt_t& car, const pmt_t& cdr); 00184 //~pmt_pair(){}; 00185 00186 bool is_pair() const { return true; } 00187 pmt_t car() const { return d_car; } 00188 pmt_t cdr() const { return d_cdr; } 00189 00190 void set_car(pmt_t car) { d_car = car; } 00191 void set_cdr(pmt_t cdr) { d_cdr = cdr; } 00192 }; 00193 00194 class pmt_vector : public pmt_base 00195 { 00196 std::vector<pmt_t> d_v; 00197 00198 public: 00199 pmt_vector(size_t len, pmt_t fill); 00200 //~pmt_vector(); 00201 00202 bool is_vector() const { return true; } 00203 pmt_t ref(size_t k) const; 00204 void set(size_t k, pmt_t obj); 00205 void fill(pmt_t fill); 00206 size_t length() const { return d_v.size(); } 00207 00208 pmt_t _ref(size_t k) const { return d_v[k]; } 00209 }; 00210 00211 class pmt_tuple : public pmt_base 00212 { 00213 std::vector<pmt_t> d_v; 00214 00215 public: 00216 pmt_tuple(size_t len); 00217 //~pmt_tuple(); 00218 00219 bool is_tuple() const { return true; } 00220 pmt_t ref(size_t k) const; 00221 size_t length() const { return d_v.size(); } 00222 00223 pmt_t _ref(size_t k) const { return d_v[k]; } 00224 void _set(size_t k, pmt_t v) { d_v[k] = v; } 00225 }; 00226 00227 class pmt_any : public pmt_base 00228 { 00229 boost::any d_any; 00230 00231 public: 00232 pmt_any(const boost::any &any); 00233 //~pmt_any(); 00234 00235 bool is_any() const { return true; } 00236 const boost::any &ref() const { return d_any; } 00237 void set(const boost::any &any) { d_any = any; } 00238 }; 00239 00240 00241 class pmt_uniform_vector : public pmt_base 00242 { 00243 public: 00244 bool is_uniform_vector() const { return true; } 00245 virtual const void *uniform_elements(size_t &len) = 0; 00246 virtual void *uniform_writable_elements(size_t &len) = 0; 00247 virtual size_t length() const = 0; 00248 }; 00249 00250 #include "pmt_unv_int.h" 00251 00252 } /* namespace pmt */ 00253 00254 #endif /* INCLUDED_PMT_INT_H */