From 76ed4c2fea5f59bfe02bbbb17754ef7eda44feca Mon Sep 17 00:00:00 2001
From: jcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Tue, 12 Dec 2006 20:00:39 +0000
Subject: Merge jcorgan/hier developer branch into trunk.  Enables creation of
 true hierarchical blocks, from either C++ or Python, as well as creating pure
 C++ gnuradio applications. EXPERIMENTAL.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4070 221aa14e-8319-0410-a670-987f0aec2ac5
---
 gnuradio-examples/c++/hier/Makefile.am | 56 ++++++++++++++++++++++++++++++++++
 gnuradio-examples/c++/hier/dialtone.cc | 48 +++++++++++++++++++++++++++++
 gnuradio-examples/c++/hier/dialtone.h  | 33 ++++++++++++++++++++
 gnuradio-examples/c++/hier/main.cc     | 38 +++++++++++++++++++++++
 gnuradio-examples/c++/hier/output.cc   | 41 +++++++++++++++++++++++++
 gnuradio-examples/c++/hier/output.h    | 33 ++++++++++++++++++++
 gnuradio-examples/c++/hier/siggen.cc   | 42 +++++++++++++++++++++++++
 gnuradio-examples/c++/hier/siggen.h    | 33 ++++++++++++++++++++
 gnuradio-examples/c++/hier/sink.cc     | 45 +++++++++++++++++++++++++++
 gnuradio-examples/c++/hier/sink.h      | 33 ++++++++++++++++++++
 gnuradio-examples/c++/hier/source.cc   | 41 +++++++++++++++++++++++++
 gnuradio-examples/c++/hier/source.h    | 33 ++++++++++++++++++++
 12 files changed, 476 insertions(+)
 create mode 100644 gnuradio-examples/c++/hier/Makefile.am
 create mode 100644 gnuradio-examples/c++/hier/dialtone.cc
 create mode 100644 gnuradio-examples/c++/hier/dialtone.h
 create mode 100644 gnuradio-examples/c++/hier/main.cc
 create mode 100644 gnuradio-examples/c++/hier/output.cc
 create mode 100644 gnuradio-examples/c++/hier/output.h
 create mode 100644 gnuradio-examples/c++/hier/siggen.cc
 create mode 100644 gnuradio-examples/c++/hier/siggen.h
 create mode 100644 gnuradio-examples/c++/hier/sink.cc
 create mode 100644 gnuradio-examples/c++/hier/sink.h
 create mode 100644 gnuradio-examples/c++/hier/source.cc
 create mode 100644 gnuradio-examples/c++/hier/source.h

(limited to 'gnuradio-examples/c++/hier')

