Add move constructors and assignment operators to wpilibc (#1314)

Fixes #898.
This commit is contained in:
Tyler Veness
2018-09-24 00:08:25 -07:00
committed by Peter Johnson
parent b1965f74a8
commit 1aa8446725
136 changed files with 764 additions and 89 deletions

View File

@@ -115,6 +115,9 @@ class Command : public ErrorBase, public SendableBase {
~Command() override = default;
Command(Command&&) = default;
Command& operator=(Command&&) = default;
/**
* Returns the time since this command was initialized (in seconds).
*

View File

@@ -46,6 +46,9 @@ class CommandGroup : public Command {
virtual ~CommandGroup() = default;
CommandGroup(CommandGroup&&) = default;
CommandGroup& operator=(CommandGroup&&) = default;
/**
* Adds a new Command to the group. The Command will be started after all the
* previously added Commands.

View File

@@ -21,6 +21,10 @@ class CommandGroupEntry {
CommandGroupEntry() = default;
CommandGroupEntry(Command* command, Sequence state, double timeout = -1.0);
CommandGroupEntry(CommandGroupEntry&&) = default;
CommandGroupEntry& operator=(CommandGroupEntry&&) = default;
bool IsTimedOut() const;
double m_timeout = -1.0;

View File

@@ -54,6 +54,9 @@ class ConditionalCommand : public Command {
virtual ~ConditionalCommand() = default;
ConditionalCommand(ConditionalCommand&&) = default;
ConditionalCommand& operator=(ConditionalCommand&&) = default;
protected:
/**
* The Condition to test to determine which Command to run.

View File

@@ -81,6 +81,9 @@ class InstantCommand : public Command {
InstantCommand() = default;
virtual ~InstantCommand() = default;
InstantCommand(InstantCommand&&) = default;
InstantCommand& operator=(InstantCommand&&) = default;
protected:
std::function<void()> m_func = nullptr;
void _Initialize() override;

View File

@@ -40,6 +40,9 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
Subsystem& subsystem);
virtual ~PIDCommand() = default;
PIDCommand(PIDCommand&&) = default;
PIDCommand& operator=(PIDCommand&&) = default;
void SetSetpointRelative(double deltaSetpoint);
// PIDOutput interface

View File

@@ -105,6 +105,9 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
~PIDSubsystem() override = default;
PIDSubsystem(PIDSubsystem&&) = default;
PIDSubsystem& operator=(PIDSubsystem&&) = default;
/**
* Enables the internal PIDController.
*/

View File

@@ -20,6 +20,9 @@ class PrintCommand : public InstantCommand {
explicit PrintCommand(const wpi::Twine& message);
virtual ~PrintCommand() = default;
PrintCommand(PrintCommand&&) = default;
PrintCommand& operator=(PrintCommand&&) = default;
protected:
virtual void Initialize();

View File

@@ -87,6 +87,9 @@ class Scheduler : public ErrorBase, public SendableBase {
Scheduler();
~Scheduler() override;
Scheduler(Scheduler&&) = default;
Scheduler& operator=(Scheduler&&) = default;
struct Impl;
std::unique_ptr<Impl> m_impl;
};

View File

@@ -16,6 +16,9 @@ class StartCommand : public InstantCommand {
explicit StartCommand(Command* commandToStart);
virtual ~StartCommand() = default;
StartCommand(StartCommand&&) = default;
StartCommand& operator=(StartCommand&&) = default;
protected:
virtual void Initialize();

View File

@@ -31,6 +31,9 @@ class Subsystem : public ErrorBase, public SendableBase {
*/
explicit Subsystem(const wpi::Twine& name);
Subsystem(Subsystem&&) = default;
Subsystem& operator=(Subsystem&&) = default;
/**
* Sets the default command. If this is not called or is called with null,
* then there will be no default command for the subsystem.

View File

@@ -54,6 +54,9 @@ class TimedCommand : public Command {
virtual ~TimedCommand() = default;
TimedCommand(TimedCommand&&) = default;
TimedCommand& operator=(TimedCommand&&) = default;
protected:
/**
* Ends command when timed out.

View File

@@ -31,6 +31,9 @@ class WaitCommand : public TimedCommand {
WaitCommand(const wpi::Twine& name, double timeout);
virtual ~WaitCommand() = default;
WaitCommand(WaitCommand&&) = default;
WaitCommand& operator=(WaitCommand&&) = default;
};
} // namespace frc

View File

@@ -19,6 +19,9 @@ class WaitForChildren : public Command {
WaitForChildren(const wpi::Twine& name, double timeout);
virtual ~WaitForChildren() = default;
WaitForChildren(WaitForChildren&&) = default;
WaitForChildren& operator=(WaitForChildren&&) = default;
protected:
virtual bool IsFinished();
};

View File

@@ -29,6 +29,9 @@ class WaitUntilCommand : public Command {
virtual ~WaitUntilCommand() = default;
WaitUntilCommand(WaitUntilCommand&&) = default;
WaitUntilCommand& operator=(WaitUntilCommand&&) = default;
protected:
/**
* Check if we've reached the actual finish time.