diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 0495d8902..df6597cd2 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -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 pass_through, std::shared_ptr acq, + std::shared_ptr trk, std::shared_ptr nav, std::string role, std::string implementation, boost::shared_ptr queue) { - pass_through_ = pass_through; acq_ = acq; trk_ = trk; @@ -187,3 +186,4 @@ void Channel::start_acquisition() { channel_fsm_.Event_start_acquisition(); } + diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index 664b5ef02..0d2a30431 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -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 pass_through, std::shared_ptr acq, + std::shared_ptr trk, std::shared_ptr nav, std::string role, std::string implementation, boost::shared_ptr 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 acquisition(){ return acq_; } + std::shared_ptr tracking(){ return trk_; } + std::shared_ptr 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 pass_through_; + std::shared_ptr acq_; + std::shared_ptr trk_; + std::shared_ptr nav_; std::string role_; std::string implementation_; unsigned int channel_; diff --git a/src/algorithms/channel/libs/channel_fsm.cc b/src/algorithms/channel/libs/channel_fsm.cc index be55bbf28..b8698d0da 100644 --- a/src/algorithms/channel/libs/channel_fsm.cc +++ b/src/algorithms/channel/libs/channel_fsm.cc @@ -136,7 +136,7 @@ ChannelFsm::ChannelFsm() -ChannelFsm::ChannelFsm(AcquisitionInterface *acquisition) : +ChannelFsm::ChannelFsm(std::shared_ptr 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 acquisition) { acq_ = acquisition; } -void ChannelFsm::set_tracking(TrackingInterface *tracking) +void ChannelFsm::set_tracking(std::shared_ptr tracking) { trk_ = tracking; } diff --git a/src/algorithms/channel/libs/channel_fsm.h b/src/algorithms/channel/libs/channel_fsm.h index 6fa2a6d41..868388b7b 100644 --- a/src/algorithms/channel/libs/channel_fsm.h +++ b/src/algorithms/channel/libs/channel_fsm.h @@ -55,10 +55,10 @@ class ChannelFsm: public sc::state_machine { public: ChannelFsm(); - ChannelFsm(AcquisitionInterface *acquisition); + ChannelFsm(std::shared_ptr acquisition); - void set_acquisition(AcquisitionInterface *acquisition); - void set_tracking(TrackingInterface *tracking); + void set_acquisition(std::shared_ptr acquisition); + void set_tracking(std::shared_ptr tracking); void set_queue(boost::shared_ptr 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 acq_; + std::shared_ptr trk_; boost::shared_ptr queue_; unsigned int channel_; }; diff --git a/src/algorithms/conditioner/adapters/array_signal_conditioner.cc b/src/algorithms/conditioner/adapters/array_signal_conditioner.cc index 5a826da12..d40adeb39 100644 --- a/src/algorithms/conditioner/adapters/array_signal_conditioner.cc +++ b/src/algorithms/conditioner/adapters/array_signal_conditioner.cc @@ -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 data_type_adapt, std::shared_ptr in_filt, + std::shared_ptr res, std::string role, std::string implementation, boost::shared_ptr 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"; diff --git a/src/algorithms/conditioner/adapters/array_signal_conditioner.h b/src/algorithms/conditioner/adapters/array_signal_conditioner.h index 3dbb59b1c..1a635dabd 100644 --- a/src/algorithms/conditioner/adapters/array_signal_conditioner.h +++ b/src/algorithms/conditioner/adapters/array_signal_conditioner.h @@ -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 data_type_adapt, std::shared_ptr in_filt, + std::shared_ptr res, std::string role, std::string implementation, boost::shared_ptr 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 data_type_adapter(){ return data_type_adapt_; } + std::shared_ptr input_filter(){ return in_filt_; } + std::shared_ptr resampler(){ return res_; } private: - GNSSBlockInterface *data_type_adapt_; - GNSSBlockInterface *in_filt_; - GNSSBlockInterface *res_; + std::shared_ptr data_type_adapt_; + std::shared_ptr in_filt_; + std::shared_ptr res_; std::string role_; std::string implementation_; bool connected_; diff --git a/src/algorithms/conditioner/adapters/signal_conditioner.cc b/src/algorithms/conditioner/adapters/signal_conditioner.cc index 3a57e38bb..42feb8f40 100644 --- a/src/algorithms/conditioner/adapters/signal_conditioner.cc +++ b/src/algorithms/conditioner/adapters/signal_conditioner.cc @@ -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 data_type_adapt, std::shared_ptr in_filt, + std::shared_ptr res, std::string role, std::string implementation, boost::shared_ptr 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) diff --git a/src/algorithms/conditioner/adapters/signal_conditioner.h b/src/algorithms/conditioner/adapters/signal_conditioner.h index 41201a4a1..ef46a6491 100644 --- a/src/algorithms/conditioner/adapters/signal_conditioner.h +++ b/src/algorithms/conditioner/adapters/signal_conditioner.h @@ -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 data_type_adapt, std::shared_ptr in_filt, + std::shared_ptr res, std::string role, std::string implementation, boost::shared_ptr 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 data_type_adapter(){ return data_type_adapt_; } + std::shared_ptr input_filter(){ return in_filt_; } + std::shared_ptr resampler(){ return res_; } private: - GNSSBlockInterface *data_type_adapt_; - GNSSBlockInterface *in_filt_; - GNSSBlockInterface *res_; + std::shared_ptr data_type_adapt_; + std::shared_ptr in_filt_; + std::shared_ptr res_; std::string role_; std::string implementation_; bool connected_; diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index f7a17f346..d337d4059 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -199,21 +199,21 @@ std::unique_ptr GNSSBlockFactory::GetSignalConditioner( if(signal_conditioner.compare("Array_Signal_Conditioner") == 0) { //instantiate the array version - std::unique_ptr 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 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 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 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 GNSSBlockFactory::GetChannel_1C( std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_1C"+ appendix2, trk, 1, 1, queue); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_1C" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, pass_through_.release(), - acq_.release(), - trk_.release(), - tlm_.release(), + std::unique_ptr 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 GNSSBlockFactory::GetChannel_2S( std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_2S" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, pass_through_.release(), - acq_.release(), - trk_.release(), - tlm_.release(), + std::unique_ptr 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 GNSSBlockFactory::GetChannel_1B( std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_1B" + appendix2, trk, 1, 1, queue); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_1B" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, pass_through_.release(), - acq_.release(), - trk_.release(), - tlm_.release(), + std::unique_ptr 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 GNSSBlockFactory::GetChannel_5X( std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_5X" + appendix2, trk, 1, 1, queue); std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_5X" + appendix3, tlm, 1, 1); - std::unique_ptr channel_(new Channel(configuration.get(), channel, pass_through_.release(), - acq_.release(), - trk_.release(), - tlm_.release(), + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::move(acq_), + std::move(trk_), + std::move(tlm_), "Channel", "5X", queue)); return channel_;