WPILibC++  2019.1.1-beta-2-22-gc405188
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Scheduler.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2011-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 <memory>
11 
12 #include "frc/ErrorBase.h"
13 #include "frc/smartdashboard/SendableBase.h"
14 
15 namespace frc {
16 
17 class ButtonScheduler;
18 class Command;
19 class Subsystem;
20 
21 class Scheduler : public ErrorBase, public SendableBase {
22  public:
28  static Scheduler* GetInstance();
29 
38  void AddCommand(Command* command);
39 
40  void AddButton(ButtonScheduler* button);
41 
50  void RegisterSubsystem(Subsystem* subsystem);
51 
66  void Run();
67 
73  void Remove(Command* command);
74 
75  void RemoveAll();
76 
80  void ResetAll();
81 
82  void SetEnabled(bool enabled);
83 
84  void InitSendable(SendableBuilder& builder) override;
85 
86  private:
87  Scheduler();
88  ~Scheduler() override;
89 
90  Scheduler(Scheduler&&) = default;
91  Scheduler& operator=(Scheduler&&) = default;
92 
93  struct Impl;
94  std::unique_ptr<Impl> m_impl;
95 };
96 
97 } // namespace frc
void AddCommand(Command *command)
Add a command to be scheduled later.
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void ResetAll()
Completely resets the scheduler.
Definition: Subsystem.h:23
Definition: ButtonScheduler.h:15
void RegisterSubsystem(Subsystem *subsystem)
Registers a Subsystem to this Scheduler, so that the Scheduler might know if a default Command needs ...
Base class for most objects.
Definition: ErrorBase.h:74
Definition: SendableBase.h:19
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
static Scheduler * GetInstance()
Returns the Scheduler, creating it if one does not exist.
Definition: SendableBuilder.h:23
void Remove(Command *command)
Removes the Command from the Scheduler.
The Command class is at the very core of the entire command framework.
Definition: Command.h:48
void Run()
Runs a single iteration of the loop.
Definition: Scheduler.h:21