diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2019-10-05 17:20:53 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2020-01-02 18:06:50 -0800 |
commit | 6fb8fcd299c9522ce05f6682f4ea94b2c691835c (patch) | |
tree | a18f11d5707f49c33854c8145ad975553cdcb009 | |
parent | 863490f489c2e0cb73ee5a4bff8f288fdf916cd5 (diff) |
random_pdu: random facilities use C++11 (minus boost)
-rw-r--r-- | gr-blocks/lib/random_pdu_impl.cc | 6 | ||||
-rw-r--r-- | gr-blocks/lib/random_pdu_impl.h | 11 |
2 files changed, 7 insertions, 10 deletions
diff --git a/gr-blocks/lib/random_pdu_impl.cc b/gr-blocks/lib/random_pdu_impl.cc index 75d825aefa..4d847fc25c 100644 --- a/gr-blocks/lib/random_pdu_impl.cc +++ b/gr-blocks/lib/random_pdu_impl.cc @@ -45,8 +45,6 @@ random_pdu_impl::random_pdu_impl(int min_items, : block("random_pdu", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)), d_urange(min_items, max_items), d_brange(0, 255), - d_rvar(d_rng, d_urange), - d_bvar(d_rng, d_brange), d_mask(byte_mask), d_length_modulo(length_modulo) { @@ -69,13 +67,13 @@ bool random_pdu_impl::start() void random_pdu_impl::output_random() { // pick a random vector length - int len = d_rvar(); + int len = d_urange(d_rng); len = std::max(d_length_modulo, len - len % d_length_modulo); // fill it with random bytes std::vector<unsigned char> vec(len); for (int i = 0; i < len; i++) - vec[i] = ((unsigned char)d_bvar()) & d_mask; + vec[i] = ((unsigned char)d_brange(d_rng)) & d_mask; // send the vector pmt::pmt_t vecpmt(pmt::make_blob(&vec[0], len)); diff --git a/gr-blocks/lib/random_pdu_impl.h b/gr-blocks/lib/random_pdu_impl.h index 6745dcde0b..bd99d4d0a7 100644 --- a/gr-blocks/lib/random_pdu_impl.h +++ b/gr-blocks/lib/random_pdu_impl.h @@ -25,7 +25,8 @@ #include <gnuradio/blocks/random_pdu.h> #include <boost/generator_iterator.hpp> -#include <boost/random.hpp> + +#include <random> namespace gr { namespace blocks { @@ -33,11 +34,9 @@ namespace blocks { class random_pdu_impl : public random_pdu { private: - boost::mt19937 d_rng; - boost::uniform_int<> d_urange; - boost::uniform_int<> d_brange; - boost::variate_generator<boost::mt19937, boost::uniform_int<>> d_rvar; // pdu length - boost::variate_generator<boost::mt19937, boost::uniform_int<>> d_bvar; // pdu contents + std::mt19937 d_rng; + std::uniform_int_distribution<> d_urange; + std::uniform_int_distribution<> d_brange; unsigned char d_mask; int d_length_modulo; |