summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gnuradio/block.hpp2
-rw-r--r--include/gnuradio/element.hpp5
-rw-r--r--include/gnuradio/gr_block.h15
-rw-r--r--include/gnuradio/gr_hier_block2.h39
-rw-r--r--include/gnuradio/gr_message.h91
-rw-r--r--include/gnuradio/gr_msg_handler.h43
-rw-r--r--include/gnuradio/gr_msg_queue.h92
-rw-r--r--include/gnuradio/gr_sptr_magic.h41
-rw-r--r--include/gnuradio/gr_sync_block.h57
-rw-r--r--include/gnuradio/gr_sync_decimator.h47
-rw-r--r--include/gnuradio/gr_sync_interpolator.h58
-rw-r--r--include/gnuradio/gr_sys_paths.h33
-rw-r--r--include/gnuradio/gr_top_block.h32
-rw-r--r--include/gnuradio/hier_block.hpp4
-rw-r--r--lib/CMakeLists.txt4
-rw-r--r--lib/gr_message.cc78
-rw-r--r--lib/gr_msg_handler.cc30
-rw-r--r--lib/gr_msg_queue.cc125
-rw-r--r--lib/gr_sys_paths.cc55
19 files changed, 847 insertions, 4 deletions
diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp
index 3bddaed..2ec2a59 100644
--- a/include/gnuradio/block.hpp
+++ b/include/gnuradio/block.hpp
@@ -166,7 +166,7 @@ struct GR_RUNTIME_API Block : Element
//! forcast requirements, can be overloaded
virtual void forecast(
int noutput_items,
- gr_vector_int &ninput_items_required
+ std::vector<size_t> &ninput_items_required
);
};
diff --git a/include/gnuradio/element.hpp b/include/gnuradio/element.hpp
index 15acbd7..dc153fe 100644
--- a/include/gnuradio/element.hpp
+++ b/include/gnuradio/element.hpp
@@ -33,7 +33,10 @@ struct GR_RUNTIME_API Element : boost::shared_ptr<ElementImpl>
* Create an element from a shared pointer to an element.
* Good for that factory function/shared ptr paradigm.
*/
- Element(const boost::shared_ptr<Element> &elem);
+ template <typename T>
+ Element(const boost::shared_ptr<T> &elem):
+ boost::shared_ptr<ElementImpl>(*reinterpret_cast<const Element*>(elem.get()))
+ { }
};
diff --git a/include/gnuradio/gr_block.h b/include/gnuradio/gr_block.h
index d8e9521..ef27199 100644
--- a/include/gnuradio/gr_block.h
+++ b/include/gnuradio/gr_block.h
@@ -20,6 +20,9 @@
#include <gnuradio/runtime_api.h>
#include <gnuradio/block.hpp>
#include <gr_io_signature.h>
+#include <gr_sptr_magic.h>
+#include <gr_types.h>
+#include <gr_tags.h>
#include <string>
struct GR_RUNTIME_API gr_block : gnuradio::Block
@@ -33,6 +36,18 @@ struct GR_RUNTIME_API gr_block : gnuradio::Block
gr_io_signature_sptr output_signature
);
+ template <typename T> void set_msg_handler(T msg_handler){/*LOL*/}
+
+ void set_output_signature(gr_io_signature_sptr);
+
+ void set_input_signature(gr_io_signature_sptr);
+
+ gr_io_signature_sptr input_signature(void);
+
+ gr_io_signature_sptr output_signature(void);
+
+ void set_fixed_rate(bool fixed_rate);
+
//! implements work -> calls general work
int work(
const InputItems &input_items,
diff --git a/include/gnuradio/gr_hier_block2.h b/include/gnuradio/gr_hier_block2.h
new file mode 100644
index 0000000..ec57749
--- /dev/null
+++ b/include/gnuradio/gr_hier_block2.h
@@ -0,0 +1,39 @@
+//
+// Copyright 2012 Josh Blum
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with io_sig program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef INCLUDED_GNURADIO_GR_HIER_BLOCK2_H
+#define INCLUDED_GNURADIO_GR_HIER_BLOCK2_H
+
+#include <gnuradio/runtime_api.h>
+#include <gnuradio/hier_block.hpp>
+#include <gr_io_signature.h>
+
+struct GR_RUNTIME_API gr_hier_block2 : gnuradio::HierBlock
+{
+
+ gr_hier_block2(void);
+
+ gr_hier_block2(
+ const std::string &name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature
+ );
+
+ const Element &self(void);
+
+};
+
+#endif /*INCLUDED_GNURADIO_GR_HIER_BLOCK2_H*/
diff --git a/include/gnuradio/gr_message.h b/include/gnuradio/gr_message.h
new file mode 100644
index 0000000..d386ca0
--- /dev/null
+++ b/include/gnuradio/gr_message.h
@@ -0,0 +1,91 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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_GR_MESSAGE_H
+#define INCLUDED_GR_MESSAGE_H
+
+#include <gr_core_api.h>
+#include <gr_types.h>
+#include <string>
+
+class gr_message;
+typedef boost::shared_ptr<gr_message> gr_message_sptr;
+
+/*!
+ * \brief public constructor for gr_message
+ */
+GR_CORE_API gr_message_sptr
+gr_make_message(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0);
+
+GR_CORE_API gr_message_sptr
+gr_make_message_from_string(const std::string s, long type = 0, double arg1 = 0, double arg2 = 0);
+
+/*!
+ * \brief Message class.
+ *
+ * \ingroup misc
+ * The ideas and method names for adjustable message length were
+ * lifted from the click modular router "Packet" class.
+ */
+class GR_CORE_API gr_message {
+ gr_message_sptr d_next; // link field for msg queue
+ long d_type; // type of the message
+ double d_arg1; // optional arg1
+ double d_arg2; // optional arg2
+
+ unsigned char *d_buf_start; // start of allocated buffer
+ unsigned char *d_msg_start; // where the msg starts
+ unsigned char *d_msg_end; // one beyond end of msg
+ unsigned char *d_buf_end; // one beyond end of allocated buffer
+
+ gr_message (long type, double arg1, double arg2, size_t length);
+
+ friend GR_CORE_API gr_message_sptr
+ gr_make_message (long type, double arg1, double arg2, size_t length);
+
+ friend GR_CORE_API gr_message_sptr
+ gr_make_message_from_string (const std::string s, long type, double arg1, double arg2);
+
+ friend class gr_msg_queue;
+
+ unsigned char *buf_data() const { return d_buf_start; }
+ size_t buf_len() const { return d_buf_end - d_buf_start; }
+
+public:
+ ~gr_message ();
+
+ long type() const { return d_type; }
+ double arg1() const { return d_arg1; }
+ double arg2() const { return d_arg2; }
+
+ void set_type(long type) { d_type = type; }
+ void set_arg1(double arg1) { d_arg1 = arg1; }
+ void set_arg2(double arg2) { d_arg2 = arg2; }
+
+ unsigned char *msg() const { return d_msg_start; }
+ size_t length() const { return d_msg_end - d_msg_start; }
+ std::string to_string() const;
+
+};
+
+GR_CORE_API long gr_message_ncurrently_allocated ();
+
+#endif /* INCLUDED_GR_MESSAGE_H */
diff --git a/include/gnuradio/gr_msg_handler.h b/include/gnuradio/gr_msg_handler.h
new file mode 100644
index 0000000..57e8a95
--- /dev/null
+++ b/include/gnuradio/gr_msg_handler.h
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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_GR_MSG_HANDLER_H
+#define INCLUDED_GR_MSG_HANDLER_H
+
+#include <gr_core_api.h>
+#include <gr_message.h>
+
+class gr_msg_handler;
+typedef boost::shared_ptr<gr_msg_handler> gr_msg_handler_sptr;
+
+/*!
+ * \brief abstract class of message handlers
+ * \ingroup base
+ */
+class GR_CORE_API gr_msg_handler {
+public:
+ virtual ~gr_msg_handler ();
+
+ //! handle \p msg
+ virtual void handle (gr_message_sptr msg) = 0;
+};
+
+#endif /* INCLUDED_GR_MSG_HANDLER_H */
diff --git a/include/gnuradio/gr_msg_queue.h b/include/gnuradio/gr_msg_queue.h
new file mode 100644
index 0000000..86440bb
--- /dev/null
+++ b/include/gnuradio/gr_msg_queue.h
@@ -0,0 +1,92 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,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_GR_MSG_QUEUE_H
+#define INCLUDED_GR_MSG_QUEUE_H
+
+#include <gr_core_api.h>
+#include <gr_msg_handler.h>
+#include <gruel/thread.h>
+
+class gr_msg_queue;
+typedef boost::shared_ptr<gr_msg_queue> gr_msg_queue_sptr;
+
+GR_CORE_API gr_msg_queue_sptr gr_make_msg_queue(unsigned int limit=0);
+
+/*!
+ * \brief thread-safe message queue
+ * \ingroup misc
+ */
+class GR_CORE_API gr_msg_queue : public gr_msg_handler {
+
+ gruel::mutex d_mutex;
+ gruel::condition_variable d_not_empty;
+ gruel::condition_variable d_not_full;
+ gr_message_sptr d_head;
+ gr_message_sptr d_tail;
+ unsigned int d_count; // # of messages in queue.
+ unsigned int d_limit; // max # of messages in queue. 0 -> unbounded
+
+public:
+ gr_msg_queue(unsigned int limit);
+ ~gr_msg_queue();
+
+ //! Generic msg_handler method: insert the message.
+ void handle(gr_message_sptr msg) { insert_tail (msg); }
+
+ /*!
+ * \brief Insert message at tail of queue.
+ * \param msg message
+ *
+ * Block if queue if full.
+ */
+ void insert_tail(gr_message_sptr msg);
+
+ /*!
+ * \brief Delete message from head of queue and return it.
+ * Block if no message is available.
+ */
+ gr_message_sptr delete_head();
+
+ /*!
+ * \brief If there's a message in the q, delete it and return it.
+ * If no message is available, return 0.
+ */
+ gr_message_sptr delete_head_nowait();
+
+ //! Delete all messages from the queue
+ void flush();
+
+ //! is the queue empty?
+ bool empty_p() const { return d_count == 0; }
+
+ //! is the queue full?
+ bool full_p() const { return d_limit != 0 && d_count >= d_limit; }
+
+ //! return number of messages in queue
+ unsigned int count() const { return d_count; }
+
+ //! return limit on number of message in queue. 0 -> unbounded
+ unsigned int limit() const { return d_limit; }
+
+};
+
+#endif /* INCLUDED_GR_MSG_QUEUE_H */
diff --git a/include/gnuradio/gr_sptr_magic.h b/include/gnuradio/gr_sptr_magic.h
new file mode 100644
index 0000000..920cc7b
--- /dev/null
+++ b/include/gnuradio/gr_sptr_magic.h
@@ -0,0 +1,41 @@
+/* -*- c++ -*- */
+/*
+ * Copyright josh blum is awesome 2012
+ *
+ * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GR_SPTR_MAGIC_H
+#define INCLUDED_GR_SPTR_MAGIC_H
+
+#include <boost/shared_ptr.hpp>
+
+namespace gnuradio {
+
+ /*
+ * \brief New! Improved! Standard method to get/create the boost::shared_ptr for a block.
+ */
+ template<class T>
+ boost::shared_ptr<T>
+ get_initial_sptr(T *p)
+ {
+ return boost::shared_ptr<T>(p);
+ }
+};
+
+#endif /* INCLUDED_GR_SPTR_MAGIC_H */
diff --git a/include/gnuradio/gr_sync_block.h b/include/gnuradio/gr_sync_block.h
index e69de29..335840e 100644
--- a/include/gnuradio/gr_sync_block.h
+++ b/include/gnuradio/gr_sync_block.h
@@ -0,0 +1,57 @@
+//
+// Copyright 2012 Josh Blum
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with io_sig program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef INCLUDED_GNURADIO_GR_SYNC_BLOCK_H
+#define INCLUDED_GNURADIO_GR_SYNC_BLOCK_H
+
+#include <gnuradio/runtime_api.h>
+#include <gr_block.h>
+
+struct GR_RUNTIME_API gr_sync_block : gr_block
+{
+
+ gr_sync_block(void);
+
+ gr_sync_block(
+ const std::string &name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature
+ );
+
+ //! implements work -> calls work
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+ void set_alignment(const size_t alignment);
+ bool is_unaligned(void);
+
+ /*!
+ * \brief just like gr_block::general_work, only this arranges to call consume_each for you
+ *
+ * The user must override work to define the signal processing code
+ */
+ virtual int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ) = 0;
+
+};
+
+#endif /*INCLUDED_GNURADIO_GR_SYNC_BLOCK_H*/
diff --git a/include/gnuradio/gr_sync_decimator.h b/include/gnuradio/gr_sync_decimator.h
index e69de29..08983ce 100644
--- a/include/gnuradio/gr_sync_decimator.h
+++ b/include/gnuradio/gr_sync_decimator.h
@@ -0,0 +1,47 @@
+//
+// Copyright 2012 Josh Blum
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with io_sig program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef INCLUDED_GNURADIO_GR_SYNC_DECIMATOR_H
+#define INCLUDED_GNURADIO_GR_SYNC_DECIMATOR_H
+
+#include <gnuradio/runtime_api.h>
+#include <gr_sync_block.h>
+
+struct GR_RUNTIME_API gr_sync_decimator : gr_sync_block
+{
+
+ gr_sync_decimator(void);
+
+ gr_sync_decimator(
+ const std::string &name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature,
+ const size_t decim_rate
+ );
+
+ size_t decimation(void);
+ void set_decimation(const size_t decim);
+
+ //! implements work -> calls work
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+};
+
+#endif /*INCLUDED_GNURADIO_GR_SYNC_DECIMATOR_H*/
diff --git a/include/gnuradio/gr_sync_interpolator.h b/include/gnuradio/gr_sync_interpolator.h
index e69de29..3cac3ed 100644
--- a/include/gnuradio/gr_sync_interpolator.h
+++ b/include/gnuradio/gr_sync_interpolator.h
@@ -0,0 +1,58 @@
+//
+// Copyright 2012 Josh Blum
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with io_sig program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef INCLUDED_GNURADIO_GR_SYNC_INTERPOLATOR_H
+#define INCLUDED_GNURADIO_GR_SYNC_INTERPOLATOR_H
+
+#include <gnuradio/runtime_api.h>
+#include <gr_sync_block.h>
+
+struct GR_RUNTIME_API gr_sync_interpolator : gr_sync_block
+{
+
+ gr_sync_interpolator(void);
+
+ gr_sync_interpolator(
+ const std::string &name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature,
+ const size_t interp_rate
+ );
+
+ size_t interpolation(void);
+ void set_interpolation(const size_t interp);
+
+ //! implements work -> calls work
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+ /*!
+ * \brief just like gr_block::general_work, only this arranges to call consume_each for you
+ *
+ * The user must override work to define the signal processing code
+ */
+ virtual int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ) = 0;
+
+};
+
+#endif /*INCLUDED_GNURADIO_GR_SYNC_INTERPOLATOR_H*/
diff --git a/include/gnuradio/gr_sys_paths.h b/include/gnuradio/gr_sys_paths.h
new file mode 100644
index 0000000..bd51ebd
--- /dev/null
+++ b/include/gnuradio/gr_sys_paths.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 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 _GR_SYS_PATHS_H_
+#define _GR_SYS_PATHS_H_
+
+#include <gr_core_api.h>
+
+//! directory to create temporary files
+GR_CORE_API const char *gr_tmp_path();
+
+//! directory to store application data
+GR_CORE_API const char *gr_appdata_path();
+
+#endif /* _GR_SYS_PATHS_H_ */
diff --git a/include/gnuradio/gr_top_block.h b/include/gnuradio/gr_top_block.h
new file mode 100644
index 0000000..199d7b5
--- /dev/null
+++ b/include/gnuradio/gr_top_block.h
@@ -0,0 +1,32 @@
+//
+// Copyright 2012 Josh Blum
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with io_sig program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef INCLUDED_GNURADIO_GR_TOP_BLOCK_H
+#define INCLUDED_GNURADIO_GR_TOP_BLOCK_H
+
+#include <gnuradio/runtime_api.h>
+#include <gr_hier_block2.h>
+
+struct GR_RUNTIME_API gr_top_block : gr_hier_block2
+{
+
+ gr_top_block(void);
+
+ gr_top_block(const std::string &name);
+
+};
+
+#endif /*INCLUDED_GNURADIO_GR_TOP_BLOCK_H*/
diff --git a/include/gnuradio/hier_block.hpp b/include/gnuradio/hier_block.hpp
index fcb968e..e129f29 100644
--- a/include/gnuradio/hier_block.hpp
+++ b/include/gnuradio/hier_block.hpp
@@ -36,14 +36,14 @@ struct GR_RUNTIME_API HierBlock : Element
const Element &src,
const size_t src_index,
const Element &sink,
- const size_t sink_index,
+ const size_t sink_index
);
void disconnect(
const Element &src,
const size_t src_index,
const Element &sink,
- const size_t sink_index,
+ const size_t sink_index
);
};
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index beb2a2d..d065b53 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -8,6 +8,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
# Append gnuradio-core library sources
########################################################################
list(APPEND gnuradio_core_sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_sys_paths.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_queue.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.cc
${CMAKE_CURRENT_SOURCE_DIR}/element.cpp
)
diff --git a/lib/gr_message.cc b/lib/gr_message.cc
new file mode 100644
index 0000000..a99dcd7
--- /dev/null
+++ b/lib/gr_message.cc
@@ -0,0 +1,78 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <gr_message.h>
+#include <assert.h>
+#include <string.h>
+
+static long s_ncurrently_allocated = 0;
+
+gr_message_sptr
+gr_make_message (long type, double arg1, double arg2, size_t length)
+{
+ return gr_message_sptr (new gr_message (type, arg1, arg2, length));
+}
+
+gr_message_sptr
+gr_make_message_from_string(const std::string s, long type, double arg1, double arg2)
+{
+ gr_message_sptr m = gr_make_message(type, arg1, arg2, s.size());
+ memcpy(m->msg(), s.data(), s.size());
+ return m;
+}
+
+
+gr_message::gr_message (long type, double arg1, double arg2, size_t length)
+ : d_type(type), d_arg1(arg1), d_arg2(arg2)
+{
+ if (length == 0)
+ d_buf_start = d_msg_start = d_msg_end = d_buf_end = 0;
+ else {
+ d_buf_start = new unsigned char [length];
+ d_msg_start = d_buf_start;
+ d_msg_end = d_buf_end = d_buf_start + length;
+ }
+ s_ncurrently_allocated++;
+}
+
+gr_message::~gr_message ()
+{
+ assert (d_next == 0);
+ delete [] d_buf_start;
+ d_msg_start = d_msg_end = d_buf_end = 0;
+ s_ncurrently_allocated--;
+}
+
+std::string
+gr_message::to_string() const
+{
+ return std::string((char *)d_msg_start, length());
+}
+
+long
+gr_message_ncurrently_allocated ()
+{
+ return s_ncurrently_allocated;
+}
diff --git a/lib/gr_msg_handler.cc b/lib/gr_msg_handler.cc
new file mode 100644
index 0000000..0f93497
--- /dev/null
+++ b/lib/gr_msg_handler.cc
@@ -0,0 +1,30 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <gr_msg_handler.h>
+
+gr_msg_handler::~gr_msg_handler ()
+{
+}
diff --git a/lib/gr_msg_queue.cc b/lib/gr_msg_queue.cc
new file mode 100644
index 0000000..0cf0467
--- /dev/null
+++ b/lib/gr_msg_queue.cc
@@ -0,0 +1,125 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <gr_msg_queue.h>
+#include <stdexcept>
+
+gr_msg_queue_sptr
+gr_make_msg_queue(unsigned int limit)
+{
+ return gr_msg_queue_sptr (new gr_msg_queue(limit));
+}
+
+gr_msg_queue::gr_msg_queue(unsigned int limit)
+ : d_not_empty(), d_not_full(),
+ /*d_head(0), d_tail(0),*/ d_count(0), d_limit(limit)
+{
+}
+
+gr_msg_queue::~gr_msg_queue()
+{
+ flush ();
+}
+
+void
+gr_msg_queue::insert_tail(gr_message_sptr msg)
+{
+ if (msg->d_next)
+ throw std::invalid_argument("gr_msg_queue::insert_tail: msg already in queue");
+
+ gruel::scoped_lock guard(d_mutex);
+
+ while (full_p())
+ d_not_full.wait(guard);
+
+ if (d_tail == 0){
+ d_tail = d_head = msg;
+ //msg->d_next = 0;
+ msg->d_next.reset();
+ }
+ else {
+ d_tail->d_next = msg;
+ d_tail = msg;
+ //msg->d_next = 0;
+ msg->d_next.reset();
+ }
+ d_count++;
+ d_not_empty.notify_one();
+}
+
+gr_message_sptr
+gr_msg_queue::delete_head()
+{
+ gruel::scoped_lock guard(d_mutex);
+ gr_message_sptr m;
+
+ while ((m = d_head) == 0)
+ d_not_empty.wait(guard);
+
+ d_head = m->d_next;
+ if (d_head == 0){
+ //d_tail = 0;
+ d_tail.reset();
+ }
+
+ d_count--;
+ // m->d_next = 0;
+ m->d_next.reset();
+ d_not_full.notify_one();
+ return m;
+}
+
+gr_message_sptr
+gr_msg_queue::delete_head_nowait()
+{
+ gruel::scoped_lock guard(d_mutex);
+ gr_message_sptr m;
+
+ if ((m = d_head) == 0){
+ //return 0;
+ return gr_message_sptr();
+ }
+
+ d_head = m->d_next;
+ if (d_head == 0){
+ //d_tail = 0;
+ d_tail.reset();
+ }
+
+ d_count--;
+ //m->d_next = 0;
+ m->d_next.reset();
+ d_not_full.notify_one();
+ return m;
+}
+
+void
+gr_msg_queue::flush()
+{
+ gr_message_sptr m;
+
+ while ((m = delete_head_nowait ()) != 0)
+ ;
+}
diff --git a/lib/gr_sys_paths.cc b/lib/gr_sys_paths.cc
new file mode 100644
index 0000000..b4918af
--- /dev/null
+++ b/lib/gr_sys_paths.cc
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011 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.
+ */
+
+#include <gr_sys_paths.h>
+#include <cstdlib> //getenv
+#include <cstdio> //P_tmpdir (maybe)
+
+const char *gr_tmp_path(){
+ const char *path;
+
+ //first case, try TMP environment variable
+ path = getenv("TMP");
+ if (path) return path;
+
+ //second case, try P_tmpdir when its defined
+ #ifdef P_tmpdir
+ if (P_tmpdir) return P_tmpdir;
+ #endif /*P_tmpdir*/
+
+ //fall-through case, nothing worked
+ return "/tmp";
+}
+
+const char *gr_appdata_path(){
+ const char *path;
+
+ //first case, try HOME environment variable (unix)
+ path = getenv("HOME");
+ if (path) return path;
+
+ //second case, try APPDATA environment variable (windows)
+ path = getenv("APPDATA");
+ if (path) return path;
+
+ //fall-through case, nothing worked
+ return gr_tmp_path();
+}