You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/net-wireless/gnuradio/files/gnuradio-3.8.2.0-lamda-set-...

299 lines
14 KiB

From 7c841011f9316d4aae068b444c995829e09278d7 Mon Sep 17 00:00:00 2001
From: Johannes Demel <demel@ant.uni-bremen.de>
Date: Sat, 9 May 2020 14:25:32 +0200
Subject: [PATCH] msg_handler: Use lambdas to set msg handlers
With this commit, all calls to `set_msg_handler` in `gr-blocks` use
lambdas. This helps to use `std::function` instead of `boost::function`.
---
gnuradio-runtime/lib/block.cc | 3 +--
gr-blocks/lib/copy_impl.cc | 2 +-
gr-blocks/lib/message_debug_impl.cc | 6 +++---
gr-blocks/lib/message_strobe_impl.cc | 3 +--
gr-blocks/lib/message_strobe_random_impl.cc | 3 +--
gr-blocks/lib/multiply_matrix_impl.cc | 7 ++-----
gr-blocks/lib/mute_impl.cc | 2 +-
gr-blocks/lib/nop_impl.cc | 3 +--
gr-blocks/lib/pdu_filter_impl.cc | 2 +-
gr-blocks/lib/pdu_remove_impl.cc | 2 +-
gr-blocks/lib/pdu_set_impl.cc | 3 ++-
gr-blocks/lib/random_pdu_impl.cc | 2 +-
gr-blocks/lib/repeat_impl.cc | 2 +-
gr-blocks/lib/socket_pdu_impl.cc | 8 ++++----
gr-blocks/lib/tagged_stream_multiply_length_impl.cc | 5 ++---
gr-blocks/lib/tuntap_pdu_impl.cc | 2 +-
16 files changed, 24 insertions(+), 31 deletions(-)
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index 5914283908..beec8c470c 100644
--- a/gnuradio-runtime/lib/block.cc
+++ b/gnuradio-runtime/lib/block.cc
@@ -61,9 +61,8 @@ block::block(const std::string& name,
{
global_block_registry.register_primitive(alias(), this);
message_port_register_in(d_system_port);
- set_msg_handler(d_system_port, boost::bind(&block::system_handler, this, _1));
-
configure_default_loggers(d_logger, d_debug_logger, symbol_name());
+ set_msg_handler(d_system_port, [this](pmt::pmt_t msg) { this->system_handler(msg); });
}
block::~block() { global_block_registry.unregister_primitive(symbol_name()); }
diff --git a/gr-blocks/lib/copy_impl.cc b/gr-blocks/lib/copy_impl.cc
index c377e57b1e..4c97d07a76 100644
--- a/gr-blocks/lib/copy_impl.cc
+++ b/gr-blocks/lib/copy_impl.cc
@@ -44,7 +44,7 @@ copy_impl::copy_impl(size_t itemsize)
d_enabled(true)
{
message_port_register_in(pmt::mp("en"));
- set_msg_handler(pmt::mp("en"), boost::bind(&copy_impl::handle_enable, this, _1));
+ set_msg_handler(pmt::mp("en"), [this](pmt::pmt_t msg) { this->handle_enable(msg); });
}
copy_impl::~copy_impl() {}
diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc
index a8c84aa509..719fbd818a 100644
--- a/gr-blocks/lib/message_debug_impl.cc
+++ b/gr-blocks/lib/message_debug_impl.cc
@@ -90,14 +90,14 @@ message_debug_impl::message_debug_impl()
: block("message_debug", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0))
{
message_port_register_in(pmt::mp("print"));
- set_msg_handler(pmt::mp("print"), boost::bind(&message_debug_impl::print, this, _1));
+ set_msg_handler(pmt::mp("print"), [this](pmt::pmt_t msg) { this->print(msg); });
message_port_register_in(pmt::mp("store"));
- set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1));
+ set_msg_handler(pmt::mp("store"), [this](pmt::pmt_t msg) { this->store(msg); });
message_port_register_in(pmt::mp("print_pdu"));
set_msg_handler(pmt::mp("print_pdu"),
- boost::bind(&message_debug_impl::print_pdu, this, _1));
+ [this](pmt::pmt_t msg) { this->print_pdu(msg); });
}
message_debug_impl::~message_debug_impl() {}
diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc
index 038eeae5a1..67a95be8f2 100644
--- a/gr-blocks/lib/message_strobe_impl.cc
+++ b/gr-blocks/lib/message_strobe_impl.cc
@@ -53,8 +53,7 @@ message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, long period_ms)
message_port_register_out(d_port);
message_port_register_in(pmt::mp("set_msg"));
- set_msg_handler(pmt::mp("set_msg"),
- boost::bind(&message_strobe_impl::set_msg, this, _1));
+ set_msg_handler(pmt::mp("set_msg"), [this](pmt::pmt_t msg) { this->set_msg(msg); });
}
message_strobe_impl::~message_strobe_impl() {}
diff --git a/gr-blocks/lib/message_strobe_random_impl.cc b/gr-blocks/lib/message_strobe_random_impl.cc
index 0ab5d6adc7..1b8deca952 100644
--- a/gr-blocks/lib/message_strobe_random_impl.cc
+++ b/gr-blocks/lib/message_strobe_random_impl.cc
@@ -74,8 +74,7 @@ message_strobe_random_impl::message_strobe_random_impl(
new gr::thread::thread(boost::bind(&message_strobe_random_impl::run, this)));
message_port_register_in(pmt::mp("set_msg"));
- set_msg_handler(pmt::mp("set_msg"),
- boost::bind(&message_strobe_random_impl::set_msg, this, _1));
+ set_msg_handler(pmt::mp("set_msg"), [this](pmt::pmt_t msg) { this->set_msg(msg); });
}
long message_strobe_random_impl::next_delay()
diff --git a/gr-blocks/lib/multiply_matrix_impl.cc b/gr-blocks/lib/multiply_matrix_impl.cc
index e1b9c746c6..03e7894536 100644
--- a/gr-blocks/lib/multiply_matrix_impl.cc
+++ b/gr-blocks/lib/multiply_matrix_impl.cc
@@ -235,9 +235,7 @@ multiply_matrix_impl<gr_complex>::multiply_matrix_impl(
pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
message_port_register_in(port_name);
- set_msg_handler(
- port_name,
- boost::bind(&multiply_matrix_impl<gr_complex>::msg_handler_A, this, _1));
+ set_msg_handler(port_name, [this](pmt::pmt_t msg) { this->msg_handler_A(msg); });
}
template <>
@@ -256,8 +254,7 @@ multiply_matrix_impl<float>::multiply_matrix_impl(
pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
message_port_register_in(port_name);
- set_msg_handler(port_name,
- boost::bind(&multiply_matrix_impl<float>::msg_handler_A, this, _1));
+ set_msg_handler(port_name, [this](pmt::pmt_t msg) { this->msg_handler_A(msg); });
}
diff --git a/gr-blocks/lib/mute_impl.cc b/gr-blocks/lib/mute_impl.cc
index bd65ce2075..c9a1d200c8 100644
--- a/gr-blocks/lib/mute_impl.cc
+++ b/gr-blocks/lib/mute_impl.cc
@@ -48,7 +48,7 @@ mute_impl<T>::mute_impl(bool mute)
{
this->message_port_register_in(pmt::intern("set_mute"));
this->set_msg_handler(pmt::intern("set_mute"),
- boost::bind(&mute_impl<T>::set_mute_pmt, this, _1));
+ [this](pmt::pmt_t msg) { this->set_mute_pmt(msg); });
}
template <class T>
diff --git a/gr-blocks/lib/nop_impl.cc b/gr-blocks/lib/nop_impl.cc
index db216d97a4..4e1e887f42 100644
--- a/gr-blocks/lib/nop_impl.cc
+++ b/gr-blocks/lib/nop_impl.cc
@@ -26,7 +26,6 @@
#include "nop_impl.h"
#include <gnuradio/io_signature.h>
-#include <boost/bind.hpp>
namespace gr {
namespace blocks {
@@ -45,7 +44,7 @@ nop_impl::nop_impl(size_t sizeof_stream_item)
// Arrange to have count_received_msgs called when messages are received.
message_port_register_in(pmt::mp("port"));
set_msg_handler(pmt::mp("port"),
- boost::bind(&nop_impl::count_received_msgs, this, _1));
+ [this](pmt::pmt_t msg) { this->count_received_msgs(msg); });
}
nop_impl::~nop_impl() {}
diff --git a/gr-blocks/lib/pdu_filter_impl.cc b/gr-blocks/lib/pdu_filter_impl.cc
index b0748eec02..760027a78c 100644
--- a/gr-blocks/lib/pdu_filter_impl.cc
+++ b/gr-blocks/lib/pdu_filter_impl.cc
@@ -45,7 +45,7 @@ pdu_filter_impl::pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert)
message_port_register_out(pdu::pdu_port_id());
message_port_register_in(pdu::pdu_port_id());
set_msg_handler(pdu::pdu_port_id(),
- boost::bind(&pdu_filter_impl::handle_msg, this, _1));
+ [this](pmt::pmt_t msg) { this->handle_msg(msg); });
}
void pdu_filter_impl::handle_msg(pmt::pmt_t pdu)
diff --git a/gr-blocks/lib/pdu_remove_impl.cc b/gr-blocks/lib/pdu_remove_impl.cc
index 19cc4dc76a..58277ca0d0 100644
--- a/gr-blocks/lib/pdu_remove_impl.cc
+++ b/gr-blocks/lib/pdu_remove_impl.cc
@@ -43,7 +43,7 @@ pdu_remove_impl::pdu_remove_impl(pmt::pmt_t k)
message_port_register_out(pdu::pdu_port_id());
message_port_register_in(pdu::pdu_port_id());
set_msg_handler(pdu::pdu_port_id(),
- boost::bind(&pdu_remove_impl::handle_msg, this, _1));
+ [this](pmt::pmt_t msg) { this->handle_msg(msg); });
}
void pdu_remove_impl::handle_msg(pmt::pmt_t pdu)
diff --git a/gr-blocks/lib/pdu_set_impl.cc b/gr-blocks/lib/pdu_set_impl.cc
index 40fbc3cd83..61f1bb1284 100644
--- a/gr-blocks/lib/pdu_set_impl.cc
+++ b/gr-blocks/lib/pdu_set_impl.cc
@@ -43,7 +43,8 @@ pdu_set_impl::pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v)
{
message_port_register_out(pdu::pdu_port_id());
message_port_register_in(pdu::pdu_port_id());
- set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_set_impl::handle_msg, this, _1));
+ set_msg_handler(pdu::pdu_port_id(),
+ [this](pmt::pmt_t msg) { this->handle_msg(msg); });
}
void pdu_set_impl::handle_msg(pmt::pmt_t pdu)
diff --git a/gr-blocks/lib/random_pdu_impl.cc b/gr-blocks/lib/random_pdu_impl.cc
index 75d825aefa..5207a779d6 100644
--- a/gr-blocks/lib/random_pdu_impl.cc
+++ b/gr-blocks/lib/random_pdu_impl.cc
@@ -53,7 +53,7 @@ random_pdu_impl::random_pdu_impl(int min_items,
message_port_register_out(pdu::pdu_port_id());
message_port_register_in(pmt::mp("generate"));
set_msg_handler(pmt::mp("generate"),
- boost::bind(&random_pdu_impl::generate_pdu, this, _1));
+ [this](pmt::pmt_t msg) { this->generate_pdu(msg); });
if (length_modulo < 1)
throw std::runtime_error("length_module must be >= 1");
if (max_items < length_modulo)
diff --git a/gr-blocks/lib/repeat_impl.cc b/gr-blocks/lib/repeat_impl.cc
index 189fbc8948..7262b11a2e 100644
--- a/gr-blocks/lib/repeat_impl.cc
+++ b/gr-blocks/lib/repeat_impl.cc
@@ -45,7 +45,7 @@ repeat_impl::repeat_impl(size_t itemsize, int interp)
{
message_port_register_in(pmt::mp("interpolation"));
set_msg_handler(pmt::mp("interpolation"),
- boost::bind(&repeat_impl::msg_set_interpolation, this, _1));
+ [this](pmt::pmt_t msg) { this->msg_set_interpolation(msg); });
}
void repeat_impl::msg_set_interpolation(pmt::pmt_t msg)
diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc
index df69f07ad2..edf572e76c 100644
--- a/gr-blocks/lib/socket_pdu_impl.cc
+++ b/gr-blocks/lib/socket_pdu_impl.cc
@@ -101,7 +101,7 @@ socket_pdu_impl::socket_pdu_impl(std::string type,
start_tcp_accept();
set_msg_handler(pdu::pdu_port_id(),
- boost::bind(&socket_pdu_impl::tcp_server_send, this, _1));
+ [this](pmt::pmt_t msg) { this->tcp_server_send(msg); });
} else if (type == "TCP_CLIENT") {
boost::system::error_code error = boost::asio::error::host_not_found;
d_tcp_socket.reset(new boost::asio::ip::tcp::socket(d_io_service));
@@ -111,7 +111,7 @@ socket_pdu_impl::socket_pdu_impl(std::string type,
d_tcp_socket->set_option(boost::asio::ip::tcp::no_delay(d_tcp_no_delay));
set_msg_handler(pdu::pdu_port_id(),
- boost::bind(&socket_pdu_impl::tcp_client_send, this, _1));
+ [this](pmt::pmt_t msg) { this->tcp_client_send(msg); });
d_tcp_socket->async_read_some(
boost::asio::buffer(d_rxbuf),
@@ -131,7 +131,7 @@ socket_pdu_impl::socket_pdu_impl(std::string type,
boost::asio::placeholders::bytes_transferred));
set_msg_handler(pdu::pdu_port_id(),
- boost::bind(&socket_pdu_impl::udp_send, this, _1));
+ [this](pmt::pmt_t msg) { this->udp_send(msg); });
} else if (type == "UDP_CLIENT") {
d_udp_socket.reset(
new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint));
@@ -144,7 +144,7 @@ socket_pdu_impl::socket_pdu_impl(std::string type,
boost::asio::placeholders::bytes_transferred));
set_msg_handler(pdu::pdu_port_id(),
- boost::bind(&socket_pdu_impl::udp_send, this, _1));
+ [this](pmt::pmt_t msg) { this->udp_send(msg); });
} else
throw std::runtime_error("gr::blocks:socket_pdu: unknown socket type");
diff --git a/gr-blocks/lib/tagged_stream_multiply_length_impl.cc b/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
index 30f4c46dc6..2266c01fe3 100644
--- a/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
+++ b/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
@@ -49,9 +49,8 @@ tagged_stream_multiply_length_impl::tagged_stream_multiply_length_impl(
set_tag_propagation_policy(TPP_DONT);
set_relative_rate(1, 1);
message_port_register_in(pmt::intern("set_scalar"));
- set_msg_handler(
- pmt::intern("set_scalar"),
- boost::bind(&tagged_stream_multiply_length_impl::set_scalar_pmt, this, _1));
+ set_msg_handler(pmt::intern("set_scalar"),
+ [this](pmt::pmt_t msg) { this->set_scalar_pmt(msg); });
}
tagged_stream_multiply_length_impl::~tagged_stream_multiply_length_impl() {}
diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc
index 4343ae1dc3..19742235d9 100644
--- a/gr-blocks/lib/tuntap_pdu_impl.cc
+++ b/gr-blocks/lib/tuntap_pdu_impl.cc
@@ -96,7 +96,7 @@ tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU, bool istunflag)
// set up input message port
message_port_register_in(pdu::pdu_port_id());
- set_msg_handler(pdu::pdu_port_id(), boost::bind(&tuntap_pdu_impl::send, this, _1));
+ set_msg_handler(pdu::pdu_port_id(), [this](pmt::pmt_t msg) { this->send(msg); });
}
int tuntap_pdu_impl::tun_alloc(char* dev, int flags)