00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2006 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 <pmt.h> 00026 #include <boost/utility.hpp> 00027 00028 /* 00029 * EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION! 00030 * 00031 * See pmt.h for the public interface 00032 */ 00033 00034 #define PMT_LOCAL_ALLOCATOR 0 // define to 0 or 1 00035 00036 class pmt_base : boost::noncopyable { 00037 protected: 00038 pmt_base(){}; 00039 virtual ~pmt_base(); 00040 00041 public: 00042 virtual bool is_bool() const { return false; } 00043 virtual bool is_symbol() const { return false; } 00044 virtual bool is_number() const { return false; } 00045 virtual bool is_integer() const { return false; } 00046 virtual bool is_real() const { return false; } 00047 virtual bool is_complex() const { return false; } 00048 virtual bool is_null() const { return false; } 00049 virtual bool is_pair() const { return false; } 00050 virtual bool is_vector() const { return false; } 00051 virtual bool is_dict() const { return false; } 00052 virtual bool is_any() const { return false; } 00053 00054 virtual bool is_uniform_vector() const { return false; } 00055 virtual bool is_u8vector() const { return false; } 00056 virtual bool is_s8vector() const { return false; } 00057 virtual bool is_u16vector() const { return false; } 00058 virtual bool is_s16vector() const { return false; } 00059 virtual bool is_u32vector() const { return false; } 00060 virtual bool is_s32vector() const { return false; } 00061 virtual bool is_u64vector() const { return false; } 00062 virtual bool is_s64vector() const { return false; } 00063 virtual bool is_f32vector() const { return false; } 00064 virtual bool is_f64vector() const { return false; } 00065 virtual bool is_c32vector() const { return false; } 00066 virtual bool is_c64vector() const { return false; } 00067 00068 # if (PMT_LOCAL_ALLOCATOR) 00069 void *operator new(size_t); 00070 void operator delete(void *, size_t); 00071 #endif 00072 }; 00073 00074 class pmt_bool : public pmt_base 00075 { 00076 public: 00077 pmt_bool(); 00078 //~pmt_bool(){} 00079 00080 bool is_bool() const { return true; } 00081 }; 00082 00083 00084 class pmt_symbol : public pmt_base 00085 { 00086 std::string d_name; 00087 pmt_t d_next; 00088 00089 public: 00090 pmt_symbol(const std::string &name); 00091 //~pmt_symbol(){} 00092 00093 bool is_symbol() const { return true; } 00094 const std::string name() { return d_name; } 00095 00096 pmt_t next() { return d_next; } // symbol table link 00097 void set_next(pmt_t next) { d_next = next; } 00098 }; 00099 00100 class pmt_integer : public pmt_base 00101 { 00102 long d_value; 00103 00104 public: 00105 pmt_integer(long value); 00106 //~pmt_integer(){} 00107 00108 bool is_number() const { return true; } 00109 bool is_integer() const { return true; } 00110 long value() const { return d_value; } 00111 }; 00112 00113 class pmt_real : public pmt_base 00114 { 00115 double d_value; 00116 00117 public: 00118 pmt_real(double value); 00119 //~pmt_real(){} 00120 00121 bool is_number() const { return true; } 00122 bool is_real() const { return true; } 00123 double value() const { return d_value; } 00124 }; 00125 00126 class pmt_complex : public pmt_base 00127 { 00128 std::complex<double> d_value; 00129 00130 public: 00131 pmt_complex(std::complex<double> value); 00132 //~pmt_complex(){} 00133 00134 bool is_number() const { return true; } 00135 bool is_complex() const { return true; } 00136 std::complex<double> value() const { return d_value; } 00137 }; 00138 00139 class pmt_null : public pmt_base 00140 { 00141 public: 00142 pmt_null(); 00143 //~pmt_null(){} 00144 00145 bool is_null() const { return true; } 00146 }; 00147 00148 class pmt_pair : public pmt_base 00149 { 00150 pmt_t d_car; 00151 pmt_t d_cdr; 00152 00153 public: 00154 pmt_pair(pmt_t car, pmt_t cdr); 00155 //~pmt_pair(){}; 00156 00157 bool is_pair() const { return true; } 00158 pmt_t car() const { return d_car; } 00159 pmt_t cdr() const { return d_cdr; } 00160 00161 void set_car(pmt_t car) { d_car = car; } 00162 void set_cdr(pmt_t cdr) { d_cdr = cdr; } 00163 }; 00164 00165 class pmt_vector : public pmt_base 00166 { 00167 std::vector<pmt_t> d_v; 00168 00169 public: 00170 pmt_vector(size_t len, pmt_t fill); 00171 //~pmt_vector(); 00172 00173 bool is_vector() const { return true; } 00174 pmt_t ref(size_t k) const; 00175 void set(size_t k, pmt_t obj); 00176 void fill(pmt_t fill); 00177 size_t length() const { return d_v.size(); } 00178 00179 pmt_t _ref(size_t k) const { return d_v[k]; } 00180 }; 00181 00182 class pmt_dict : public pmt_base 00183 { 00184 pmt_t d_alist; // list of (key . value) pairs 00185 00186 public: 00187 pmt_dict(); 00188 //~pmt_dict(); 00189 00190 bool is_dict() const { return true; } 00191 void set(pmt_t key, pmt_t value); 00192 pmt_t ref(pmt_t key, pmt_t default_value) const; 00193 bool has_key(pmt_t key) const; 00194 pmt_t items() const; 00195 pmt_t keys() const; 00196 pmt_t values() const; 00197 }; 00198 00199 class pmt_any : public pmt_base 00200 { 00201 boost::any d_any; 00202 00203 public: 00204 pmt_any(const boost::any &any); 00205 //~pmt_any(); 00206 00207 bool is_any() const { return true; } 00208 const boost::any &ref() const { return d_any; } 00209 void set(const boost::any &any) { d_any = any; } 00210 }; 00211 00212 00213 class pmt_uniform_vector : public pmt_base 00214 { 00215 public: 00216 bool is_uniform_vector() const { return true; } 00217 virtual const void *uniform_elements(size_t &len) = 0; 00218 virtual void *uniform_writable_elements(size_t &len) = 0; 00219 virtual size_t length() const = 0; 00220 }; 00221 00222 #include "pmt_unv_int.h" 00223 00224 #endif /* INCLUDED_PMT_INT_H */