diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-05-03 12:27:08 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-05-17 17:45:14 -0400 |
commit | fb1d5f822e3a273db88b2087b8d53be67725d232 (patch) | |
tree | dbc3694e025b541efa9b88f30eb354bcd7a0c438 /gnuradio-runtime/lib/basic_block.cc | |
parent | 4c2cb19a23a0b608617330bba80dd19cbb0c37dc (diff) |
grc: adding advanced tab feature to set a block's alias.
Does not allow for setting individual block aliases underneath a hier_block.
runtime: updates block registery to support updating block's alias that's then accessible through alias().
Adds an update_symbolic_name to the block_registry to delete the old key and add the new one. The block_registry only keeps the symbol_name (which never changes during the lifetime of the block) and the latest alias name that was set.
Diffstat (limited to 'gnuradio-runtime/lib/basic_block.cc')
-rw-r--r-- | gnuradio-runtime/lib/basic_block.cc | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/gnuradio-runtime/lib/basic_block.cc b/gnuradio-runtime/lib/basic_block.cc index 40edf09b01..686c1d6e65 100644 --- a/gnuradio-runtime/lib/basic_block.cc +++ b/gnuradio-runtime/lib/basic_block.cc @@ -71,8 +71,17 @@ namespace gr { void basic_block::set_block_alias(std::string name) - { - global_block_registry.register_symbolic_name(this, name); + { + // Only keep one alias'd name around for each block. If we don't + // have an alias, add it; if we do, update the entry in the + // registry. + if(alias_set()) + global_block_registry.update_symbolic_name(this, name); + else + global_block_registry.register_symbolic_name(this, name); + + // set the block's alias + d_symbol_alias = name; } // ** Message passing interface ** @@ -131,7 +140,7 @@ namespace gr { if(!pmt::dict_has_key(d_message_subscribers, port_id)) { throw std::runtime_error("port does not exist"); } - + pmt::pmt_t currlist = pmt::dict_ref(d_message_subscribers, port_id, pmt::PMT_NIL); // iterate through subscribers on port while(pmt::is_pair(currlist)) { @@ -139,7 +148,7 @@ namespace gr { pmt::pmt_t block = pmt::car(target); pmt::pmt_t port = pmt::cdr(target); - + currlist = pmt::cdr(currlist); basic_block_sptr blk = global_block_registry.block_lookup(block); //blk->post(msg); @@ -150,14 +159,14 @@ namespace gr { // - subscribe to a message port void basic_block::message_port_sub(pmt::pmt_t port_id, pmt::pmt_t target){ - if(!pmt::dict_has_key(d_message_subscribers, port_id)){ + if(!pmt::dict_has_key(d_message_subscribers, port_id)){ std::stringstream ss; ss << "Port does not exist: \"" << pmt::write_string(port_id) << "\" on block: " << pmt::write_string(target) << std::endl; throw std::runtime_error(ss.str()); } pmt::pmt_t currlist = pmt::dict_ref(d_message_subscribers,port_id,pmt::PMT_NIL); - + // ignore re-adds of the same target if(!pmt::list_has(currlist, target)) d_message_subscribers = pmt::dict_add(d_message_subscribers,port_id,pmt::list_add(currlist,target)); @@ -166,13 +175,13 @@ namespace gr { void basic_block::message_port_unsub(pmt::pmt_t port_id, pmt::pmt_t target) { - if(!pmt::dict_has_key(d_message_subscribers, port_id)) { + if(!pmt::dict_has_key(d_message_subscribers, port_id)) { std::stringstream ss; ss << "Port does not exist: \"" << pmt::write_string(port_id) << "\" on block: " << pmt::write_string(target) << std::endl; throw std::runtime_error(ss.str()); } - + // ignore unsubs of unknown targets pmt::pmt_t currlist = pmt::dict_ref(d_message_subscribers,port_id,pmt::PMT_NIL); d_message_subscribers = pmt::dict_add(d_message_subscribers,port_id,pmt::list_rm(currlist,target)); @@ -230,7 +239,7 @@ namespace gr { return m; } - pmt::pmt_t + pmt::pmt_t basic_block::message_subscribers(pmt::pmt_t port) { return pmt::dict_ref(d_message_subscribers,port,pmt::PMT_NIL); |