mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-03-28 14:27:03 +00:00
Improve memory management
The blocks are now always managed by smart pointers instead of raw pointers
This commit is contained in:
parent
d24ea0e916
commit
fbfc4a28ba
@ -43,11 +43,10 @@ using google::LogMessage;
|
||||
|
||||
// Constructor
|
||||
Channel::Channel(ConfigurationInterface *configuration, unsigned int channel,
|
||||
GNSSBlockInterface *pass_through, AcquisitionInterface *acq,
|
||||
TrackingInterface *trk, TelemetryDecoderInterface *nav,
|
||||
std::shared_ptr<GNSSBlockInterface> pass_through, std::shared_ptr<AcquisitionInterface> acq,
|
||||
std::shared_ptr<TrackingInterface> trk, std::shared_ptr<TelemetryDecoderInterface> nav,
|
||||
std::string role, std::string implementation, boost::shared_ptr<gr::msg_queue> queue)
|
||||
{
|
||||
|
||||
pass_through_ = pass_through;
|
||||
acq_ = acq;
|
||||
trk_ = trk;
|
||||
@ -187,3 +186,4 @@ void Channel::start_acquisition()
|
||||
{
|
||||
channel_fsm_.Event_start_acquisition();
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,8 @@ class Channel: public ChannelInterface
|
||||
public:
|
||||
//! Constructor
|
||||
Channel(ConfigurationInterface *configuration, unsigned int channel,
|
||||
GNSSBlockInterface *pass_through, AcquisitionInterface *acq,
|
||||
TrackingInterface *trk, TelemetryDecoderInterface *nav,
|
||||
std::shared_ptr<GNSSBlockInterface> pass_through, std::shared_ptr<AcquisitionInterface> acq,
|
||||
std::shared_ptr<TrackingInterface> trk, std::shared_ptr<TelemetryDecoderInterface> nav,
|
||||
std::string role, std::string implementation,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
//! Virtual destructor
|
||||
@ -77,9 +77,9 @@ public:
|
||||
std::string implementation(){ return implementation_; }
|
||||
size_t item_size(){ return 0; }
|
||||
Gnss_Signal get_signal() const { return gnss_signal_; }
|
||||
AcquisitionInterface* acquisition(){ return acq_; }
|
||||
TrackingInterface* tracking(){ return trk_; }
|
||||
TelemetryDecoderInterface* telemetry(){ return nav_; }
|
||||
std::shared_ptr<AcquisitionInterface> acquisition(){ return acq_; }
|
||||
std::shared_ptr<TrackingInterface> tracking(){ return trk_; }
|
||||
std::shared_ptr<TelemetryDecoderInterface> telemetry(){ return nav_; }
|
||||
void start_acquisition(); //!< Start the State Machine
|
||||
void set_signal(const Gnss_Signal& gnss_signal_); //!< Sets the channel GNSS signal
|
||||
|
||||
@ -88,10 +88,10 @@ public:
|
||||
|
||||
private:
|
||||
channel_msg_receiver_cc_sptr channel_msg_rx;
|
||||
GNSSBlockInterface *pass_through_;
|
||||
AcquisitionInterface *acq_;
|
||||
TrackingInterface *trk_;
|
||||
TelemetryDecoderInterface *nav_;
|
||||
std::shared_ptr<GNSSBlockInterface> pass_through_;
|
||||
std::shared_ptr<AcquisitionInterface> acq_;
|
||||
std::shared_ptr<TrackingInterface> trk_;
|
||||
std::shared_ptr<TelemetryDecoderInterface> nav_;
|
||||
std::string role_;
|
||||
std::string implementation_;
|
||||
unsigned int channel_;
|
||||
|
@ -136,7 +136,7 @@ ChannelFsm::ChannelFsm()
|
||||
|
||||
|
||||
|
||||
ChannelFsm::ChannelFsm(AcquisitionInterface *acquisition) :
|
||||
ChannelFsm::ChannelFsm(std::shared_ptr<AcquisitionInterface> acquisition) :
|
||||
acq_(acquisition)
|
||||
{
|
||||
trk_ = nullptr;
|
||||
@ -180,12 +180,12 @@ void ChannelFsm::Event_failed_tracking_standby()
|
||||
// this->process_event(Ev_channel_failed_tracking_reacq());
|
||||
//}
|
||||
|
||||
void ChannelFsm::set_acquisition(AcquisitionInterface *acquisition)
|
||||
void ChannelFsm::set_acquisition(std::shared_ptr<AcquisitionInterface> acquisition)
|
||||
{
|
||||
acq_ = acquisition;
|
||||
}
|
||||
|
||||
void ChannelFsm::set_tracking(TrackingInterface *tracking)
|
||||
void ChannelFsm::set_tracking(std::shared_ptr<TrackingInterface> tracking)
|
||||
{
|
||||
trk_ = tracking;
|
||||
}
|
||||
|
@ -55,10 +55,10 @@ class ChannelFsm: public sc::state_machine<ChannelFsm, channel_idle_fsm_S0>
|
||||
{
|
||||
public:
|
||||
ChannelFsm();
|
||||
ChannelFsm(AcquisitionInterface *acquisition);
|
||||
ChannelFsm(std::shared_ptr<AcquisitionInterface> acquisition);
|
||||
|
||||
void set_acquisition(AcquisitionInterface *acquisition);
|
||||
void set_tracking(TrackingInterface *tracking);
|
||||
void set_acquisition(std::shared_ptr<AcquisitionInterface> acquisition);
|
||||
void set_tracking(std::shared_ptr<TrackingInterface> tracking);
|
||||
void set_queue(boost::shared_ptr<gr::msg_queue> queue);
|
||||
void set_channel(unsigned int channel);
|
||||
void start_acquisition();
|
||||
@ -75,8 +75,8 @@ public:
|
||||
void Event_failed_tracking_standby();
|
||||
|
||||
private:
|
||||
AcquisitionInterface *acq_;
|
||||
TrackingInterface *trk_;
|
||||
std::shared_ptr<AcquisitionInterface> acq_;
|
||||
std::shared_ptr<TrackingInterface> trk_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
unsigned int channel_;
|
||||
};
|
||||
|
@ -37,8 +37,8 @@ using google::LogMessage;
|
||||
|
||||
// Constructor
|
||||
ArraySignalConditioner::ArraySignalConditioner(ConfigurationInterface *configuration,
|
||||
GNSSBlockInterface *data_type_adapt, GNSSBlockInterface *in_filt,
|
||||
GNSSBlockInterface *res, std::string role, std::string implementation,
|
||||
std::shared_ptr<GNSSBlockInterface> data_type_adapt, std::shared_ptr<GNSSBlockInterface> in_filt,
|
||||
std::shared_ptr<GNSSBlockInterface> res, std::string role, std::string implementation,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : data_type_adapt_(data_type_adapt),
|
||||
in_filt_(in_filt), res_(res), role_(role), implementation_(implementation),
|
||||
queue_(queue)
|
||||
@ -50,17 +50,12 @@ ArraySignalConditioner::ArraySignalConditioner(ConfigurationInterface *configura
|
||||
|
||||
// Destructor
|
||||
ArraySignalConditioner::~ArraySignalConditioner()
|
||||
{
|
||||
delete data_type_adapt_;
|
||||
delete in_filt_;
|
||||
delete res_;
|
||||
}
|
||||
|
||||
{}
|
||||
|
||||
|
||||
void ArraySignalConditioner::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
// note: the array signal conditioner do not have data type adapter, and must use the array input filter (multichannel)
|
||||
// note: the array signal conditioner do not have data type adapter, and must use the array input filter (multichannel)
|
||||
if (connected_)
|
||||
{
|
||||
LOG(WARNING) << "Array Signal conditioner already connected internally";
|
||||
@ -70,7 +65,6 @@ void ArraySignalConditioner::connect(gr::top_block_sptr top_block)
|
||||
in_filt_->connect(top_block);
|
||||
res_->connect(top_block);
|
||||
|
||||
|
||||
//top_block->connect(data_type_adapt_->get_right_block(), 0, in_filt_->get_left_block(), 0);
|
||||
//DLOG(INFO) << "data_type_adapter -> input_filter";
|
||||
|
||||
|
@ -52,8 +52,8 @@ class ArraySignalConditioner: public GNSSBlockInterface
|
||||
public:
|
||||
//! Constructor
|
||||
ArraySignalConditioner(ConfigurationInterface *configuration,
|
||||
GNSSBlockInterface *data_type_adapt, GNSSBlockInterface *in_filt,
|
||||
GNSSBlockInterface *res, std::string role, std::string implementation,
|
||||
std::shared_ptr<GNSSBlockInterface> data_type_adapt, std::shared_ptr<GNSSBlockInterface> in_filt,
|
||||
std::shared_ptr<GNSSBlockInterface> res, std::string role, std::string implementation,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
//! Virtual destructor
|
||||
@ -69,14 +69,14 @@ public:
|
||||
std::string implementation(){ return "Array_Signal_Conditioner"; }
|
||||
size_t item_size(){ return 0; }
|
||||
|
||||
GNSSBlockInterface *data_type_adapter(){ return data_type_adapt_; }
|
||||
GNSSBlockInterface *input_filter(){ return in_filt_; }
|
||||
GNSSBlockInterface *resampler(){ return res_; }
|
||||
std::shared_ptr<GNSSBlockInterface> data_type_adapter(){ return data_type_adapt_; }
|
||||
std::shared_ptr<GNSSBlockInterface> input_filter(){ return in_filt_; }
|
||||
std::shared_ptr<GNSSBlockInterface> resampler(){ return res_; }
|
||||
|
||||
private:
|
||||
GNSSBlockInterface *data_type_adapt_;
|
||||
GNSSBlockInterface *in_filt_;
|
||||
GNSSBlockInterface *res_;
|
||||
std::shared_ptr<GNSSBlockInterface> data_type_adapt_;
|
||||
std::shared_ptr<GNSSBlockInterface> in_filt_;
|
||||
std::shared_ptr<GNSSBlockInterface> res_;
|
||||
std::string role_;
|
||||
std::string implementation_;
|
||||
bool connected_;
|
||||
|
@ -37,8 +37,8 @@ using google::LogMessage;
|
||||
|
||||
// Constructor
|
||||
SignalConditioner::SignalConditioner(ConfigurationInterface *configuration,
|
||||
GNSSBlockInterface *data_type_adapt, GNSSBlockInterface *in_filt,
|
||||
GNSSBlockInterface *res, std::string role, std::string implementation,
|
||||
std::shared_ptr<GNSSBlockInterface> data_type_adapt, std::shared_ptr<GNSSBlockInterface> in_filt,
|
||||
std::shared_ptr<GNSSBlockInterface> res, std::string role, std::string implementation,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : data_type_adapt_(data_type_adapt),
|
||||
in_filt_(in_filt), res_(res), role_(role), implementation_(implementation),
|
||||
queue_(queue)
|
||||
@ -50,11 +50,7 @@ SignalConditioner::SignalConditioner(ConfigurationInterface *configuration,
|
||||
|
||||
// Destructor
|
||||
SignalConditioner::~SignalConditioner()
|
||||
{
|
||||
delete data_type_adapt_;
|
||||
delete in_filt_;
|
||||
delete res_;
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void SignalConditioner::connect(gr::top_block_sptr top_block)
|
||||
|
@ -51,8 +51,8 @@ class SignalConditioner: public GNSSBlockInterface
|
||||
public:
|
||||
//! Constructor
|
||||
SignalConditioner(ConfigurationInterface *configuration,
|
||||
GNSSBlockInterface *data_type_adapt, GNSSBlockInterface *in_filt,
|
||||
GNSSBlockInterface *res, std::string role, std::string implementation,
|
||||
std::shared_ptr<GNSSBlockInterface> data_type_adapt, std::shared_ptr<GNSSBlockInterface> in_filt,
|
||||
std::shared_ptr<GNSSBlockInterface> res, std::string role, std::string implementation,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
//! Virtual destructor
|
||||
@ -68,14 +68,14 @@ public:
|
||||
std::string implementation(){ return "Signal_Conditioner"; }
|
||||
size_t item_size(){ return 0; }
|
||||
|
||||
GNSSBlockInterface *data_type_adapter(){ return data_type_adapt_; }
|
||||
GNSSBlockInterface *input_filter(){ return in_filt_; }
|
||||
GNSSBlockInterface *resampler(){ return res_; }
|
||||
std::shared_ptr<GNSSBlockInterface> data_type_adapter(){ return data_type_adapt_; }
|
||||
std::shared_ptr<GNSSBlockInterface> input_filter(){ return in_filt_; }
|
||||
std::shared_ptr<GNSSBlockInterface> resampler(){ return res_; }
|
||||
|
||||
private:
|
||||
GNSSBlockInterface *data_type_adapt_;
|
||||
GNSSBlockInterface *in_filt_;
|
||||
GNSSBlockInterface *res_;
|
||||
std::shared_ptr<GNSSBlockInterface> data_type_adapt_;
|
||||
std::shared_ptr<GNSSBlockInterface> in_filt_;
|
||||
std::shared_ptr<GNSSBlockInterface> res_;
|
||||
std::string role_;
|
||||
std::string implementation_;
|
||||
bool connected_;
|
||||
|
@ -199,21 +199,21 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalConditioner(
|
||||
if(signal_conditioner.compare("Array_Signal_Conditioner") == 0)
|
||||
{
|
||||
//instantiate the array version
|
||||
std::unique_ptr<GNSSBlockInterface> conditioner_(new ArraySignalConditioner(configuration.get(), GetBlock(configuration,
|
||||
role_datatypeadapter, data_type_adapter, 1, 1, queue).release(), GetBlock(
|
||||
configuration,role_inputfilter, input_filter, 1, 1, queue).release(),
|
||||
GetBlock(configuration,role_resampler, resampler, 1, 1, queue).release(),
|
||||
role_conditioner, "Signal_Conditioner", queue));
|
||||
std::unique_ptr<GNSSBlockInterface> conditioner_(new ArraySignalConditioner(configuration.get(),
|
||||
std::move(GetBlock(configuration, role_datatypeadapter, data_type_adapter, 1, 1, queue)),
|
||||
std::move(GetBlock(configuration, role_inputfilter, input_filter, 1, 1, queue)),
|
||||
std::move(GetBlock(configuration, role_resampler, resampler, 1, 1, queue)),
|
||||
role_conditioner, "Signal_Conditioner", queue));
|
||||
return conditioner_;
|
||||
}
|
||||
else
|
||||
{
|
||||
//single-antenna version
|
||||
std::unique_ptr<GNSSBlockInterface> conditioner_(new SignalConditioner(configuration.get(), GetBlock(configuration,
|
||||
role_datatypeadapter, data_type_adapter, 1, 1, queue).release(), GetBlock(
|
||||
configuration,role_inputfilter, input_filter, 1, 1, queue).release(),
|
||||
GetBlock(configuration,role_resampler, resampler, 1, 1, queue).release(),
|
||||
role_conditioner, "Signal_Conditioner", queue));
|
||||
std::unique_ptr<GNSSBlockInterface> conditioner_(new SignalConditioner(configuration.get(),
|
||||
std::move(GetBlock(configuration, role_datatypeadapter, data_type_adapter, 1, 1, queue)),
|
||||
std::move(GetBlock(configuration, role_inputfilter, input_filter, 1, 1, queue)),
|
||||
std::move(GetBlock(configuration, role_resampler, resampler, 1, 1, queue)),
|
||||
role_conditioner, "Signal_Conditioner", queue));
|
||||
return conditioner_;
|
||||
}
|
||||
}
|
||||
@ -296,10 +296,10 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetChannel_1C(
|
||||
std::unique_ptr<TrackingInterface> trk_ = GetTrkBlock(configuration, "Tracking_1C"+ appendix2, trk, 1, 1, queue);
|
||||
std::unique_ptr<TelemetryDecoderInterface> tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_1C" + appendix3, tlm, 1, 1);
|
||||
|
||||
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, pass_through_.release(),
|
||||
acq_.release(),
|
||||
trk_.release(),
|
||||
tlm_.release(),
|
||||
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, std::move(pass_through_),
|
||||
std::move(acq_),
|
||||
std::move(trk_),
|
||||
std::move(tlm_),
|
||||
"Channel", "1C", queue));
|
||||
|
||||
return channel_;
|
||||
@ -351,10 +351,10 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetChannel_2S(
|
||||
|
||||
std::unique_ptr<TelemetryDecoderInterface> tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_2S" + appendix3, tlm, 1, 1);
|
||||
|
||||
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, pass_through_.release(),
|
||||
acq_.release(),
|
||||
trk_.release(),
|
||||
tlm_.release(),
|
||||
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, std::move(pass_through_),
|
||||
std::move(acq_),
|
||||
std::move(trk_),
|
||||
std::move(tlm_),
|
||||
"Channel", "2S", queue));
|
||||
|
||||
return channel_;
|
||||
@ -407,10 +407,10 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetChannel_1B(
|
||||
std::unique_ptr<TrackingInterface> trk_ = GetTrkBlock(configuration, "Tracking_1B" + appendix2, trk, 1, 1, queue);
|
||||
std::unique_ptr<TelemetryDecoderInterface> tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_1B" + appendix3, tlm, 1, 1);
|
||||
|
||||
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, pass_through_.release(),
|
||||
acq_.release(),
|
||||
trk_.release(),
|
||||
tlm_.release(),
|
||||
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, std::move(pass_through_),
|
||||
std::move(acq_),
|
||||
std::move(trk_),
|
||||
std::move(tlm_),
|
||||
"Channel", "1B", queue));
|
||||
|
||||
return channel_;
|
||||
@ -463,10 +463,10 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetChannel_5X(
|
||||
std::unique_ptr<TrackingInterface> trk_ = GetTrkBlock(configuration, "Tracking_5X" + appendix2, trk, 1, 1, queue);
|
||||
std::unique_ptr<TelemetryDecoderInterface> tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_5X" + appendix3, tlm, 1, 1);
|
||||
|
||||
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, pass_through_.release(),
|
||||
acq_.release(),
|
||||
trk_.release(),
|
||||
tlm_.release(),
|
||||
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, std::move(pass_through_),
|
||||
std::move(acq_),
|
||||
std::move(trk_),
|
||||
std::move(tlm_),
|
||||
"Channel", "5X", queue));
|
||||
|
||||
return channel_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user