commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] pmt/src/lib pmt.h


From: Eric Blossom
Subject: [Commit-gnuradio] pmt/src/lib pmt.h
Date: Mon, 26 Jun 2006 23:20:21 +0000

CVSROOT:        /sources/gnuradio
Module name:    pmt
Changes by:     Eric Blossom <eb>       06/06/26 23:20:21

Modified files:
        src/lib        : pmt.h 

Log message:
        work-in-progress

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pmt/src/lib/pmt.h?cvsroot=gnuradio&r1=1.2&r2=1.3

Patches:
Index: pmt.h
===================================================================
RCS file: /sources/gnuradio/pmt/src/lib/pmt.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- pmt.h       26 Jun 2006 19:37:39 -0000      1.2
+++ pmt.h       26 Jun 2006 23:20:21 -0000      1.3
@@ -26,11 +26,13 @@
 #include <boost/shared_ptr.hpp>
 #include <complex>
 #include <string>
+#include <stdint.h>
+#include <iostream>
 
 /*!
  * This file defines a polymorphic type and the operations on it.
  *
- * If draws heavily on the idea of scheme and lisp data types.
+ * It draws heavily on the idea of scheme and lisp data types.
  * The interface parallels that in Guile 1.8, with the notable
  * exception that these objects are transparently reference counted.
  */
@@ -51,7 +53,7 @@
 
 /*
  * ------------------------------------------------------------------------
- * Booleans.  Two constants #t and #f.
+ * Booleans.  Two constants, #t and #f.
  *
  * In predicates, anything that is not #f is considered true.
  * I.e., there is a single false value, #f.
@@ -112,6 +114,9 @@
 //! Return true if \p x is an integer number, else false
 bool pmt_is_integer(pmt_t x);
 
+//! Return the pmt value that represents the integer \p x.
+pmt_t pmt_from_long(long x);
+
 /*!
  * \brief Convert pmt to long if possible.
  *
@@ -121,9 +126,6 @@
  */
 long pmt_to_long(pmt_t x);
 
-//! Return the pmt value that represents integer \p x.
-pmt_t pmt_from_long(long x);
-
 /*
  * ------------------------------------------------------------------------
  *                             Reals
@@ -139,6 +141,9 @@
  */
 bool pmt_is_real(pmt_t obj);
 
+//! Return the pmt value that represents double \p x.
+pmt_t pmt_from_double(double x);
+
 /*!
  * \brief Convert pmt to double if possible.
  *
@@ -148,9 +153,6 @@
  */
 double pmt_to_double(pmt_t x);
 
-//! Return the pmt value that represents double \p x.
-pmt_t pmt_from_double(double x);
-
 /*
  * ------------------------------------------------------------------------
  *                            Complex
@@ -166,15 +168,305 @@
  */
 bool pmt_is_complex(pmt_t obj);
 
+//! Return a complex number constructed of the given real and imaginary parts.
+pmt_t pmt_make_rectangular(double re, double im);
+
 /*!
  * If \p z is complex, return the closest complex<double>.
  * Otherwise, raise the wrong_type exception.
  */
 std::complex<double> pmt_to_complex(pmt_t z);
 
