GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
gnss_sdr_valve.h
Go to the documentation of this file.
1 /*!
2  * \file gnss_sdr_valve.h
3  * \brief Interface of a GNU Radio block that sends a STOP message to the
4  * control queue right after a specific number of samples have passed through it.
5  * \author Javier Arribas, 2018. jarribas(at)cttc.es
6  * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
7  *
8  * -----------------------------------------------------------------------------
9  *
10  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
11  *
12  * GNSS-SDR is a software defined Global Navigation
13  * Satellite Systems receiver
14  *
15  * This file is part of GNSS-SDR.
16  *
17  * SPDX-License-Identifier: GPL-3.0-or-later
18  *
19  * -----------------------------------------------------------------------------
20  */
21 
22 
23 #ifndef GNSS_SDR_GNSS_SDR_VALVE_H
24 #define GNSS_SDR_GNSS_SDR_VALVE_H
25 
26 #include "concurrent_queue.h"
27 #include <gnuradio/sync_block.h> // for sync_block
28 #include <gnuradio/types.h> // for gr_vector_const_void_star
29 #include <pmt/pmt.h>
30 #include <cstddef> // for size_t
31 #include <cstdint>
32 #if GNURADIO_USES_STD_POINTERS
33 #include <memory>
34 #else
35 #include <boost/shared_ptr.hpp>
36 #endif
37 
38 class Gnss_Sdr_Valve;
39 
40 #if GNURADIO_USES_STD_POINTERS
41 std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
42  size_t sizeof_stream_item,
43  uint64_t nitems,
45 
46 std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
47  size_t sizeof_stream_item,
48  uint64_t nitems,
50  bool stop_flowgraph);
51 #else
52 boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
53  size_t sizeof_stream_item,
54  uint64_t nitems,
56 
57 boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
58  size_t sizeof_stream_item,
59  uint64_t nitems,
61  bool stop_flowgraph);
62 #endif
63 
64 /*!
65  * \brief Implementation of a GNU Radio block that sends a STOP message to the
66  * control queue right after a specific number of samples have passed through it.
67  */
68 class Gnss_Sdr_Valve : public gr::sync_block
69 {
70 public:
71  void open_valve();
72 
73  int work(int noutput_items,
74  gr_vector_const_void_star& input_items,
75  gr_vector_void_star& output_items);
76 
77 private:
78 #if GNURADIO_USES_STD_POINTERS
79  friend std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
80  size_t sizeof_stream_item,
81  uint64_t nitems,
83 
84  friend std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
85  size_t sizeof_stream_item,
86  uint64_t nitems,
88  bool stop_flowgraph);
89 #else
90  friend boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
91  size_t sizeof_stream_item,
92  uint64_t nitems,
94 
95  friend boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
96  size_t sizeof_stream_item,
97  uint64_t nitems,
99  bool stop_flowgraph);
100 #endif
101  Gnss_Sdr_Valve(size_t sizeof_stream_item,
102  uint64_t nitems,
103  Concurrent_Queue<pmt::pmt_t>* queue, bool stop_flowgraph);
104 
105  uint64_t d_nitems;
106  uint64_t d_ncopied_items;
108  bool d_stop_flowgraph;
109  bool d_open_valve;
110 };
111 
112 #endif // GNSS_SDR_GNSS_SDR_VALVE_H
Interface of a thread-safe std::queue.
Implementation of a GNU Radio block that sends a STOP message to the control queue right after a spec...