WPILibC++  2018.4.1-20180924024742-1199-gb1965f7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
InstantCommand.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <functional>
11 
12 #include <wpi/Twine.h>
13 
14 #include "frc/commands/Command.h"
15 #include "frc/commands/Subsystem.h"
16 
17 namespace frc {
18 
24 class InstantCommand : public Command {
25  public:
31  explicit InstantCommand(const wpi::Twine& name);
32 
38  explicit InstantCommand(Subsystem& subsystem);
39 
46  InstantCommand(const wpi::Twine& name, Subsystem& subsystem);
47 
53  explicit InstantCommand(std::function<void()> func);
54 
61  InstantCommand(Subsystem& subsystem, std::function<void()> func);
62 
69  InstantCommand(const wpi::Twine& name, std::function<void()> func);
70 
78  InstantCommand(const wpi::Twine& name, Subsystem& subsystem,
79  std::function<void()> func);
80 
81  InstantCommand() = default;
82  virtual ~InstantCommand() = default;
83 
84  protected:
85  std::function<void()> m_func = nullptr;
86  void _Initialize() override;
87  bool IsFinished() override;
88 };
89 
90 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: Subsystem.h:23
This command will execute once, then finish immediately afterward.
Definition: InstantCommand.h:24
bool IsFinished() override
Returns whether this command is finished.
The Command class is at the very core of the entire command framework.
Definition: Command.h:48
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79