1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-06 10:13:04 +00:00

Improve memory management

The blocks are now always managed by smart pointers instead of raw pointers
This commit is contained in:
Carles Fernandez
2016-05-02 17:26:32 +02:00
parent d24ea0e916
commit fbfc4a28ba
9 changed files with 69 additions and 79 deletions

View File

@@ -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";

View File

@@ -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_;

View File

@@ -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)

View File

@@ -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_;