commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r6192 - gnuradio/branches/developers/eb/fg/gnuradio-co


From: eb
Subject: [Commit-gnuradio] r6192 - gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime
Date: Mon, 27 Aug 2007 23:14:38 -0600 (MDT)

Author: eb
Date: 2007-08-27 23:14:38 -0600 (Mon, 27 Aug 2007)
New Revision: 6192

Modified:
   
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
   
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2.h
   
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
   
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h
   
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
Log:
Refactor flatten into const-correct functional form.  Beauty reigns ;)


Modified: 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
===================================================================
--- 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
  2007-08-28 04:55:38 UTC (rev 6191)
+++ 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
  2007-08-28 05:14:38 UTC (rev 6192)
@@ -77,8 +77,10 @@
   d_detail->unlock();
 }
 
-void
-gr_hier_block2::flatten(gr_flat_flowgraph_sptr ffg)
+gr_flat_flowgraph_sptr
+gr_hier_block2::flatten() const
 {
-  d_detail->flatten(ffg);
+  gr_flat_flowgraph_sptr new_ffg = gr_make_flat_flowgraph();
+  d_detail->flatten_aux(new_ffg);
+  return new_ffg;
 }

Modified: 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2.h
===================================================================
--- 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2.h
   2007-08-28 04:55:38 UTC (rev 6191)
+++ 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2.h
   2007-08-28 05:14:38 UTC (rev 6192)
@@ -65,7 +65,7 @@
   virtual void lock();
   virtual void unlock();
 
-  void flatten(gr_flat_flowgraph_sptr ffg);
+  gr_flat_flowgraph_sptr flatten() const;
 };
 
 #endif /* INCLUDED_GR_HIER_BLOCK2_H */

Modified: 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
===================================================================
--- 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
   2007-08-28 04:55:38 UTC (rev 6191)
+++ 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
   2007-08-28 05:14:38 UTC (rev 6192)
@@ -204,7 +204,7 @@
 }
 
 gr_endpoint
-gr_hier_block2_detail::resolve_endpoint(const gr_endpoint &endp, bool is_input)
+gr_hier_block2_detail::resolve_endpoint(const gr_endpoint &endp, bool 
is_input) const
 {
   // Check if endpoint is a leaf node
   if (boost::dynamic_pointer_cast<gr_block, gr_basic_block>(endp.block()))
@@ -225,7 +225,7 @@
 }
 
 void
-gr_hier_block2_detail::flatten(gr_flat_flowgraph_sptr sfg)
+gr_hier_block2_detail::flatten_aux(gr_flat_flowgraph_sptr sfg) const
 {
   if (GR_HIER_BLOCK2_DETAIL_DEBUG)
     std::cout << "flattening " << d_owner->name() << std::endl;
@@ -248,7 +248,7 @@
   for (gr_basic_block_viter_t p = blocks.begin(); p != blocks.end(); p++) {
     gr_hier_block2_sptr 
hier_block2(boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(*p));
     if (hier_block2)
-      hier_block2->d_detail->flatten(sfg);
+      hier_block2->d_detail->flatten_aux(sfg);
   }
 }
 

Modified: 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h
===================================================================
--- 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h
    2007-08-28 04:55:38 UTC (rev 6191)
+++ 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h
    2007-08-28 05:14:38 UTC (rev 6192)
@@ -50,9 +50,9 @@
     void connect_output(int my_port, int port, gr_basic_block_sptr block);
     void disconnect_input(int my_port, int port, gr_basic_block_sptr block);
     void disconnect_output(int my_port, int port, gr_basic_block_sptr block);
-    void flatten(gr_flat_flowgraph_sptr sfg);
+    void flatten_aux(gr_flat_flowgraph_sptr sfg) const;
     gr_endpoint resolve_port(int port, bool is_input);
-    gr_endpoint resolve_endpoint(const gr_endpoint &endp, bool is_input);
+    gr_endpoint resolve_endpoint(const gr_endpoint &endp, bool is_input) const;
     void lock();
     void unlock();
 

Modified: 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
===================================================================
--- 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
       2007-08-28 04:55:38 UTC (rev 6191)
+++ 
gnuradio/branches/developers/eb/fg/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
       2007-08-28 05:14:38 UTC (rev 6192)
@@ -63,7 +63,7 @@
 
 gr_top_block_impl::gr_top_block_impl(gr_top_block *owner) 
   : d_running(false),
-    d_ffg(gr_make_flat_flowgraph()),
+    d_ffg(),
     d_owner(owner),
     d_lock_count(0)
 {
@@ -86,8 +86,7 @@
     throw std::runtime_error("already running");
 
   // Create new flat flow graph by flattening hierarchy
-  d_ffg->clear();
-  d_owner->flatten(d_ffg);
+  d_ffg = d_owner->flatten();
 
   // Validate new simple flow graph and wire it up
   d_ffg->validate();
@@ -196,11 +195,10 @@
   if (GR_TOP_BLOCK_IMPL_DEBUG)
     std::cout << "restart: threads stopped" << std::endl;
 
-  // Create new simple flow graph 
-  gr_flat_flowgraph_sptr new_ffg = gr_make_flat_flowgraph();
-  d_owner->flatten(new_ffg);
-  new_ffg->validate();
-  new_ffg->merge_connections(d_ffg);
+  // Create new simple flow graph
+  gr_flat_flowgraph_sptr new_ffg = d_owner->flatten();        
+  new_ffg->validate();                // check consistency, sanity, etc
+  new_ffg->merge_connections(d_ffg);   // reuse buffers, etc
 
   if (GR_TOP_BLOCK_IMPL_DEBUG)
     std::cout << "restart: replacing old flow graph with new" << std::endl;





reply via email to

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