mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
Add copy constructor, copy assignment operator, move constructor and move assignment operator
This commit is contained in:
parent
620191f818
commit
52c08e3ab4
@ -89,29 +89,60 @@ bool operator==(const Gnss_Satellite& sat1, const Gnss_Satellite& sat2)
|
|||||||
{
|
{
|
||||||
if (sat1.get_PRN() == sat2.get_PRN())
|
if (sat1.get_PRN() == sat2.get_PRN())
|
||||||
{
|
{
|
||||||
equal = true;
|
if (sat1.get_rf_link() == sat2.get_rf_link())
|
||||||
|
{
|
||||||
|
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
|
||||||
@ -625,100 +664,100 @@ std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_
|
|||||||
if (system_ == "Beidou")
|
if (system_ == "Beidou")
|
||||||
{
|
{
|
||||||
// Check https://en.wikipedia.org/wiki/List_of_BeiDou_satellites
|
// Check https://en.wikipedia.org/wiki/List_of_BeiDou_satellites
|
||||||
switch ( PRN_ )
|
switch (PRN_)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
block_ = std::string("Compass-G1"); //!<GEO 140.0°E; launched 2010/01/16
|
block_ = std::string("Compass-G1"); //!<GEO 140.0°E; launched 2010/01/16
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
block_ = std::string("Compass-G6"); //!<GEO 80°E; launched 2012/10/25
|
block_ = std::string("Compass-G6"); //!<GEO 80°E; launched 2012/10/25
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
block_ = std::string("Compass-G7"); //!<GEO 110.5°E; launched 2016/06/12
|
block_ = std::string("Compass-G7"); //!<GEO 110.5°E; launched 2016/06/12
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
block_ = std::string("Compass-G4"); //!<GEO 160.0°E; launched 2010/10/31
|
block_ = std::string("Compass-G4"); //!<GEO 160.0°E; launched 2010/10/31
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
block_ = std::string("Compass-G5"); //!<GEO 58.75°E; launched 2012/02/24
|
block_ = std::string("Compass-G5"); //!<GEO 58.75°E; launched 2012/02/24
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
block_ = std::string("Compass-IGS01"); //!<55° inclination IGSO 118°E; launched 2010/07/31
|
block_ = std::string("Compass-IGS01"); //!<55° inclination IGSO 118°E; launched 2010/07/31
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
block_ = std::string("Compass-IGS02"); //!<55° inclination IGSO 118°E; launched 2010/12/17
|
block_ = std::string("Compass-IGS02"); //!<55° inclination IGSO 118°E; launched 2010/12/17
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
block_ = std::string("Compass-IGS03"); //!<55° inclination IGSO 118°E; launched 2011/04/09
|
block_ = std::string("Compass-IGS03"); //!<55° inclination IGSO 118°E; launched 2011/04/09
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
block_ = std::string("Compass-IGS04"); //!<55° inclination IGSO 95°E; launched 2011/07/27
|
block_ = std::string("Compass-IGS04"); //!<55° inclination IGSO 95°E; launched 2011/07/27
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
block_ = std::string("Compass-IGS05"); //!<55° inclination IGSO 118°E; launched 2011/12/01
|
block_ = std::string("Compass-IGS05"); //!<55° inclination IGSO 118°E; launched 2011/12/01
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
block_ = std::string("Compass-M3"); //!<Slot A07; launched 2012/04/29
|
block_ = std::string("Compass-M3"); //!<Slot A07; launched 2012/04/29
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
block_ = std::string("Compass-M4"); //!<Slot A08; launched 2012/04/29
|
block_ = std::string("Compass-M4"); //!<Slot A08; launched 2012/04/29
|
||||||
break;
|
break;
|
||||||
case 19:
|
case 19:
|
||||||
block_ = std::string("BEIDOU-3 M1"); //!<Slot B-7; launched 2017/11/05
|
block_ = std::string("BEIDOU-3 M1"); //!<Slot B-7; launched 2017/11/05
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
block_ = std::string("BEIDOU-3 M2"); //!<Slot B-5; launched 2017/11/05
|
block_ = std::string("BEIDOU-3 M2"); //!<Slot B-5; launched 2017/11/05
|
||||||
break;
|
break;
|
||||||
case 21:
|
case 21:
|
||||||
block_ = std::string("BEIDOU 3M5"); //!<Slot B-?; launched 2018/02/12
|
block_ = std::string("BEIDOU 3M5"); //!<Slot B-?; launched 2018/02/12
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 22:
|
||||||
block_ = std::string("BEIDOU 3M6"); //!<Slot B-6; launched 2018/02/12
|
block_ = std::string("BEIDOU 3M6"); //!<Slot B-6; launched 2018/02/12
|
||||||
break;
|
break;
|
||||||
case 23:
|
case 23:
|
||||||
block_ = std::string("BEIDOU 3M9"); //!<Slot C-7; launched 2018/07/29
|
block_ = std::string("BEIDOU 3M9"); //!<Slot C-7; launched 2018/07/29
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
block_ = std::string("BEIDOU 3M10"); //!<Slot C-1; launched 2018/07/29
|
block_ = std::string("BEIDOU 3M10"); //!<Slot C-1; launched 2018/07/29
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
block_ = std::string("BEIDOU 3M12"); //!<Slot C-8; launched 2018/08/24
|
block_ = std::string("BEIDOU 3M12"); //!<Slot C-8; launched 2018/08/24
|
||||||
break;
|
break;
|
||||||
case 26:
|
case 26:
|
||||||
block_ = std::string("BEIDOU 3M11"); //!<Slot C-2; launched 2018/08/24
|
block_ = std::string("BEIDOU 3M11"); //!<Slot C-2; launched 2018/08/24
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
block_ = std::string("BEIDOU 3M3"); //!<Slot A-?; launched 2018/01/11
|
block_ = std::string("BEIDOU 3M3"); //!<Slot A-?; launched 2018/01/11
|
||||||
break;
|
break;
|
||||||
case 28:
|
case 28:
|
||||||
block_ = std::string("BEIDOU 3M4"); //!<Slot A-?; launched 2018/01/11
|
block_ = std::string("BEIDOU 3M4"); //!<Slot A-?; launched 2018/01/11
|
||||||
break;
|
break;
|
||||||
case 29:
|
case 29:
|
||||||
block_ = std::string("BEIDOU 3M7"); //!<Slot A-?; launched 2018/03/29
|
block_ = std::string("BEIDOU 3M7"); //!<Slot A-?; launched 2018/03/29
|
||||||
break;
|
break;
|
||||||
case 30:
|
case 30:
|
||||||
block_ = std::string("BEIDOU 3M8"); //!<Slot A-?; launched 2018/03/29
|
block_ = std::string("BEIDOU 3M8"); //!<Slot A-?; launched 2018/03/29
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
block_ = std::string("BEIDOU 3M13"); //!<Slot B-1?; launched 2018/09/19
|
block_ = std::string("BEIDOU 3M13"); //!<Slot B-1?; launched 2018/09/19
|
||||||
break;
|
break;
|
||||||
case 33:
|
case 33:
|
||||||
block_ = std::string("BEIDOU 3M14"); //!<Slot B-3; launched 2018/09/19
|
block_ = std::string("BEIDOU 3M14"); //!<Slot B-3; launched 2018/09/19
|
||||||
break;
|
break;
|
||||||
case 34:
|
case 34:
|
||||||
block_ = std::string("BEIDOU 3M15"); //!<Slot B-3; launched 2018/10/15
|
block_ = std::string("BEIDOU 3M15"); //!<Slot B-3; launched 2018/10/15
|
||||||
break;
|
break;
|
||||||
case 35:
|
case 35:
|
||||||
block_ = std::string("BEIDOU 3M16"); //!<Slot B-3; launched 2018/10/15
|
block_ = std::string("BEIDOU 3M16"); //!<Slot B-3; launched 2018/10/15
|
||||||
break;
|
break;
|
||||||
case 36:
|
case 36:
|
||||||
block_ = std::string("BEIDOU 3M17"); //!<Slot B-3; launched 2018/11/18
|
block_ = std::string("BEIDOU 3M17"); //!<Slot B-3; launched 2018/11/18
|
||||||
break;
|
break;
|
||||||
case 37:
|
case 37:
|
||||||
block_ = std::string("BEIDOU 3M18"); //!<Slot B-3; launched 2018/11/18
|
block_ = std::string("BEIDOU 3M18"); //!<Slot B-3; launched 2018/11/18
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
block_ = std::string("Unknown(Simulated)");
|
block_ = std::string("Unknown(Simulated)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return block_;
|
return block_;
|
||||||
|
@ -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