1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-10-31 23:26:22 +00:00

Improve copy and move constructors

This commit is contained in:
Carles Fernandez 2023-03-25 18:11:29 +01:00
parent c3c1098790
commit 090017dfaa
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
4 changed files with 25 additions and 49 deletions

View File

@ -73,16 +73,16 @@ bool operator==(const Gnss_Satellite& sat1, const Gnss_Satellite& sat2)
// Copy constructor
Gnss_Satellite::Gnss_Satellite(const Gnss_Satellite& other) noexcept
: system(other.system),
block(other.block),
PRN(other.PRN),
rf_link(other.rf_link)
{
system = other.system;
block = other.block;
PRN = other.PRN;
rf_link = other.rf_link;
}
// Copy assignment operator
Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs)
Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs) noexcept
{
// Only do assignment if RHS is a different object from this.
if (this != &rhs)
@ -98,11 +98,11 @@ Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs)
// Move constructor
Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other) noexcept
: system(std::move(other.system)),
block(std::move(other.block)),
PRN(other.PRN),
rf_link(other.rf_link)
{
system = std::move(other.system);
block = std::move(other.block);
PRN = other.PRN;
rf_link = other.rf_link;
other.reset();
}

View File

@ -44,7 +44,7 @@ public:
~Gnss_Satellite() = default; //!< Default Destructor.
Gnss_Satellite(const Gnss_Satellite& other) noexcept; //!< Copy constructor
Gnss_Satellite& operator=(const Gnss_Satellite&); //!< Copy assignment operator
Gnss_Satellite& operator=(const Gnss_Satellite&) noexcept; //!< Copy assignment operator
Gnss_Satellite(Gnss_Satellite&& other) noexcept; //!< Move constructor
Gnss_Satellite& operator=(Gnss_Satellite&& other) noexcept; //!< Move assignment operator

View File

@ -221,30 +221,6 @@ Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename,
}
}
// Copy constructor
Acquisition_Dump_Reader::Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept
: doppler(other.doppler),
samples(other.samples),
mag(other.mag),
acq_doppler_hz(other.acq_doppler_hz),
acq_delay_samples(other.acq_delay_samples),
test_statistic(other.test_statistic),
input_power(other.input_power),
threshold(other.threshold),
positive_acq(other.positive_acq),
PRN(other.PRN),
num_dwells(other.num_dwells),
sample_counter(other.sample_counter),
d_basename(other.d_basename),
d_dump_filename(other.d_dump_filename),
d_sat(other.d_sat),
d_doppler_max(other.d_doppler_max),
d_doppler_step(other.d_doppler_step),
d_samples_per_code(other.d_samples_per_code),
d_num_doppler_bins(other.d_num_doppler_bins)
{
}
// Copy assignment operator
Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(const Acquisition_Dump_Reader& other) noexcept
@ -308,23 +284,23 @@ Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(Acquisition_Dump_Rea
// Move member variables from the other object to this object
d_basename = std::move(other.d_basename);
d_dump_filename = std::move(other.d_dump_filename);
d_sat = std::move(other.d_sat);
d_doppler_max = std::move(other.d_doppler_max);
d_doppler_step = std::move(other.d_doppler_step);
d_samples_per_code = std::move(other.d_samples_per_code);
d_num_doppler_bins = std::move(other.d_num_doppler_bins);
d_sat = other.d_sat;
d_doppler_max = other.d_doppler_max;
d_doppler_step = other.d_doppler_step;
d_samples_per_code = other.d_samples_per_code;
d_num_doppler_bins = other.d_num_doppler_bins;
doppler = std::move(other.doppler);
samples = std::move(other.samples);
mag = std::move(other.mag);
acq_doppler_hz = std::move(other.acq_doppler_hz);
acq_delay_samples = std::move(other.acq_delay_samples);
test_statistic = std::move(other.test_statistic);
input_power = std::move(other.input_power);
threshold = std::move(other.threshold);
positive_acq = std::move(other.positive_acq);
PRN = std::move(other.PRN);
num_dwells = std::move(other.num_dwells);
sample_counter = std::move(other.sample_counter);
acq_doppler_hz = other.acq_doppler_hz;
acq_delay_samples = other.acq_delay_samples;
test_statistic = other.test_statistic;
input_power = other.input_power;
threshold = other.threshold;
positive_acq = other.positive_acq;
PRN = other.PRN;
num_dwells = other.num_dwells;
sample_counter = other.sample_counter;
}
return *this;
}

View File

@ -37,7 +37,7 @@ public:
int channel = 0,
int execution = 1);
Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept; //!< Copy constructor
Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept = default; //!< Copy constructor
Acquisition_Dump_Reader& operator=(const Acquisition_Dump_Reader& other) noexcept; //!< Copy assignment operator
Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept; //!< Move constructor
Acquisition_Dump_Reader& operator=(Acquisition_Dump_Reader&& other) noexcept; //!< Move assignment operator