WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Subsystem.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2011-2016. 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 #include <string>
12 
13 #include "ErrorBase.h"
14 #include "SmartDashboard/NamedSendable.h"
15 
16 namespace frc {
17 
18 class Command;
19 
20 class Subsystem : public ErrorBase, public NamedSendable {
21  friend class Scheduler;
22 
23  public:
24  explicit Subsystem(const std::string& name);
25  virtual ~Subsystem() = default;
26 
27  void SetDefaultCommand(Command* command);
29  void SetCurrentCommand(Command* command);
30  Command* GetCurrentCommand() const;
31  virtual void InitDefaultCommand();
32 
33  private:
34  void ConfirmCommand();
35 
36  Command* m_currentCommand = nullptr;
37  bool m_currentCommandChanged = true;
38  Command* m_defaultCommand = nullptr;
39  std::string m_name;
40  bool m_initializedDefaultCommand = false;
41 
42  public:
43  std::string GetName() const override;
44  void InitTable(std::shared_ptr<ITable> subtable) override;
45  std::shared_ptr<ITable> GetTable() const override;
46  std::string GetSmartDashboardType() const override;
47 
48  protected:
49  std::shared_ptr<ITable> m_table;
50 };
51 
52 } // namespace frc
std::shared_ptr< ITable > GetTable() const override
Definition: Subsystem.cpp:152
virtual void InitDefaultCommand()
Initialize the default command for this subsystem.
Definition: Subsystem.cpp:35
Definition: Subsystem.h:20
Command * GetDefaultCommand()
Returns the default command (or null if there is none).
Definition: Subsystem.cpp:83
void SetDefaultCommand(Command *command)
Sets the default command.
Definition: Subsystem.cpp:46
void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: Subsystem.cpp:134
Command * GetCurrentCommand() const
Returns the command which currently claims this subsystem.
Definition: Subsystem.cpp:106
std::string GetName() const override
Definition: Subsystem.cpp:130
std::string GetSmartDashboardType() const override
Definition: Subsystem.cpp:132
Base class for most objects.
Definition: ErrorBase.h:72
The Command class is at the very core of the entire command framework.
Definition: Command.h:52
Subsystem(const std::string &name)
Creates a subsystem with the given name.
Definition: Subsystem.cpp:21
The interface for sendable objects that gives the sendable a default name in the Smart Dashboard...
Definition: NamedSendable.h:21
void SetCurrentCommand(Command *command)
Sets the current command.
Definition: Subsystem.cpp:96
Definition: Scheduler.h:29