[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3889 - in gnuradio/branches/developers/jcorgan/hier/g
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r3889 - in gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src: lib/runtime python/gnuradio/gr |
Date: |
Sat, 28 Oct 2006 00:53:52 -0600 (MDT) |
Author: jcorgan
Date: 2006-10-28 00:53:52 -0600 (Sat, 28 Oct 2006)
New Revision: 3889
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_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/python/gnuradio/gr/qa_hier_block2.py
Log:
Work in progress.
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-10-28 06:17:44 UTC (rev 3888)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
2006-10-28 06:53:52 UTC (rev 3889)
@@ -57,4 +57,6 @@
if (d_impl->lookup_component(name))
throw std::invalid_argument("Component already defined");
+
+ d_impl->d_components.push_back(gr_hier_component(name, comp));
}
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-10-28 06:17:44 UTC (rev 3888)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
2006-10-28 06:53:52 UTC (rev 3889)
@@ -39,9 +39,11 @@
gr_basic_block_sptr gr_hier_block2_impl::lookup_component(std::string name)
{
- gr_basic_block_sptr result;
+ for (std::vector<gr_hier_component>::const_iterator p =
d_components.begin();
+ p != d_components.end(); p++) {
+ if (name == p->name())
+ return p->component();
+ }
- // NOP
-
- return result;
-}
\ No newline at end of file
+ return gr_basic_block_sptr();
+}
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-10-28 06:17:44 UTC (rev 3888)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
2006-10-28 06:53:52 UTC (rev 3889)
@@ -28,6 +28,21 @@
#include <gr_basic_block.h>
#include <stdexcept>
+// This beats the hell out of using pairs
+class gr_hier_component
+{
+private:
+ std::string d_name;
+ gr_basic_block_sptr d_component;
+
+public:
+ gr_hier_component(const std::string name, gr_basic_block_sptr component)
+ : d_name(name), d_component(component) {}
+
+ std::string name() const { return d_name; }
+ gr_basic_block_sptr component() const { return d_component; }
+};
+
class gr_hier_block2_impl
{
private:
@@ -38,6 +53,8 @@
gr_hier_block2_impl(const gr_hier_block2_impl &rhs);
gr_hier_block2_impl &operator=(const gr_hier_block2_impl &rhs);
+ std::vector<gr_hier_component> d_components;
+
gr_basic_block_sptr lookup_component(const std::string name);
public:
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
===================================================================
---
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
2006-10-28 06:17:44 UTC (rev 3888)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
2006-10-28 06:53:52 UTC (rev 3889)
@@ -31,5 +31,18 @@
hblock.define_component("source", src1)
hblock.define_component("sink", sink1)
+ """
+ def test_003_define_component_already_defined(self):
+ hblock = gr.hier_block2("test_block",
+ gr.io_signature(1,1,gr.sizeof_int),
+ gr.io_signature(1,1,gr.sizeof_int))
+
+ src1 = gr.null_source(gr.sizeof_int)
+ sink1 = gr.null_sink(gr.sizeof_int)
+
+ hblock.define_component("source", src1)
+ self.assertRaises(RuntimeError, lambda:
hblock.define_component("source", sink1))
+ """
+
if __name__ == "__main__":
gr_unittest.main()
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3889 - in gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src: lib/runtime python/gnuradio/gr,
jcorgan <=