diff --git a/gnuradio-examples/c++/hier/Makefile.am b/gnuradio-examples/c++/hier/Makefile.am
new file mode 100644
index 0000000000..f9d341eb7f
--- /dev/null
+++ b/gnuradio-examples/c++/hier/Makefile.am
@@ -0,0 +1,56 @@
+#
+# Copyright 2006 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 2, 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 $(top_srcdir)/Makefile.common
+
+# For compiling within the GNU Radio build tree
+INCLUDES=$(STD_DEFINES_AND_INCLUDES) \
+         -I$(top_srcdir)/gr-audio-alsa/src 
+
+GR_AUDIO_ALSA_LIBS=$(top_builddir)/gr-audio-alsa/src/libgr_audio_alsa.la
+
+# For compiling outside the tree, these are the usual
+# INCLUDES = -I/usr/local/include -I/usr/local/include/gnuradio
+# GNURADIO_CORE_LIBS = -lgnuradio-core
+# GR_AUDIO_ALSA_LIBS = -lgr_audio_alsa
+
+noinst_PROGRAMS = dialtone
+    
+noinst_HEADERS = \
+    dialtone.h	\
+    sink.h \
+    source.h \
+    siggen.h \
+    output.h
+        
+dialtone_SOURCES = \
+    dialtone.cc	   \
+    source.cc \
+    sink.cc \
+    siggen.cc \
+    output.cc \
+    main.cc
+
+dialtone_LDADD = \
+    $(GNURADIO_CORE_LIBS) \
+    $(GR_AUDIO_ALSA_LIBS)
+
+MOSTLYCLEANFILES = *~
diff --git a/gnuradio-examples/c++/hier/dialtone.cc b/gnuradio-examples/c++/hier/dialtone.cc
new file mode 100644
index 0000000000..eb77cf27ba
--- /dev/null
+++ b/gnuradio-examples/c++/hier/dialtone.cc
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006 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 2, 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 <dialtone.h>
+#include <gr_io_signature.h>
+#include <source.h>
+#include <gr_kludge_copy.h>
+#include <sink.h>
+
+// Shared pointer constructor
+dialtone_sptr make_dialtone()
+{
+    return dialtone_sptr(new dialtone());
+}
+
+// Hierarchical block constructor, with no inputs or outputs
+dialtone::dialtone() : 
+gr_hier_block2("dialtone",
+	       gr_make_io_signature(0,0,0),
+	       gr_make_io_signature(0,0,0))
+{
+    define_component("source", make_source());
+    define_component("copy", gr_make_kludge_copy(sizeof(float)));
+    define_component("sink", make_sink());
+
+    connect("source", 0, "copy", 0);
+    connect("source", 1, "copy", 1);
+    connect("copy", 0, "sink",   0);
+    connect("copy", 1, "sink",   1);
+}
diff --git a/gnuradio-examples/c++/hier/dialtone.h b/gnuradio-examples/c++/hier/dialtone.h
new file mode 100644
index 0000000000..2beb46c506
--- /dev/null
+++ b/gnuradio-examples/c++/hier/dialtone.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 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 2, 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_hier_block2.h>
+
+class dialtone;
+typedef boost::shared_ptr<dialtone> dialtone_sptr;
+dialtone_sptr make_dialtone();
+
+class dialtone : public gr_hier_block2
+{
+private:
+    dialtone();
+    friend dialtone_sptr make_dialtone();
+};
diff --git a/gnuradio-examples/c++/hier/main.cc b/gnuradio-examples/c++/hier/main.cc
new file mode 100644
index 0000000000..beefac3a58
--- /dev/null
+++ b/gnuradio-examples/c++/hier/main.cc
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2006 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 2, 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.
+ */
+
+// GNU Radio C++ application
+//
+// Instantiate a top block
+// Instantiate a runtime, passing it the top block
+// Tell the runtime to go...
+
+#include <dialtone.h>
+#include <gr_runtime.h>
+
+int main()
+{
+    dialtone_sptr top_block = make_dialtone();
+    gr_runtime_sptr runtime = gr_make_runtime(top_block);
+
+    runtime->run();   
+    return 0;
+}
diff --git a/gnuradio-examples/c++/hier/output.cc b/gnuradio-examples/c++/hier/output.cc
new file mode 100644
index 0000000000..88ee96e581
--- /dev/null
+++ b/gnuradio-examples/c++/hier/output.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2006 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 2, 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 <output.h>
+#include <gr_io_signature.h>
+#include <audio_alsa_sink.h>
+
+// Shared pointer constructor
+output_sptr make_output()
+{
+    return output_sptr(new output());
+}
+
+output::output() : 
+gr_hier_block2("output",
+	       gr_make_io_signature(2,2,sizeof(float)),
+	       gr_make_io_signature(0,0,0))
+{
+    define_component("audio", audio_alsa_make_sink(48000));
+    
+    connect("self", 0, "audio", 0);
+    connect("self", 1, "audio", 1);
+}
diff --git a/gnuradio-examples/c++/hier/output.h b/gnuradio-examples/c++/hier/output.h
new file mode 100644
index 0000000000..c2f5c99e41
--- /dev/null
+++ b/gnuradio-examples/c++/hier/output.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 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 2, 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_hier_block2.h>
+
+class output;
+typedef boost::shared_ptr<class output> output_sptr;
+output_sptr make_output();
+
+class output : public gr_hier_block2
+{
+private:
+    output();
+    friend output_sptr make_output();
+};
diff --git a/gnuradio-examples/c++/hier/siggen.cc b/gnuradio-examples/c++/hier/siggen.cc
new file mode 100644
index 0000000000..f3b4f67331
--- /dev/null
+++ b/gnuradio-examples/c++/hier/siggen.cc
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006 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 2, 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 <siggen.h>
+#include <gr_io_signature.h>
+#include <gr_sig_source_f.h>
+
+// Shared pointer constructor
+siggen_sptr make_siggen()
+{
+    return siggen_sptr(new siggen());
+}
+
+siggen::siggen() : 
+gr_hier_block2("siggen",
+	       gr_make_io_signature(0,0,0),
+	       gr_make_io_signature(2,2,sizeof(float)))
+{
+    define_component("siggen0", gr_make_sig_source_f(48000, GR_SIN_WAVE, 350, 0.5));
+    define_component("siggen1", gr_make_sig_source_f(48000, GR_SIN_WAVE, 440, 0.5));
+
+    connect("siggen0", 0, "self", 0);
+    connect("siggen1", 0, "self", 1);
+}
diff --git a/gnuradio-examples/c++/hier/siggen.h b/gnuradio-examples/c++/hier/siggen.h
new file mode 100644
index 0000000000..6169882c6a
--- /dev/null
+++ b/gnuradio-examples/c++/hier/siggen.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 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 2, 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_hier_block2.h>
+
+class siggen;
+typedef boost::shared_ptr<class siggen> siggen_sptr;
+siggen_sptr make_siggen();
+
+class siggen : public gr_hier_block2
+{
+private:
+    siggen();
+    friend siggen_sptr make_siggen();
+};
diff --git a/gnuradio-examples/c++/hier/sink.cc b/gnuradio-examples/c++/hier/sink.cc
new file mode 100644
index 0000000000..f073eb982f
--- /dev/null
+++ b/gnuradio-examples/c++/hier/sink.cc
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006 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 2, 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 <sink.h>
+#include <gr_io_signature.h>
+#include <gr_kludge_copy.h>
+#include <output.h>
+
+// Shared pointer constructor
+sink_sptr make_sink()
+{
+    return sink_sptr(new sink());
+}
+
+sink::sink() : 
+gr_hier_block2("sink",
+	       gr_make_io_signature(2,2,sizeof(float)),
+	       gr_make_io_signature(0,0,0))
+{
+    define_component("copy", gr_make_kludge_copy(sizeof(float)));
+    define_component("output", make_output());
+
+    connect("self", 0, "copy",   0);
+    connect("self", 1, "copy",   1);
+    connect("copy",  0, "output", 0);
+    connect("copy",  1, "output", 1);    
+}
diff --git a/gnuradio-examples/c++/hier/sink.h b/gnuradio-examples/c++/hier/sink.h
new file mode 100644
index 0000000000..5428b59a6b
--- /dev/null
+++ b/gnuradio-examples/c++/hier/sink.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 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 2, 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_hier_block2.h>
+
+class sink;
+typedef boost::shared_ptr<sink> sink_sptr;
+sink_sptr make_sink();
+
+class sink : public gr_hier_block2
+{
+private:
+    sink();
+    friend sink_sptr make_sink();
+};
diff --git a/gnuradio-examples/c++/hier/source.cc b/gnuradio-examples/c++/hier/source.cc
new file mode 100644
index 0000000000..816f3aa2f0
--- /dev/null
+++ b/gnuradio-examples/c++/hier/source.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2006 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 2, 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 <source.h>
+#include <gr_io_signature.h>
+#include <siggen.h>
+
+// Shared pointer constructor
+source_sptr make_source()
+{
+    return source_sptr(new source());
+}
+
+source::source() : 
+gr_hier_block2("source",
+	       gr_make_io_signature(0,0,0),
+	       gr_make_io_signature(2,2,sizeof(float)))
+{
+    define_component("siggen", make_siggen());
+
+    connect("siggen", 0, "self", 0);
+    connect("siggen", 1, "self", 1);
+}
diff --git a/gnuradio-examples/c++/hier/source.h b/gnuradio-examples/c++/hier/source.h
new file mode 100644
index 0000000000..8057726c94
--- /dev/null
+++ b/gnuradio-examples/c++/hier/source.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 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 2, 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_hier_block2.h>
+
+class source;
+typedef boost::shared_ptr<source> source_sptr;
+source_sptr make_source();
+
+class source : public gr_hier_block2
+{
+private:
+    source();
+    friend source_sptr make_source();
+};
-- 
cgit v1.2.3