GNU Radio's SATELLITES Package
selector_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2019 Free Software Foundation, Inc.
4 * Copyright 2023 Daniel Estevez <daniel@destevez.net>
5 *
6 * This file is part of gr-satellites
7 *
8 * SPDX-License-Identifier: GPL-3.0-or-later
9 *
10 * This is a copy of the GNU Radio Selector block modified to consume all the
11 * items that are available on inactive inputs. This is required to use selector
12 * blocks to bypass sections of the flowgraph. See
13 * https://github.com/gnuradio/gnuradio/issues/6792
14 * for more information.
15 *
16 */
17
18#ifndef INCLUDED_SATELLITES_SELECTOR_IMPL_H
19#define INCLUDED_SATELLITES_SELECTOR_IMPL_H
20
21#include <gnuradio/thread/thread.h>
22#include <satellites/selector.h>
23
24namespace gr {
25namespace satellites {
26
27class selector_impl : public selector
28{
29private:
30 const size_t d_itemsize;
31 unsigned int d_input_index, d_output_index;
32 unsigned int d_num_inputs, d_num_outputs; // keep track of the topology
33 bool d_enabled;
34
35 gr::thread::mutex d_mutex;
36
37public:
38 selector_impl(size_t itemsize, unsigned int input_index, unsigned int output_index);
39 ~selector_impl() override;
40
41 void forecast(int noutput_items, gr_vector_int& ninput_items_required) override;
42 bool check_topology(int ninputs, int noutputs) override;
43 void setup_rpc() override;
44 void handle_msg_input_index(const pmt::pmt_t& msg);
45 void handle_msg_output_index(const pmt::pmt_t& msg);
46 void handle_enable(const pmt::pmt_t& msg);
47 void set_enabled(bool enable) override
48 {
49 gr::thread::scoped_lock l(d_mutex);
50 d_enabled = enable;
51 }
52 bool enabled() const override { return d_enabled; }
53
54 void set_input_index(unsigned int input_index) override;
55 int input_index() const override { return d_input_index; }
56
57 void set_output_index(unsigned int output_index) override;
58 int output_index() const override { return d_output_index; }
59
60 int general_work(int noutput_items,
61 gr_vector_int& ninput_items,
62 gr_vector_const_void_star& input_items,
63 gr_vector_void_star& output_items) override;
64};
65
66} /* namespace satellites */
67} /* namespace gr */
68
69#endif /* INCLUDED_SATELLITES_SELECTOR_IMPL_H */
Definition: selector_impl.h:28
void forecast(int noutput_items, gr_vector_int &ninput_items_required) override
selector_impl(size_t itemsize, unsigned int input_index, unsigned int output_index)
bool check_topology(int ninputs, int noutputs) override
void set_enabled(bool enable) override
Definition: selector_impl.h:47
void handle_msg_output_index(const pmt::pmt_t &msg)
void handle_enable(const pmt::pmt_t &msg)
int input_index() const override
Definition: selector_impl.h:55
void set_input_index(unsigned int input_index) override
bool enabled() const override
Definition: selector_impl.h:52
void set_output_index(unsigned int output_index) override
void handle_msg_input_index(const pmt::pmt_t &msg)
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override
int output_index() const override
Definition: selector_impl.h:58
output[output_index][i] = input[input_index][i]
Definition: selector.h:40
Definition: ax100_decode.h:17