commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5166 - gnuradio/branches/developers/jcorgan/hb/gnurad


From: jcorgan
Subject: [Commit-gnuradio] r5166 - gnuradio/branches/developers/jcorgan/hb/gnuradio-core/src/lib/runtime
Date: Fri, 27 Apr 2007 18:33:00 -0600 (MDT)

Author: jcorgan
Date: 2007-04-27 18:32:59 -0600 (Fri, 27 Apr 2007)
New Revision: 5166

Modified:
   
gnuradio/branches/developers/jcorgan/hb/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
Log:
Work in progress, added debug output.

Modified: 
gnuradio/branches/developers/jcorgan/hb/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hb/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
      2007-04-28 00:15:11 UTC (rev 5165)
+++ 
gnuradio/branches/developers/jcorgan/hb/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
      2007-04-28 00:32:59 UTC (rev 5166)
@@ -48,6 +48,10 @@
 gr_hier_block2_detail::connect(gr_basic_block_sptr src, int src_port, 
                                gr_basic_block_sptr dst, int dst_port)
 {
+  if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+    std::cout << "connecting: " << gr_endpoint(src, src_port)
+              << " -> " << gr_endpoint(dst, dst_port) << std::endl;
+
   if (src.get() == dst.get())
     throw std::invalid_argument("src and destination blocks cannot be the 
same");
 
@@ -109,16 +113,28 @@
 gr_endpoint
 gr_hier_block2_detail::resolve_port(int port, bool is_input)
 {
+  if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+    std::cout << "Resolving port " << port << " as an "
+             << (is_input ? "input" : "output")
+             << " of " << d_owner->name() << std::endl;
+
+  gr_endpoint result;
+
   if (is_input) {
     if (port < 0 || port >= (signed)d_inputs.size())
       throw std::runtime_error("input port number out of range");
-    return resolve_endpoint(d_inputs[port], true);
+    result = resolve_endpoint(d_inputs[port], true);
   }
   else {
     if (port < 0 || port >= (signed)d_outputs.size())
       throw std::runtime_error("output port number out of range");
-    return resolve_endpoint(d_outputs[port], false);
+    result = resolve_endpoint(d_outputs[port], false);
   }
+
+  if (!result.block())
+    throw std::runtime_error("unable to resolve port");
+
+  return result;
 }
 
 gr_endpoint
@@ -130,18 +146,29 @@
   
   // Check if endpoint is a hierarchical block
   gr_hier_block2_sptr hier_block2(boost::dynamic_pointer_cast<gr_hier_block2, 
gr_basic_block>(endp.block()));
-  if (hier_block2)
+  if (hier_block2) {
+    if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+      std::cout << "Resolving endpoint " << endp << " as an " 
+               << (is_input ? "input" : "output")
+               << ", recursing" << std::endl;
     return hier_block2->d_detail->resolve_port(endp.port(), is_input);
+  }
 
   // Shouldn't ever get here
-  throw std::runtime_error("unable to resolve endpoint");
+  throw std::runtime_error("block is not a valid gr_block or gr_hier_block2!");
 }
 
 void
 gr_hier_block2_detail::flatten(gr_simple_flowgraph_sptr sfg)
 {
+  if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+    std::cout << "flattening " << d_owner->name() << std::endl;
+
   // Add my edges to the flow graph, resolving references to actual endpoints
   for (gr_edge_viter_t p = d_fg->d_detail->d_edges.begin(); p != 
d_fg->d_detail->d_edges.end(); p++) {
+    if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+      std::cout << "Flattening edge " << (*p) << std::endl;
+
     gr_endpoint src_endp = resolve_endpoint((*p)->src(), false);
     gr_endpoint dst_endp = resolve_endpoint((*p)->dst(), true);
     sfg->connect(src_endp, dst_endp);





reply via email to

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