+/*
+ * ------------------------------------------------------------------------
+ *                             Pairs
+ * ------------------------------------------------------------------------
+ */
+
+extern const pmt_t PMT_NIL;    //< the empty list
+
+//! Return true if \p x is the empty list, otherwise return false.
+bool pmt_is_null(pmt_t x);
+
+//! Return true if \p obj is a pair, else false.
+bool pmt_is_pair(pmt_t obj);
+
+//! Return a newly allocated pair whose car is \p x and whose cdr is \p y.
+pmt_t pmt_cons(pmt_t x, pmt_t y);
+
+//! If \p pair is a pair, return the car of the \p pair, otherwise raise 
wrong_type.
+pmt_t pmt_car(pmt_t pair);
+
+//! If \p pair is a pair, return the cdr of the \p pair, otherwise raise 
wrong_type.
+pmt_t pmt_cdr(pmt_t pair);
+
+//! Stores \p value in the car field of \p pair.
+void pmt_set_car(pmt_t pair, pmt_t value);
+
+//! Stores \p value in the cdr field of \p pair.
+void pmt_set_cdr(pmt_t pair, pmt_t value);
+
+/*
+ * ------------------------------------------------------------------------
+ *                            Vectors
+ *
+ * These vectors can hold any kind of objects.  Indexing is zero based.
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if \p x is a vector, othewise false.
+bool pmt_is_vector(pmt_t x);
+
+//! Make a vector of length \p k, with initial values set to \p fill
+pmt_t pmt_make_vector(size_t k, pmt_t fill);
+
+/*!
+ * Return the contents of position \p k of \p vector.
+ * \p k must be a valid index of \p vector.
+ */
+pmt_t pmt_vector_ref(pmt_t vector, size_t k);
+
+//! Store \p obj in position \p k.
+void pmt_vector_set(pmt_t vector, size_t k, pmt_t obj);
+
+//! Store \p fill in every position of \p vector
+void pmt_vector_fill(pmt_t vector, pmt_t fill);
+
+/*!
+ * <pre>
+ * ------------------------------------------------------------------------
+ *                    Uniform Numeric Vectors
+ *
+ * A uniform numeric vector is a vector whose elements are all of single
+ * numeric type.  pmt offers uniform numeric vectors for signed and
+ * unsigned 8-bit, 16-bit, 32-bit, and 64-bit integers, two sizes of
+ * floating point values, and complex floating-point numbers of these
+ * two sizes.  Indexing is zero based.
+ *
+ * The names of the functions include these tags in their names:
+ *
+ *    u8  unsigned 8-bit integers
+ *    s8  signed 8-bit integers
+ *   u16  unsigned 16-bit integers
+ *   s16  signed 16-bit integers
+ *   u32  unsigned 32-bit integers
+ *   s32  signed 32-bit integers
+ *   u64  unsigned 64-bit integers
+ *   s64  signed 64-bit integers
+ *   f32  the C++ type float
+ *   f64  the C++ type double
+ *   c32  the C++ type complex<float>
+ *   c64  the C++ type complex<double>
+ * ------------------------------------------------------------------------
+ * </pre>
+ */
+
+//! true if \p x is any kind of uniform numeric vector
+bool pmt_is_uniform_vector(pmt_t x);  
+
+bool pmt_is_u8vector(pmt_t x);
+bool pmt_is_s8vector(pmt_t x);
+bool pmt_is_u16vector(pmt_t x);
+bool pmt_is_s16vector(pmt_t x);
+bool pmt_is_u32vector(pmt_t x);
+bool pmt_is_s32vector(pmt_t x);
+bool pmt_is_u64vector(pmt_t x);
+bool pmt_is_s64vector(pmt_t x);
+bool pmt_is_f32vector(pmt_t x);
+bool pmt_is_f64vector(pmt_t x);
+bool pmt_is_c32vector(pmt_t x);
+bool pmt_is_c64vector(pmt_t x);
+
+pmt_t pmt_make_u8vector(size_t k, uint8_t fill);
+pmt_t pmt_make_s8vector(size_t k, int8_t fill);
+pmt_t pmt_make_u16vector(size_t k, uint16_t fill);
+pmt_t pmt_make_s16vector(size_t k, int16_t fill);
+pmt_t pmt_make_u32vector(size_t k, uint32_t fill);
+pmt_t pmt_make_s32vector(size_t k, int32_t fill);
+pmt_t pmt_make_u64vector(size_t k, uint64_t fill);
+pmt_t pmt_make_s64vector(size_t k, int64_t fill);
+pmt_t pmt_make_f32vector(size_t k, float fill);
+pmt_t pmt_make_f64vector(size_t k, double fill);
+pmt_t pmt_make_c32vector(size_t k, std::complex<float> fill);
+pmt_t pmt_make_c64vector(size_t k, std::complex<double> fill);
+
+uint8_t  pmt_u8vector_ref(pmt_t v, size_t k);
+int8_t   pmt_s8vector_ref(pmt_t v, size_t k);
+uint16_t pmt_u16vector_ref(pmt_t v, size_t k);
+int16_t  pmt_s16vector_ref(pmt_t v, size_t k);
+uint32_t pmt_u32vector_ref(pmt_t v, size_t k);
+int32_t  pmt_s32vector_ref(pmt_t v, size_t k);
+uint64_t pmt_u64vector_ref(pmt_t v, size_t k);
+int64_t  pmt_s64vector_ref(pmt_t v, size_t k);
+float    pmt_f32vector_ref(pmt_t v, size_t k);
+double   pmt_f64vector_ref(pmt_t v, size_t k);
+std::complex<float>  pmt_c32vector_ref(pmt_t v, size_t k);
+std::complex<double> pmt_c64vector_ref(pmt_t v, size_t k);
+
+void pmt_u8vector_set(pmt_t v, size_t k, uint8_t x);  //< v[k] = x
+void pmt_s8vector_set(pmt_t v, size_t k, int8_t x);
+void pmt_u16vector_set(pmt_t v, size_t k, uint16_t x);
+void pmt_s16vector_set(pmt_t v, size_t k, int16_t x);
+void pmt_u32vector_set(pmt_t v, size_t k, uint32_t x);
+void pmt_s32vector_set(pmt_t v, size_t k, int32_t x);
+void pmt_u64vector_set(pmt_t v, size_t k, uint64_t x);
+void pmt_s64vector_set(pmt_t v, size_t k, int64_t x);
+void pmt_f32vector_set(pmt_t v, size_t k, float x);
+void pmt_f64vector_set(pmt_t v, size_t k, double x);
+void pmt_c32vector_set(pmt_t v, size_t k, std::complex<float> x);
+void pmt_c64vector_set(pmt_t v, size_t k, std::complex<double> x);
+
+// Return const pointers to the elements
+
+const void *pmt_uniform_vector_elements(pmt_t v, size_t &len);  //< works with 
any; len is in bytes
+
+const uint8_t  *pmt_u8vector_elements(pmt_t v, size_t &len);  //< len is in 
elements
+const int8_t   *pmt_s8vector_elements(pmt_t v, size_t &len);  //< len is in 
elements
+const uint16_t *pmt_u16vector_elements(pmt_t v, size_t &len); //< len is in 
elements
+const int16_t  *pmt_s16vector_elements(pmt_t v, size_t &len); //< len is in 
elements
+const uint32_t *pmt_u32vector_elements(pmt_t v, size_t &len); //< len is in 
elements
+const int32_t  *pmt_s32vector_elements(pmt_t v, size_t &len); //< len is in 
elements
+const uint64_t *pmt_u64vector_elements(pmt_t v, size_t &len); //< len is in 
elements
+const int64_t  *pmt_s64vector_elements(pmt_t v, size_t &len); //< len is in 
elements
+const float    *pmt_f32vector_elements(pmt_t v, size_t &len); //< len is in 
elements
+const double   *pmt_f64vector_elements(pmt_t v, size_t &len); //< len is in 
elements
+const std::complex<float>  *pmt_c32vector_elements(pmt_t v, size_t &len); //< 
len is in elements
+const std::complex<double> *pmt_c64vector_elements(pmt_t v, size_t &len); //< 
len is in elements
+
+// Return non-const pointers to the elements
+
+void *pmt_uniform_vector_writeable_elements(pmt_t v, size_t &len);  //< works 
with any; len is in bytes
+
+uint8_t  *pmt_u8vector_writable_elements(pmt_t v, size_t &len);  //< len is in 
elements
+int8_t   *pmt_s8vector_writable_elements(pmt_t v, size_t &len);  //< len is in 
elements
+uint16_t *pmt_u16vector_writable_elements(pmt_t v, size_t &len); //< len is in 
elements
+int16_t  *pmt_s16vector_writable_elements(pmt_t v, size_t &len); //< len is in 
elements
+uint32_t *pmt_u32vector_writable_elements(pmt_t v, size_t &len); //< len is in 
elements
+int32_t  *pmt_s32vector_writable_elements(pmt_t v, size_t &len); //< len is in 
elements
+uint64_t *pmt_u64vector_writable_elements(pmt_t v, size_t &len); //< len is in 
elements
+int64_t  *pmt_s64vector_writable_elements(pmt_t v, size_t &len); //< len is in 
elements
+float    *pmt_f32vector_writable_elements(pmt_t v, size_t &len); //< len is in 
elements
+double   *pmt_f64vector_writable_elements(pmt_t v, size_t &len); //< len is in 
elements
+std::complex<float>  *pmt_c32vector_writable_elements(pmt_t v, size_t &len); 
//< len is in elements
+std::complex<double> *pmt_c64vector_writable_elements(pmt_t v, size_t &len); 
//< len is in elements
+
+/*
+ * ------------------------------------------------------------------------
+ *        Dictionary (a.k.a associative array, hash, map)
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if \p obj is a dictionary
+bool pmt_is_dict(pmt_t obj);
+
+//! make an empty dictionary
+pmt_t pmt_make_dict();
+
+//! dict[key] = value
+void  pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value);
+
+//! Return true if \p key exists in \p dict
+bool  pmt_dict_has_key(pmt_t dict, pmt_t key);
+
+//! If \p key exists in \p dict, return associated value; otherwise return \p 
default_value
+pmt_t pmt_dict_ref(pmt_t dict, pmt_t key, pmt_t default_value);
+
+//! Return list of (key . value) pairs
+pmt_t pmt_dict_items(pmt_t dict);
+
+//! Return list of keys
+pmt_t pmt_dict_keys(pmt_t dict);
+
+//! Return list of values
+pmt_t pmt_dict_values(pmt_t dict);
+
+/*
+ * ------------------------------------------------------------------------
+ *                       General functions
+ * ------------------------------------------------------------------------
+ */
+
+//! Return true if x and y are the same object; otherwise return false.
+bool pmt_eq(pmt_t x, pmt_t y);
+
+/*!
+ * \brief Return true if x and y should normally be regarded as the same 
object, else false.
+ *
+ * <pre>
+ * eqv returns true if:
+ *   x and y are the same object.
+ *   x and y are both #t or both #f.
+ *   x and y are both symbols and their names are the same.
+ *   x and y are both numbers, and are numerically equal.
+ *   x and y are both the empty list (nil).
+ *   x and y are pairs or vectors that denote same location in store.
+ * </pre>
+ */
+bool pmt_eqv(pmt_t x, pmt_t y);
+
+/*!
+ * pmt_equal recursively compares the contents of pairs and vectors,
+ * applying pmt_eqv on other objects such as numbers and symbols.  
+ * pmt_equal may fail to terminate if its arguments are circular data
+ * structures.
+ */
+bool pmt_equal(pmt_t x, pmt_t y);
+
+
+//! Return the number of elements in v
+size_t pmt_length(pmt_t v);
+
+
+/*
+ * ------------------------------------------------------------------------
+ *                          read / write
+ * ------------------------------------------------------------------------
+ */
+extern const pmt_t PMT_EOF;    //< The end of file object
+
+//! return true if obj is the EOF object, otherwise return false.
+bool pmt_is_eof_object(pmt_t obj);
+
+/*!
+ * read converts external representations of pmt objects into the
+ * objects themselves.  Read returns the next object parsable from
+ * the given input port, updating port to point to the first
+ * character past the end of the external representation of the
+ * object.
+ *
+ * If an end of file is encountered in the input before any
+ * characters are found that can begin an object, then an end of file
+ * object is returned.   The port remains open, and further attempts
+ * to read will also return an end of file object.  If an end of file
+ * is encountered after the beginning of an object's external
+ * representation, but the external representation is incomplete and
+ * therefore not parsable, an error is signaled.
+ */
+pmt_t pmt_read(std::istream &port);
+
+/*!
+ * Write a written representation of \p obj to the given \p port.
+ */
+void pmt_write(pmt_t obj, std::ostream &port);
+
+/*!
+ * Writes an end of line to \p port.
+ */
+void pmt_newline(std::ostream &port);
+
+/*
+ * ------------------------------------------------------------------------
+ *                   portable byte stream representation
+ * ------------------------------------------------------------------------
+ */
+/*!
+ * \brief Write portable byte-serial representation of \p obj to \p sink
+ */
+void pmt_serialize(pmt_t obj, std::ostream &sink);
+
 /*!
- * Return a complex number constructed of the given real and imaginary parts.
+ * \brief Create obj from portable byte-serial representation
  */
-pmt_t pmt_c_make_rectangular(double re, double im);
+pmt_t pmt_deserialize(std::istream &source);
 
 #endif /* INCLUDED_PMT_H */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]