mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-13 13:47:15 +00:00
Redesign of pointer management
Avoid indirection caused by passing shared_ptr by reference The block factory does not have responsability on the lifetime of their inputs Define std::make_unique when using C++11 and make use of it Printers are turned into unique_ptr to express ownership Printers do not participate on the lifelime of the data, so they take const raw pointers Modernize tests code
This commit is contained in:
@@ -180,8 +180,8 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
|
||||
bool quadrature_,
|
||||
bool rfdc_,
|
||||
bool bbdc_,
|
||||
std::string filter_source_,
|
||||
std::string filter_filename_,
|
||||
std::string filter_source_, // NOLINT(performance-unnecessary-value-param)
|
||||
std::string filter_filename_, // NOLINT(performance-unnecessary-value-param)
|
||||
float Fpass_,
|
||||
float Fstop_)
|
||||
|
||||
|
||||
@@ -31,42 +31,43 @@
|
||||
|
||||
Gnss_Sdr_Valve::Gnss_Sdr_Valve(size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue,
|
||||
Concurrent_Queue<pmt::pmt_t>* queue,
|
||||
bool stop_flowgraph) : gr::sync_block("valve",
|
||||
gr::io_signature::make(1, 20, sizeof_stream_item),
|
||||
gr::io_signature::make(1, 20, sizeof_stream_item)),
|
||||
d_nitems(nitems),
|
||||
d_ncopied_items(0),
|
||||
d_queue(std::move(queue)),
|
||||
d_queue(queue),
|
||||
d_stop_flowgraph(stop_flowgraph)
|
||||
{
|
||||
d_open_valve = false;
|
||||
}
|
||||
|
||||
|
||||
#if GNURADIO_USES_STD_POINTERS
|
||||
std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue, bool stop_flowgraph)
|
||||
std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, Concurrent_Queue<pmt::pmt_t>* queue, bool stop_flowgraph)
|
||||
{
|
||||
std::shared_ptr<Gnss_Sdr_Valve> valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, std::move(queue), stop_flowgraph));
|
||||
std::shared_ptr<Gnss_Sdr_Valve> valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, queue, stop_flowgraph));
|
||||
return valve_;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue)
|
||||
std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, Concurrent_Queue<pmt::pmt_t>* queue)
|
||||
{
|
||||
std::shared_ptr<Gnss_Sdr_Valve> valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, std::move(queue), true));
|
||||
std::shared_ptr<Gnss_Sdr_Valve> valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, queue, true));
|
||||
return valve_;
|
||||
}
|
||||
#else
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue, bool stop_flowgraph)
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, Concurrent_Queue<pmt::pmt_t>* queue, bool stop_flowgraph)
|
||||
{
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, std::move(queue), stop_flowgraph));
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, queue, stop_flowgraph));
|
||||
return valve_;
|
||||
}
|
||||
|
||||
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue)
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, Concurrent_Queue<pmt::pmt_t>* queue)
|
||||
{
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, std::move(queue), true));
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> valve_(new Gnss_Sdr_Valve(sizeof_stream_item, nitems, queue, true));
|
||||
return valve_;
|
||||
}
|
||||
#endif
|
||||
@@ -79,8 +80,8 @@ void Gnss_Sdr_Valve::open_valve()
|
||||
|
||||
|
||||
int Gnss_Sdr_Valve::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
gr_vector_const_void_star& input_items,
|
||||
gr_vector_void_star& output_items)
|
||||
{
|
||||
if (d_open_valve == false)
|
||||
{
|
||||
|
||||
@@ -41,23 +41,23 @@ class Gnss_Sdr_Valve;
|
||||
std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
|
||||
size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue);
|
||||
Concurrent_Queue<pmt::pmt_t>* queue);
|
||||
|
||||
std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
|
||||
size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue,
|
||||
Concurrent_Queue<pmt::pmt_t>* queue,
|
||||
bool stop_flowgraph);
|
||||
#else
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
|
||||
size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue);
|
||||
Concurrent_Queue<pmt::pmt_t>* queue);
|
||||
|
||||
boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
|
||||
size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue,
|
||||
Concurrent_Queue<pmt::pmt_t>* queue,
|
||||
bool stop_flowgraph);
|
||||
#endif
|
||||
|
||||
@@ -71,40 +71,40 @@ public:
|
||||
void open_valve();
|
||||
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
gr_vector_const_void_star& input_items,
|
||||
gr_vector_void_star& output_items);
|
||||
|
||||
private:
|
||||
#if GNURADIO_USES_STD_POINTERS
|
||||
friend std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
|
||||
size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue);
|
||||
Concurrent_Queue<pmt::pmt_t>* queue);
|
||||
|
||||
friend std::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
|
||||
size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue,
|
||||
Concurrent_Queue<pmt::pmt_t>* queue,
|
||||
bool stop_flowgraph);
|
||||
#else
|
||||
friend boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
|
||||
size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue);
|
||||
Concurrent_Queue<pmt::pmt_t>* queue);
|
||||
|
||||
friend boost::shared_ptr<Gnss_Sdr_Valve> gnss_sdr_make_valve(
|
||||
size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue,
|
||||
Concurrent_Queue<pmt::pmt_t>* queue,
|
||||
bool stop_flowgraph);
|
||||
#endif
|
||||
Gnss_Sdr_Valve(size_t sizeof_stream_item,
|
||||
uint64_t nitems,
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue, bool stop_flowgraph);
|
||||
Concurrent_Queue<pmt::pmt_t>* queue, bool stop_flowgraph);
|
||||
|
||||
uint64_t d_nitems;
|
||||
uint64_t d_ncopied_items;
|
||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> d_queue;
|
||||
Concurrent_Queue<pmt::pmt_t>* d_queue;
|
||||
bool d_stop_flowgraph;
|
||||
bool d_open_valve;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user