diff options
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_hier_block2.i | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc | 22 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc | 14 |
3 files changed, 27 insertions, 12 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2.i b/gnuradio-core/src/lib/runtime/gr_hier_block2.i index 5278eefce..a62f50e84 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2.i +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2.i @@ -31,7 +31,8 @@ typedef boost::shared_ptr<gr_hier_block2> gr_hier_block2_sptr; %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 { diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc index e5336d483..123d5c3cd 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc @@ -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() diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc b/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc index 2cf1a8d10..d9d89ce2c 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc +++ b/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc @@ -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 @@ void qa_gr_hier_block2::test_make() 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()); } |