Changeset 3959
- Timestamp:
- 11/08/06 15:15:01
- Files:
-
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.cc (modified) (1 diff)
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.h (modified) (2 diffs)
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.h (modified) (1 diff)
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc (modified) (1 diff)
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.h (modified) (1 diff)
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.i (modified) (1 diff)
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc (modified) (2 diffs)
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h (modified) (1 diff)
- gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.cc
r3954 r3959 58 58 return shared_from_this(); 59 59 } 60 61 // default implementation62 63 bool64 gr_basic_block::check_topology(int ninputs, int noutputs)65 {66 return true;67 }gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_basic_block.h
r3954 r3959 61 61 } 62 62 63 //! overridden in gr_block and gr_hier_block2 for type sepcific behavior 64 virtual bool validate() { return true; } 65 63 66 public: 64 67 virtual ~gr_basic_block(); … … 82 85 * and output gr_io_signatures. 83 86 */ 84 virtual bool check_topology (int ninputs, int noutputs);87 virtual bool check_topology(int ninputs, int noutputs) { return true; } 85 88 }; 86 89 gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_block.h
r3954 r3959 198 198 bool d_fixed_rate; 199 199 200 200 // Overrides gr_basic_block 201 bool validate() { return true; } // Nothing to do 202 201 203 protected: 202 204 gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
r3953 r3959 98 98 d_impl->d_connections.push_back(connection); 99 99 } 100 101 bool 102 gr_hier_block2::validate() 103 { 104 d_impl->validate(); 105 } gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.h
r3953 r3959 61 61 void connect(const std::string src_name, int src_port, 62 62 const std::string dst_name, int dst_port); 63 64 // Overrides gr_basic_block, performs recursive validation of connections 65 bool validate(); 63 66 }; 64 67 gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.i
r3953 r3959 53 53 const std::string dst_name, int dst_port) 54 54 throw (std::invalid_argument); 55 bool validate(); 55 56 }; gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
r3953 r3959 24 24 #include "config.h" 25 25 #endif 26 27 #define GR_HIER_BLOCK2_IMPL_DEBUG 1 26 28 27 29 #include <gr_hier_block2_impl.h> … … 106 108 throw std::invalid_argument("type mismatch"); 107 109 } 110 111 void 112 gr_hier_block2_impl::validate() 113 { 114 if (GR_HIER_BLOCK2_IMPL_DEBUG) 115 std::cout << "gr_hier_block2_impl::validate()" << std::endl; 116 117 /* General strategy for validating a hierarchical tree 118 119 The runtime will call this function with the top block, which is a 120 hierarchical block. 121 122 At each level in the hierarchy, one must ensure: 123 124 1. Each hierarchical block has its inputs and outputs wired to 125 its components 126 2. Each component (via check_topology) "agrees" with its number of ports 127 3. Each component has its input ports contiguously assigned 128 4. Each component has between min and max number of inputs connected 129 5. Each component has its output ports contiguously assigned 130 6. Each component has between min and max number of outputs connected 131 132 Within the context of a hierarchical block, the current connnection list 133 provides enough information to check criteria #1 for oneself and #2-#6 134 for all one's sub-components. So the recursive means to accomplish this 135 is: 136 137 1. When called, check the above criteria #1 for oneself 138 2. For each unique block in the connection list, check criteria #2-#6 139 3. For each hierarchical block in the connection list, recurse into its 140 validate() 141 142 To simplify step 3, the validate() function is defined as virtual in 143 gr_basic_block, as that is what we hold shared pointers to. We call 144 validate() on all unique blocks in the current edge list. If they are 145 hierarchical blocks, we end up here. The validate() function in gr_block 146 is a stub returning 'true', as there is nothing to check for in a 147 leaf block that isn't covered by 'check_topology' that gets called back 148 in step 2. 149 150 */ 151 } gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
r3953 r3959 87 87 void check_type_match(gr_io_signature_sptr src_sig, int src_port, 88 88 gr_io_signature_sptr dst_sig, int dst_port); 89 89 void validate(); 90 90 91 public: 91 92 ~gr_hier_block2_impl(); gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
r3953 r3959 28 28 29 29 #include <gr_runtime_impl.h> 30 #include <gr_hier_block2.h> 30 31 #include <stdexcept> 31 32 #include <iostream> 32 33 33 34 gr_runtime_impl::gr_runtime_impl(gr_hier_block2_sptr top_block) : 34 d_ top_block(top_block),35 d_ running(false)35 d_running(false), 36 d_top_block(top_block) 36 37 { 37 38 } … … 48 49 49 50 if (d_running) 50 throw std::runtime_error(" Already running");51 throw std::runtime_error("already running"); 51 52 else 52 53 d_running = true; 53 54 54 // Start 55 if (!d_top_block->validate()) 56 throw std::runtime_error("tree validation failed"); 55 57 } 56 58
