commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3971 - gnuradio/branches/developers/jcorgan/hier/gnur


From: jcorgan
Subject: [Commit-gnuradio] r3971 - gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime
Date: Sat, 11 Nov 2006 22:14:01 -0700 (MST)

Author: jcorgan
Date: 2006-11-11 22:14:01 -0700 (Sat, 11 Nov 2006)
New Revision: 3971

Modified:
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.h
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.cc
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.h
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.h
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
Log:
Work in progress.

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.h
    2006-11-11 23:21:12 UTC (rev 3970)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.h
    2006-11-12 05:14:01 UTC (rev 3971)
@@ -31,7 +31,7 @@
 {
 public:
     virtual ~gr_tree_visitor() {};
-    bool operator()(gr_basic_block_sptr block)         { return 
visited(block); }
+    bool operator()(gr_basic_block_sptr block) { return visited(block); }
     virtual bool visited(gr_basic_block_sptr block) = 0;
 };
 
@@ -68,15 +68,15 @@
         d_output_signature = iosig;
     }
 
-    
+        
 public:
     virtual ~gr_basic_block();
     long unique_id() const { return d_unique_id; }
     std::string name() const { return d_name; }
     gr_io_signature_sptr input_signature() const  { return d_input_signature; }
     gr_io_signature_sptr output_signature() const { return d_output_signature; 
}
-    gr_basic_block_sptr basic_block();
-
+    gr_basic_block_sptr basic_block(); // Needed for Python type coercion
+    
     /*! overridden in gr_hier_block2 to implement tree traversal
      *  otherwise invoke callback with shared pointer to this object
      */

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.cc
 2006-11-11 23:21:12 UTC (rev 3970)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.cc
 2006-11-12 05:14:01 UTC (rev 3971)
@@ -27,7 +27,10 @@
 #include <gr_block.h>
 #include <gr_block_detail.h>
 #include <stdexcept>
+#include <iostream>
 
+#define GR_BLOCK_DEBUG 1
+
 gr_block::gr_block (const std::string &name,
                    gr_io_signature_sptr input_signature,
                    gr_io_signature_sptr output_signature)
@@ -109,3 +112,15 @@
 {
   throw std::runtime_error("Unimplemented");
 }
+
+bool
+gr_block::validate()
+{
+    if (GR_BLOCK_DEBUG)
+       std::cout << "gr_block::validate()" << std::endl;
+
+    // Call my parent, get my assigned inputs and outputs, then call check 
topology,
+    // which may be overridden by descendent classes
+
+    return true; // Stub for now
+}

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.h
  2006-11-11 23:21:12 UTC (rev 3970)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.h
  2006-11-12 05:14:01 UTC (rev 3971)
@@ -197,8 +197,9 @@
   unsigned             d_history;
   bool                 d_fixed_rate;
 
-  // Overrides gr_basic_block
-  bool validate() { return true; }             // Nothing to do
+  // Overrides gr_basic_block.  Asks parent for assigned ports and calls
+  // check_topology on itself
+  virtual bool validate();
     
  protected:
 

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
   2006-11-11 23:21:12 UTC (rev 3970)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
   2006-11-12 05:14:01 UTC (rev 3971)
@@ -50,9 +50,9 @@
 }
 
 void 
-gr_hier_block2::define_component(const std::string &name, gr_basic_block_sptr 
basic_block)
+gr_hier_block2::define_component(const std::string &name, gr_basic_block_sptr 
block)
 {
-    d_impl->define_component(name, basic_block);
+    d_impl->define_component(name, block);
 }
 
 void 
@@ -101,5 +101,5 @@
 bool
 gr_hier_block2::validate()
 {
-    d_impl->validate();
+    return d_impl->validate();
 }

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.h
    2006-11-11 23:21:12 UTC (rev 3970)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.h
    2006-11-12 05:14:01 UTC (rev 3971)
@@ -37,7 +37,7 @@
  * \brief gr_hier_block2 - Hierarchical container class for gr_block's
  *
  */
