Hi,

the attached patch includes an example C++-only app for
gr-howto-write-a-block. Two things I'd like to point out:

1) I stumbled upon the following lines in Makefile.common: 
STD_DEFINES_AND_INCLUDES = \
        $(DEFINES) \
        -I$(abs_top_srcdir)/include \

Since abs_top_srcdir points to the top of gr-howto, the last shown line
will never point to a useful directory (since
gr-howto-write-a-block/include) does not exist). The patch changes that
to 
        -I$(abs_top_srcdir)/lib \
because I thought that might be what was meant in the first place, and
it makes apps/Makefile.am lighter.

2) I'm still getting the hang of git and, in particular, automake so this
probably could be solved a bit nicer. Basically, it's a merge of the
dial_tone C++ example in the GR master and gr-howto-write-a-block.

Hope this is useful,
MB

-- 
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin Braun
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-3790
Fax: +49 721 608-6071
www.cel.kit.edu

KIT -- University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association

diff --git a/gr-howto-write-a-block/Makefile.common b/gr-howto-write-a-block/Makefile.common
index e628d6b..6af9ade 100644
--- a/gr-howto-write-a-block/Makefile.common
+++ b/gr-howto-write-a-block/Makefile.common
@@ -37,7 +37,7 @@ AM_CPPFLAGS = \
 # these are used by both SWIG and CXX
 STD_DEFINES_AND_INCLUDES = \
 	$(DEFINES) \
-	-I$(abs_top_srcdir)/include \
+	-I$(abs_top_srcdir)/lib \
 	-I$(GNURADIO_CORE_INCLUDEDIR) \
 	-I$(GNURADIO_CORE_INCLUDEDIR)/swig
 
diff --git a/gr-howto-write-a-block/apps/Makefile.am b/gr-howto-write-a-block/apps/Makefile.am
index 85ed222..b1c99f3 100644
--- a/gr-howto-write-a-block/apps/Makefile.am
+++ b/gr-howto-write-a-block/apps/Makefile.am
@@ -1,5 +1,5 @@
 #
-# Copyright 2009 Free Software Foundation, Inc.
+# Copyright 2009,2010 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -21,6 +21,7 @@
 
 include $(top_srcdir)/Makefile.common
 
+# Python apps #####
 if PYTHON
 
 dist_bin_SCRIPTS = \
@@ -30,3 +31,21 @@ EXTRA_DIST = \
 	howto_square.grc
 
 endif
+
+
+# C++ apps ########
+CURRENT_PROJECT_LA=$(abs_top_srcdir)/lib/libgnuradio-$(modname).la
+
+# For compiling outside the tree, these will get fished out by pkgconfig
+noinst_PROGRAMS = howto_square
+
+noinst_HEADERS = \
+    howto_square.h
+
+howto_square_SOURCES = 		\
+    howto_square.cc		\
+    howto_square_main.cc
+
+howto_square_LDADD = 	\
+    $(GNURADIO_CORE_LA) \
+    $(CURRENT_PROJECT_LA)
diff --git a/gr-howto-write-a-block/apps/howto_square.cc b/gr-howto-write-a-block/apps/howto_square.cc
new file mode 100644
index 0000000..776c679
--- /dev/null
+++ b/gr-howto-write-a-block/apps/howto_square.cc
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 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 <howto_square.h>
+#include <gr_io_signature.h>
+#include <gr_vector_source_f.h>
+#include <howto_square_ff.h>
+
+
+// Shared pointer constructor
+howto_square_sptr make_howto_square()
+{
+	return gnuradio::get_initial_sptr(new howto_square());
+}
+
+
+// Hierarchical block constructor, with no inputs or outputs
+howto_square::howto_square() : gr_top_block("howto_square"),
+	d_in_data(128, 2.0)
+{
+	gr_vector_source_f_sptr src = gr_make_vector_source_f(d_in_data, false);
+	howto_square_ff_sptr square = howto_make_square_ff();
+	d_vec_sink = gr_make_vector_sink_f();
+
+    connect(src, 0, square, 0);
+    connect(square, 0, d_vec_sink, 0);
+}
+
+
+float
+howto_square::get_first_value()
+{
+	std::vector<float> data = d_vec_sink->data();
+	return data[0];
+}
+
diff --git a/gr-howto-write-a-block/apps/howto_square.h b/gr-howto-write-a-block/apps/howto_square.h
new file mode 100644
index 0000000..e76ffe4
--- /dev/null
+++ b/gr-howto-write-a-block/apps/howto_square.h
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 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_top_block.h>
+#include <gr_vector_sink_f.h>
+
+class howto_square;
+typedef boost::shared_ptr<howto_square> howto_square_sptr;
+howto_square_sptr make_howto_square();
+
+class howto_square : public gr_top_block
+{
+    howto_square();
+    friend howto_square_sptr make_howto_square();
+
+	gr_vector_sink_f_sptr d_vec_sink;
+
+	std::vector<float> d_in_data;
+
+ public:
+	float get_first_value();
+};
+
diff --git a/gr-howto-write-a-block/apps/howto_square_main.cc b/gr-howto-write-a-block/apps/howto_square_main.cc
new file mode 100644
index 0000000..f951903
--- /dev/null
+++ b/gr-howto-write-a-block/apps/howto_square_main.cc
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 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 <iostream>
+#include <howto_square.h>
+
+int main()
+{
+	howto_square_sptr top_block = make_howto_square();
+	top_block->run();
+	std::cout << "First value: " << top_block->get_first_value() << std::endl;
+	return 0;
+}

Attachment: pgpxezaxPeVMf.pgp
Description: PGP signature

_______________________________________________
Patch-gnuradio mailing list
Patch-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/patch-gnuradio

Reply via email to