commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10671 - gnuradio/trunk/gnuradio-core/src/lib/runtime


From: jcorgan
Subject: [Commit-gnuradio] r10671 - gnuradio/trunk/gnuradio-core/src/lib/runtime
Date: Mon, 23 Mar 2009 13:49:50 -0600 (MDT)

Author: jcorgan
Date: 2009-03-23 13:49:49 -0600 (Mon, 23 Mar 2009)
New Revision: 10671

Modified:
   gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2.i
   gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
   gnuradio/trunk/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc
Log:
Error out when creating hierarchical blocks with arbitrary or variable numbers 
of inputs and outputs.  Temporarily fixes ticket:247; this functionality will 
be added during the release 3.2 series but not for the first release.

Modified: gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2.i
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2.i       
2009-03-23 16:39:11 UTC (rev 10670)
+++ gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2.i       
2009-03-23 19:49:49 UTC (rev 10671)
@@ -31,7 +31,8 @@
 %rename(hier_block2_swig) gr_make_hier_block2;
 gr_hier_block2_sptr gr_make_hier_block2(const std::string name,
                                         gr_io_signature_sptr input_signature,
-                                        gr_io_signature_sptr output_signature);
+                                        gr_io_signature_sptr output_signature)
+  throw (std::runtime_error);
 
 class gr_hier_block2 : public gr_basic_block
 {

Modified: gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc       
2009-03-23 16:39:11 UTC (rev 10670)
+++ gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc       
2009-03-23 19:49:49 UTC (rev 10671)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006,2007 Free Software Foundation, Inc.
+ * Copyright 2006,2007,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -33,10 +33,24 @@
 gr_hier_block2_detail::gr_hier_block2_detail(gr_hier_block2 *owner) :
   d_owner(owner), 
   d_parent_detail(0),
-  d_fg(gr_make_flowgraph()),
-  d_inputs(owner->input_signature()->max_streams()),
-  d_outputs(owner->output_signature()->max_streams())
+  d_fg(gr_make_flowgraph())
 {
+  int min_inputs = owner->input_signature()->min_streams();
+  int max_inputs = owner->input_signature()->max_streams();
+  int min_outputs = owner->output_signature()->min_streams();
+  int max_outputs = owner->output_signature()->max_streams();
+
+  if (max_inputs == gr_io_signature::IO_INFINITE ||
+      max_outputs == gr_io_signature::IO_INFINITE ||
+      (min_inputs != max_inputs) ||(min_outputs != max_outputs) ) {
+    std::stringstream msg;
+    msg << "Hierarchical blocks do not yet support arbitrary or"
+       << " variable numbers of inputs or outputs (" << d_owner->name() << ")";
+    throw std::runtime_error(msg.str());
+  }
+
+  d_inputs = gr_endpoint_vector_t(max_inputs);
+  d_outputs = gr_endpoint_vector_t(max_outputs);
 }
 
 gr_hier_block2_detail::~gr_hier_block2_detail()

Modified: gnuradio/trunk/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc   
2009-03-23 16:39:11 UTC (rev 10670)
+++ gnuradio/trunk/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc   
2009-03-23 19:49:49 UTC (rev 10671)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -33,8 +33,8 @@
 void qa_gr_hier_block2::test_make()
 {
     gr_hier_block2_sptr src1(gr_make_hier_block2("test",
-                                                gr_make_io_signature(1, 2, 1 * 
sizeof(int)),
-                                                gr_make_io_signature(3, 4, 2 * 
sizeof(int))));
+                                                gr_make_io_signature(1, 1, 1 * 
sizeof(int)),
+                                                gr_make_io_signature(1, 1, 1 * 
sizeof(int))));
 
     CPPUNIT_ASSERT(src1);
     CPPUNIT_ASSERT_EQUAL(std::string("test"), src1->name());
@@ -43,14 +43,14 @@
                         src1->input_signature()->sizeof_stream_item(0));
 
     CPPUNIT_ASSERT_EQUAL(1, src1->input_signature()->min_streams());
-    CPPUNIT_ASSERT_EQUAL(2, src1->input_signature()->max_streams());
+    CPPUNIT_ASSERT_EQUAL(1, src1->input_signature()->max_streams());
 
 
-    CPPUNIT_ASSERT_EQUAL(2 * (int) sizeof(int), 
+    CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int), 
                         src1->output_signature()->sizeof_stream_item(0));
 
-    CPPUNIT_ASSERT_EQUAL(3, src1->output_signature()->min_streams());
-    CPPUNIT_ASSERT_EQUAL(4, src1->output_signature()->max_streams());
+    CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->min_streams());
+    CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->max_streams());
 
 }
 





reply via email to

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