mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 04:30:33 +00:00
Add copy constructor, copy assignment operator, move constructor and move assignment operator
This commit is contained in:
parent
620191f818
commit
52c08e3ab4
@ -88,30 +88,61 @@ bool operator==(const Gnss_Satellite& sat1, const Gnss_Satellite& sat2)
|
|||||||
if (sat1.get_system() == sat2.get_system())
|
if (sat1.get_system() == sat2.get_system())
|
||||||
{
|
{
|
||||||
if (sat1.get_PRN() == sat2.get_PRN())
|
if (sat1.get_PRN() == sat2.get_PRN())
|
||||||
|
{
|
||||||
|
if (sat1.get_rf_link() == sat2.get_rf_link())
|
||||||
{
|
{
|
||||||
equal = true;
|
equal = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return equal;
|
return equal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite &rhs) {
|
|
||||||
|
|
||||||
|
// Copy constructor
|
||||||
|
Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other)
|
||||||
|
{
|
||||||
|
*this = std::move(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Copy assignment operator
|
||||||
|
Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs)
|
||||||
|
{
|
||||||
// Only do assignment if RHS is a different object from this.
|
// Only do assignment if RHS is a different object from this.
|
||||||
if (this != &rhs) {
|
if (this != &rhs)
|
||||||
|
{
|
||||||
// Deallocate, allocate new space, copy values...
|
// Deallocate, allocate new space, copy values...
|
||||||
const std::string system_ = rhs.get_system();
|
this->reset();
|
||||||
const uint32_t PRN_ = rhs.get_PRN();
|
this->set_system(rhs.get_system());
|
||||||
const std::string block_ = rhs.get_block();
|
this->set_PRN(rhs.get_PRN());
|
||||||
// const int32_t rf_link_ = 0;
|
this->set_block(rhs.get_system(), rhs.get_PRN());
|
||||||
this->set_system(system_);
|
this->set_rf_link(rhs.get_rf_link());
|
||||||
this->set_PRN(PRN_);
|
|
||||||
this->set_block(system_, PRN_);
|
|
||||||
//this.rf_link = rf_link_;
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Move constructor
|
||||||
|
Gnss_Satellite::Gnss_Satellite(const Gnss_Satellite& other)
|
||||||
|
{
|
||||||
|
*this = std::move(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Move assignment operator
|
||||||
|
Gnss_Satellite& Gnss_Satellite::operator=(Gnss_Satellite&& other)
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
this->reset();
|
||||||
|
this->system = std::move(other.get_system());
|
||||||
|
this->PRN = std::move(other.get_PRN());
|
||||||
|
this->block = std::move(other.get_block());
|
||||||
|
this->rf_link = std::move(other.get_rf_link());
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Gnss_Satellite::set_system(const std::string& system_)
|
void Gnss_Satellite::set_system(const std::string& system_)
|
||||||
@ -260,6 +291,14 @@ int32_t Gnss_Satellite::get_rf_link() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Gnss_Satellite::set_rf_link(int32_t rf_link_)
|
||||||
|
{
|
||||||
|
// Set satellite's rf link. Identifies the GLONASS Frequency Channel
|
||||||
|
rf_link = rf_link_;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t Gnss_Satellite::get_PRN() const
|
uint32_t Gnss_Satellite::get_PRN() const
|
||||||
{
|
{
|
||||||
// Get satellite's PRN
|
// Get satellite's PRN
|
||||||
|
@ -61,7 +61,12 @@ public:
|
|||||||
|
|
||||||
friend bool operator==(const Gnss_Satellite& /*sat1*/, const Gnss_Satellite& /*sat2*/); //!< operator== for comparison
|
friend bool operator==(const Gnss_Satellite& /*sat1*/, const Gnss_Satellite& /*sat2*/); //!< operator== for comparison
|
||||||
friend std::ostream& operator<<(std::ostream& /*out*/, const Gnss_Satellite& /*sat*/); //!< operator<< for pretty printing
|
friend std::ostream& operator<<(std::ostream& /*out*/, const Gnss_Satellite& /*sat*/); //!< operator<< for pretty printing
|
||||||
//Gnss_Satellite& operator=(const Gnss_Satellite &);
|
|
||||||
|
Gnss_Satellite(Gnss_Satellite&& other); //!< Copy constructor
|
||||||
|
Gnss_Satellite& operator=(const Gnss_Satellite&); //!< Copy assignment operator
|
||||||
|
Gnss_Satellite(const Gnss_Satellite& other); //!< Move constructor
|
||||||
|
Gnss_Satellite& operator=(Gnss_Satellite&& other); //!< Move assignment operator
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t PRN;
|
uint32_t PRN;
|
||||||
std::string system;
|
std::string system;
|
||||||
@ -73,5 +78,6 @@ private:
|
|||||||
void set_block(const std::string& system_, uint32_t PRN_);
|
void set_block(const std::string& system_, uint32_t PRN_);
|
||||||
std::set<std::string> system_set; // = {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"};
|
std::set<std::string> system_set; // = {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"};
|
||||||
void reset();
|
void reset();
|
||||||
|
void set_rf_link(int32_t rf_link_);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user