commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: jcorgan
Subject: [Commit-gnuradio] r3959 - gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime
Date: Wed, 8 Nov 2006 15:15:01 -0700 (MST)

Author: jcorgan
Date: 2006-11-08 15:15:01 -0700 (Wed, 08 Nov 2006)
New Revision: 3959

Modified:
   
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.cc
   
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.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.i
   
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.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.cc
   2006-11-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.cc
   2006-11-08 22:15:01 UTC (rev 3959)
@@ -57,11 +57,3 @@
 {
     return shared_from_this();
 }
-
-// default implementation
-
-bool
-gr_basic_block::check_topology(int ninputs, int noutputs)
-{
-    return true;
-}

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-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.h
    2006-11-08 22:15:01 UTC (rev 3959)
@@ -60,6 +60,9 @@
         d_output_signature = iosig;
     }
 
+    //! overridden in gr_block and gr_hier_block2 for type sepcific behavior
+    virtual bool validate() { return true; }
+
 public:
     virtual ~gr_basic_block();
     long unique_id() const { return d_unique_id; }
@@ -81,7 +84,7 @@
      * This check is in addition to the constraints specified by the input
      * and output gr_io_signatures.
      */
-    virtual bool check_topology (int ninputs, int noutputs);
+    virtual bool check_topology(int ninputs, int noutputs) { return true; }
 };
 
 long gr_basic_block_ncurrently_allocated();

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-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.h
  2006-11-08 22:15:01 UTC (rev 3959)
@@ -197,7 +197,9 @@
   unsigned             d_history;
   bool                 d_fixed_rate;
 
-  
+  // Overrides gr_basic_block
+  bool validate() { return true; }             // Nothing to do
+    
  protected:
 
   gr_block (const std::string &name,

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-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
   2006-11-08 22:15:01 UTC (rev 3959)
@@ -97,3 +97,9 @@
                              gr_endpoint(dst_name, dst_port));
     d_impl->d_connections.push_back(connection);
 }
+
+bool
+gr_hier_block2::validate()
+{
+    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-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.h
    2006-11-08 22:15:01 UTC (rev 3959)
@@ -60,6 +60,9 @@
     void define_component(const std::string name, gr_basic_block_sptr 
basic_block);
     void connect(const std::string src_name, int src_port, 
                  const std::string dst_name, int dst_port);
+
+    // Overrides gr_basic_block, performs recursive validation of connections
+    bool validate();
 };
 
 inline std::ostream &operator << (std::ostream &os, gr_basic_block_sptr 
basic_block)

Modified: 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.i
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.i
    2006-11-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.i
    2006-11-08 22:15:01 UTC (rev 3959)
@@ -52,4 +52,5 @@
     void connect(const std::string src_name, int src_port,
                 const std::string dst_name, int dst_port)
        throw (std::invalid_argument);
+    bool validate();
 };

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-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
      2006-11-08 22:15:01 UTC (rev 3959)
@@ -24,6 +24,8 @@
 #include "config.h"
 #endif
 
+#define GR_HIER_BLOCK2_IMPL_DEBUG 1
+
 #include <gr_hier_block2_impl.h>
 #include <gr_io_signature.h>
 #include <iostream>
@@ -105,3 +107,45 @@
         dst_sig->sizeof_stream_item(dst_port))
        throw std::invalid_argument("type mismatch");
 }
+
+void
+gr_hier_block2_impl::validate()
+{
+    if (GR_HIER_BLOCK2_IMPL_DEBUG)
+       std::cout << "gr_hier_block2_impl::validate()" << std::endl;
+
+    /* 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.
+    
+    */
+}

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-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
       2006-11-08 22:15:01 UTC (rev 3959)
@@ -86,7 +86,8 @@
     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();
+                                
 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-08 15:53:07 UTC (rev 3958)
+++ 
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
  2006-11-08 22:15:01 UTC (rev 3959)
@@ -27,12 +27,13 @@
 #define GR_RUNTIME_IMPL_DEBUG 1
 
 #include <gr_runtime_impl.h>
+#include <gr_hier_block2.h>
 #include <stdexcept>
 #include <iostream>
 
 gr_runtime_impl::gr_runtime_impl(gr_hier_block2_sptr top_block) :
-d_top_block(top_block),
-d_running(false)
+d_running(false),
+d_top_block(top_block)
 {
 }
   
@@ -47,11 +48,12 @@
        std::cout << "gr_runtime_impl::start()" << std::endl;
 
     if (d_running)
-       throw std::runtime_error("Already running");
+       throw std::runtime_error("already running");
     else
        d_running = true;
 
-    // Start
+    if (!d_top_block->validate())
+       throw std::runtime_error("tree validation failed");
 }
 
 void 





reply via email to

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