mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilibc] Add missing move constructors and assignment operators (#2959)
- Field2d - FieldObject2d - AnalogGyro
This commit is contained in:
@@ -17,6 +17,18 @@ Field2d::Field2d() {
|
||||
m_objects[0]->SetPose(Pose2d{});
|
||||
}
|
||||
|
||||
Field2d::Field2d(Field2d&& rhs) {
|
||||
std::swap(m_table, rhs.m_table);
|
||||
std::swap(m_objects, rhs.m_objects);
|
||||
}
|
||||
|
||||
Field2d& Field2d::operator=(Field2d&& rhs) {
|
||||
std::swap(m_table, rhs.m_table);
|
||||
std::swap(m_objects, rhs.m_objects);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Field2d::SetRobotPose(const Pose2d& pose) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_objects[0]->SetPose(pose);
|
||||
|
||||
@@ -9,6 +9,20 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
FieldObject2d::FieldObject2d(FieldObject2d&& rhs) {
|
||||
std::swap(m_name, rhs.m_name);
|
||||
std::swap(m_entry, rhs.m_entry);
|
||||
std::swap(m_poses, rhs.m_poses);
|
||||
}
|
||||
|
||||
FieldObject2d& FieldObject2d::operator=(FieldObject2d&& rhs) {
|
||||
std::swap(m_name, rhs.m_name);
|
||||
std::swap(m_entry, rhs.m_entry);
|
||||
std::swap(m_poses, rhs.m_poses);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void FieldObject2d::SetPose(const Pose2d& pose) {
|
||||
SetPoses(wpi::makeArrayRef(pose));
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ class AnalogGyro : public GyroBase {
|
||||
|
||||
~AnalogGyro() override;
|
||||
|
||||
AnalogGyro(AnalogGyro&& rhs);
|
||||
AnalogGyro& operator=(AnalogGyro&& rhs);
|
||||
AnalogGyro(AnalogGyro&& rhs) = default;
|
||||
AnalogGyro& operator=(AnalogGyro&& rhs) = default;
|
||||
|
||||
/**
|
||||
* Return the actual angle in degrees that the robot is currently facing.
|
||||
|
||||
@@ -47,6 +47,9 @@ class Field2d : public Sendable {
|
||||
|
||||
Field2d();
|
||||
|
||||
Field2d(Field2d&& rhs);
|
||||
Field2d& operator=(Field2d&& rhs);
|
||||
|
||||
/**
|
||||
* Set the robot pose from a Pose object.
|
||||
*
|
||||
|
||||
@@ -36,6 +36,9 @@ class FieldObject2d {
|
||||
FieldObject2d(std::string&& name, const private_init&)
|
||||
: m_name{std::move(name)} {}
|
||||
|
||||
FieldObject2d(FieldObject2d&& rhs);
|
||||
FieldObject2d& operator=(FieldObject2d&& rhs);
|
||||
|
||||
/**
|
||||
* Set the pose from a Pose object.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user