summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcorgan2007-08-29 19:16:10 +0000
committerjcorgan2007-08-29 19:16:10 +0000
commit2a88d301ecdc95266e8f84fe36be646f78a9895a (patch)
tree63ecf552216d4a63054a8f22ffee96ab99e6bac0
parent0786370660817056e2ecb6b9793894678445a1a8 (diff)
downloadgnuradio-2a88d301ecdc95266e8f84fe36be646f78a9895a.tar.gz
gnuradio-2a88d301ecdc95266e8f84fe36be646f78a9895a.tar.bz2
gnuradio-2a88d301ecdc95266e8f84fe36be646f78a9895a.zip
Clean up shared pointer casting.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6208 221aa14e-8319-0410-a670-987f0aec2ac5
-rw-r--r--gnuradio-core/src/lib/runtime/gr_hier_block2.h4
-rw-r--r--gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc14
2 files changed, 11 insertions, 7 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2.h b/gnuradio-core/src/lib/runtime/gr_hier_block2.h
index 51eb687ed..7ecc0d770 100644
--- a/gnuradio-core/src/lib/runtime/gr_hier_block2.h
+++ b/gnuradio-core/src/lib/runtime/gr_hier_block2.h
@@ -89,4 +89,8 @@ public:
gr_flat_flowgraph_sptr flatten() const;
};
+inline gr_hier_block2_sptr make_hier_block2_sptr(gr_basic_block_sptr block) {
+ return boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(block);
+}
+
#endif /* INCLUDED_GR_HIER_BLOCK2_H */
diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
index 1412a284c..76d23cab0 100644
--- a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
+++ b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
@@ -57,8 +57,8 @@ gr_hier_block2_detail::connect(gr_basic_block_sptr src, int src_port,
if (src.get() == dst.get())
throw std::invalid_argument("connect: src and destination blocks cannot be the same");
- gr_hier_block2_sptr src_block(boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(src));
- gr_hier_block2_sptr dst_block(boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(dst));
+ gr_hier_block2_sptr src_block(make_hier_block2_sptr(src));
+ gr_hier_block2_sptr dst_block(make_hier_block2_sptr(dst));
if (src_block && src.get() != d_owner) {
if (GR_HIER_BLOCK2_DETAIL_DEBUG)
@@ -111,8 +111,8 @@ gr_hier_block2_detail::disconnect(gr_basic_block_sptr src, int src_port,
if (src.get() == dst.get())
throw std::invalid_argument("disconnect: source and destination blocks cannot be the same");
- gr_hier_block2_sptr src_block(boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(src));
- gr_hier_block2_sptr dst_block(boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(dst));
+ gr_hier_block2_sptr src_block(make_hier_block2_sptr(src));
+ gr_hier_block2_sptr dst_block(make_hier_block2_sptr(dst));
if (src_block && src.get() != d_owner) {
if (GR_HIER_BLOCK2_DETAIL_DEBUG)
@@ -258,11 +258,11 @@ gr_hier_block2_detail::resolve_endpoint(const gr_endpoint &endp, bool is_input)
std::stringstream msg;
// Check if endpoint is a leaf node
- if (boost::dynamic_pointer_cast<gr_block, gr_basic_block>(endp.block()))
+ if (make_gr_block_sptr(endp.block()))
return endp;
// Check if endpoint is a hierarchical block
- gr_hier_block2_sptr hier_block2(boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(endp.block()));
+ gr_hier_block2_sptr hier_block2(make_hier_block2_sptr(endp.block()));
if (hier_block2) {
if (GR_HIER_BLOCK2_DETAIL_DEBUG)
std::cout << "Resolving endpoint " << endp << " as an "
@@ -298,7 +298,7 @@ gr_hier_block2_detail::flatten_aux(gr_flat_flowgraph_sptr sfg) const
// Recurse hierarchical children
for (gr_basic_block_viter_t p = blocks.begin(); p != blocks.end(); p++) {
- gr_hier_block2_sptr hier_block2(boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(*p));
+ gr_hier_block2_sptr hier_block2(make_hier_block2_sptr(*p));
if (hier_block2)
hier_block2->d_detail->flatten_aux(sfg);
}