[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3858 - gnuradio/branches/developers/jcorgan/cppwrap/g
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r3858 - gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime |
Date: |
Wed, 25 Oct 2006 14:58:17 -0600 (MDT) |
Author: jcorgan
Date: 2006-10-25 14:58:17 -0600 (Wed, 25 Oct 2006)
New Revision: 3858
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_basic_flowgraph.cc
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_basic_flowgraph.h
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_flow_graph.cc
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/qa_gr_basic_flowgraph.cc
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/qa_gr_basic_flowgraph.h
Log:
Work in progress.
Added public 'validate' function to gr_basic_flowgraph to test
functions normally called only from derived class gr_flow_graph.
Added QA test for validate function.
Fixed removing duplicates from vectors technique.
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_basic_flowgraph.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_basic_flowgraph.cc
2006-10-25 19:54:41 UTC (rev 3857)
+++
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_basic_flowgraph.cc
2006-10-25 20:58:17 UTC (rev 3858)
@@ -79,6 +79,14 @@
#endif
}
+// validates flowgraph toplogy and finalizes internal structures
+// Throws exceptions on errors
+void gr_basic_flowgraph::validate()
+{
+ create_block_list();
+ connect_blocks();
+}
+
// Returns list of lists of blocks comprising unique islands
// of connectivity in flow graph.
gr_block_vector_vector_t gr_basic_flowgraph::calc_partitions()
@@ -313,25 +321,26 @@
vector<int> gr_basic_flowgraph::calc_used_ports(gr_block_sptr block, bool
direction)
{
gr_edge_vector_iterator_t edge_iter;
- vector<int> result;
+ vector<int> tmp, result;
+ insert_iterator<vector<int> > inserter(result, result.begin());
gr_block_sptr cmp_block;
for(edge_iter = d_edges.begin(); edge_iter != d_edges.end(); edge_iter++) {
if (!direction) { // inputs
cmp_block = edge_iter->second.first;
if (cmp_block == block)
- result.push_back(edge_iter->second.second);
+ tmp.push_back(edge_iter->second.second);
}
else { // outputs
cmp_block = edge_iter->first.first;
if (cmp_block == block)
- result.push_back(edge_iter->first.second);
+ tmp.push_back(edge_iter->first.second);
}
}
// Remove duplicates
- sort(result.begin(), result.end());
- unique(result.begin(), result.end());
+ sort(tmp.begin(), tmp.end());
+ unique_copy(tmp.begin(), tmp.end(), inserter);
return result;
}
@@ -354,29 +363,38 @@
}
}
+#if GR_FLOWGRAPH_DEBUG
+ cout << "Checking contiguity of block " << block << " with " << l << "
used ports." << endl;
+#endif
+
if (used_ports[l-1]+1 < min_s)
throw invalid_argument("gr_basic_flowgraph::check_contiguity:
insufficient inputs");
if (used_ports[l-1]+1 != l) {
- for (int i = 0; i < l; i++)
- if (used_ports[i] != i)
+ for (int i = 0; i < l; i++) {
+#if GR_FLOWGRAPH_DEBUG
+ cout << "Port " << i << " = " << used_ports[i] << endl;
+#endif
+ if (used_ports[i] != i)
throw invalid_argument("gr_basic_flowgraph::check_contiguity:
missing input");
+ }
}
}
// Return list of blocks downstream of a given endpoint
gr_block_vector_t gr_basic_flowgraph::calc_downstream_blocks(gr_endpoint_t src)
{
- gr_block_vector_t result;
+ gr_block_vector_t tmp, result;
+ insert_iterator<gr_block_vector_t> inserter(result, result.begin());
gr_edge_vector_iterator_t edge_iter;
for(edge_iter = d_edges.begin(); edge_iter != d_edges.end(); edge_iter++)
if (edge_iter->first == src)
- result.push_back(edge_iter->second.first);
+ tmp.push_back(edge_iter->second.first);
// Remove duplicates
- sort(result.begin(), result.end());
- unique(result.begin(), result.end());
+ sort(tmp.begin(), tmp.end());
+ unique_copy(tmp.begin(), tmp.end(), inserter);
return result;
}
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_basic_flowgraph.h
===================================================================
---
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_basic_flowgraph.h
2006-10-25 19:54:41 UTC (rev 3857)
+++
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_basic_flowgraph.h
2006-10-25 20:58:17 UTC (rev 3858)
@@ -105,6 +105,10 @@
gr_block_sptr dst_block, int dst_port);
void disconnect_all();
+ // Validates flowgraph topology and finalizes internal data structures
+ // Throws exceptions on errors
+ void validate();
+
// Returns a list of lists of blocks that represent distinct
// islands of connectivity in the graph
gr_block_vector_vector_t calc_partitions();
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_flow_graph.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_flow_graph.cc
2006-10-25 19:54:41 UTC (rev 3857)
+++
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/gr_flow_graph.cc
2006-10-25 20:58:17 UTC (rev 3858)
@@ -45,8 +45,7 @@
if (d_scheduler)
throw runtime_error("Scheduler already running!");
- create_block_list();
- connect_blocks();
+ validate();
d_scheduler = gr_make_scheduler(shared_from_this());
d_scheduler->start();
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/qa_gr_basic_flowgraph.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/qa_gr_basic_flowgraph.cc
2006-10-25 19:54:41 UTC (rev 3857)
+++
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/qa_gr_basic_flowgraph.cc
2006-10-25 20:58:17 UTC (rev 3858)
@@ -110,3 +110,14 @@
gr_block_sptr dst1 = gr_make_null_sink(sizeof(char));
d_fg->connect(src1, 0, dst1, 0);
}
+
+void qa_gr_basic_flowgraph::test_validate_1()
+{
+ CPPUNIT_ASSERT(d_fg);
+ gr_block_sptr src1 = gr_make_null_source(sizeof(int));
+ gr_block_sptr dst1 = gr_make_null_sink(sizeof(int));
+ gr_block_sptr dst2 = gr_make_null_sink(sizeof(int));
+ d_fg->connect(src1, 0, dst1, 0);
+ d_fg->connect(src1, 0, dst2, 0);
+ d_fg->validate();
+}
Modified:
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/qa_gr_basic_flowgraph.h
===================================================================
---
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/qa_gr_basic_flowgraph.h
2006-10-25 19:54:41 UTC (rev 3857)
+++
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime/qa_gr_basic_flowgraph.h
2006-10-25 20:58:17 UTC (rev 3858)
@@ -43,6 +43,7 @@
CPPUNIT_TEST_EXCEPTION(test_no_such_dst_port, std::out_of_range);
CPPUNIT_TEST(test_one_src_two_dst);
CPPUNIT_TEST_EXCEPTION(test_itemsize_mismatch, std::invalid_argument);
+ CPPUNIT_TEST(test_validate_1);
CPPUNIT_TEST_SUITE_END();
@@ -56,7 +57,8 @@
void test_no_such_dst_port();
void test_one_src_two_dst();
void test_itemsize_mismatch();
-
+ void test_validate_1();
+
public:
void setUp();
void tearDown();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3858 - gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-core/src/lib/runtime,
jcorgan <=