-class gr_hier_block2 : public gr_basic_block 
+class gr_hier_block2 : public gr_basic_block
 {
 private:
     friend gr_hier_block2_sptr gr_make_hier_block2(const std::string &name,

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
      2006-11-11 23:21:12 UTC (rev 3970)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
      2006-11-12 05:14:01 UTC (rev 3971)
@@ -108,7 +108,7 @@
        throw std::invalid_argument("type mismatch");
 }
 
-void
+bool
 gr_hier_block2_impl::validate()
 {
     if (GR_HIER_BLOCK2_IMPL_DEBUG)
@@ -116,36 +116,16 @@
 
     /* General strategy for validating a hierarchical tree
 
-       The runtime will call this function with the top block, which is a 
-       hierarchical block.
-       
-       At each level in the hierarchy, one must ensure:
-       
-       1. Each hierarchical block has its inputs and outputs wired to 
-          its components
-       2. Each component (via check_topology) "agrees" with its number of ports
-       3. Each component has its input ports contiguously assigned
-       4. Each component has between min and max number of inputs connected
-       5. Each component has its output ports contiguously assigned
-       6. Each component has between min and max number of outputs connected
-       
-       Within the context of a hierarchical block, the current connnection list
-       provides enough information to check criteria #1 for oneself and #2-#6 
-       for all one's sub-components. So the recursive means to accomplish this 
-       is:
-       
-       1. When called, check the above criteria #1 for oneself
-       2. For each unique block in the connection list, check criteria #2-#6
-       3. For each hierarchical block in the connection list, recurse into its 
-          validate()
-       
-       To simplify step 3, the validate() function is defined as virtual in 
-       gr_basic_block, as that is what we hold shared pointers to.  We call 
-       validate() on all unique blocks in the current edge list.  If they are 
-       hierarchical blocks, we end up here. The validate() function in gr_block
-       is a stub returning 'true', as there is nothing to check for in a 
-       leaf block that isn't covered by 'check_topology' that gets called back
-       in step 2.
-    
+       The runtime will call 'visit' with a visitor function that calls 
validate() 
+       on the basic block that it gets passed at each node in the traversal.
+
+       For hierarchical blocks, we get here.  To be valid, we must check:
+               
+       1. Each of our inputs and outputs are wired according to our external
+          connectivity.
+       2. Each actually connected (sub)component has its input ports 
contiguously assigned
+       3. Each actually connected (sub)component has between min and max 
number of inputs connected
+       4. Each actually connected (sub)component has its output ports 
contiguously assigned
+       5. Each actually connected (sub)component has between min and max 
number of outputs connected
     */
 }

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
       2006-11-11 23:21:12 UTC (rev 3970)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
       2006-11-12 05:14:01 UTC (rev 3971)
@@ -86,7 +86,7 @@
     void check_dst_not_used(const std::string name, int port);
     void check_type_match(gr_io_signature_sptr src_sig, int src_port,
                          gr_io_signature_sptr dst_sig, int dst_port);
-    void validate();
+    bool validate();
                                 
 public:
     ~gr_hier_block2_impl();

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
  2006-11-11 23:21:12 UTC (rev 3970)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
  2006-11-12 05:14:01 UTC (rev 3971)
@@ -30,7 +30,6 @@
 #include <gr_hier_block2.h>
 #include <stdexcept>
 #include <iostream>
-#include <boost/bind.hpp>
 
 gr_runtime_impl::gr_runtime_impl(gr_hier_block2_sptr top_block) :
 d_running(false),
@@ -46,7 +45,7 @@
 {
 public:
     virtual bool visited(gr_basic_block_sptr block)
-       { std::cout << "validation_visitor::visited()" << std::endl; return 
block->validate(); }
+       { return block->validate(); }
 };
 
 void 
@@ -60,8 +59,8 @@
     else
        d_running = true;
 
-    validation_visitor validator;
-    if (!d_top_block->visit(validator))
+    validation_visitor visitor;
+    if (!d_top_block->visit(visitor))
        throw std::runtime_error("tree validation failed");
 }
 





reply via email to

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