WPILibC++  2020.3.2-60-g3011ebe
Scheduler.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2011-2019 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/Sendable.h"
14 #include "frc/smartdashboard/SendableHelper.h"
15 
16 namespace frc {
17 
18 class ButtonScheduler;
19 class Command;
20 class Subsystem;
21 
22 class Scheduler : public ErrorBase,
23  public Sendable,
24  public SendableHelper<Scheduler> {
25  public:
31  static Scheduler* GetInstance();
32 
41  void AddCommand(Command* command);
42 
43  void AddButton(ButtonScheduler* button);
44 
53  void RegisterSubsystem(Subsystem* subsystem);
54 
69  void Run();
70 
76  void Remove(Command* command);
77 
78  void RemoveAll();
79 
83  void ResetAll();
84 
85  void SetEnabled(bool enabled);
86 
87  void InitSendable(SendableBuilder& builder) override;
88 
89  private:
90  Scheduler();
91  ~Scheduler() override;
92 
93  Scheduler(Scheduler&&) = default;
94  Scheduler& operator=(Scheduler&&) = default;
95 
96  struct Impl;
97  std::unique_ptr<Impl> m_impl;
98 };
99 
100 } // namespace frc
frc::Scheduler::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::Scheduler::Run
void Run()
Runs a single iteration of the loop.
frc::Scheduler
Definition: Scheduler.h:22
frc::Scheduler::RegisterSubsystem
void RegisterSubsystem(Subsystem *subsystem)
Registers a Subsystem to this Scheduler, so that the Scheduler might know if a default Command needs ...
frc::Command
The Command class is at the very core of the entire command framework.
Definition: Command.h:49
frc::Subsystem
Definition: Subsystem.h:24
frc::ErrorBase
Base class for most objects.
Definition: ErrorBase.h:104
frc::Scheduler::Remove
void Remove(Command *command)
Removes the Command from the Scheduler.
frc::Scheduler::AddCommand
void AddCommand(Command *command)
Add a command to be scheduled later.
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc
A class that enforces constraints on the differential drive kinematics.
Definition: PDPSim.h:16
frc::Scheduler::GetInstance
static Scheduler * GetInstance()
Returns the Scheduler, creating it if one does not exist.
frc::ButtonScheduler
Definition: ButtonScheduler.h:15
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::Scheduler::ResetAll
void ResetAll()
Completely resets the scheduler.
frc::SendableBuilder
Definition: SendableBuilder.h:23