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 #ifndef __SUBSYSTEM_H__
9 #define __SUBSYSTEM_H__
10 
11 #include "ErrorBase.h"
12 #include "SmartDashboard/NamedSendable.h"
13 #include <string>
14 #include <memory>
15 
16 class Command;
17 
18 class Subsystem : public ErrorBase, public NamedSendable {
19  friend class Scheduler;
20 
21  public:
22  Subsystem(const std::string &name);
23  virtual ~Subsystem() = default;
24 
25  void SetDefaultCommand(Command *command);
27  void SetCurrentCommand(Command *command);
28  Command *GetCurrentCommand() const;
29  virtual void InitDefaultCommand();
30 
31  private:
32  void ConfirmCommand();
33 
34  Command *m_currentCommand = nullptr;
35  bool m_currentCommandChanged = true;
36  Command *m_defaultCommand = nullptr;
37  std::string m_name;
38  bool m_initializedDefaultCommand = false;
39 
40  public:
41  virtual std::string GetName() const;
42  virtual void InitTable(std::shared_ptr<ITable> table);
43  virtual std::shared_ptr<ITable> GetTable() const;
44  virtual std::string GetSmartDashboardType() const;
45 
46  protected:
47  std::shared_ptr<ITable> m_table;
48 };
49 
50 #endif
Definition: Scheduler.h:27
virtual void InitTable(std::shared_ptr< ITable > table)
Initializes a table for this sendable object.
Definition: Subsystem.cpp:129
virtual std::string GetSmartDashboardType() const
Definition: Subsystem.cpp:127
virtual std::shared_ptr< ITable > GetTable() const
Definition: Subsystem.cpp:147
Command * GetDefaultCommand()
Returns the default command (or null if there is none).
Definition: Subsystem.cpp:80
virtual std::string GetName() const
Definition: Subsystem.cpp:125
virtual void InitDefaultCommand()
Initialize the default command for this subsystem This is meant to be the place to call SetDefaultCom...
Definition: Subsystem.cpp:32
Subsystem(const std::string &name)
Creates a subsystem with the given name.
Definition: Subsystem.cpp:18
Definition: Subsystem.h:18
Base class for most objects.
Definition: ErrorBase.h:66
void SetCurrentCommand(Command *command)
Sets the current command.
Definition: Subsystem.cpp:92
Command * GetCurrentCommand() const
Returns the command which currently claims this subsystem.
Definition: Subsystem.cpp:101
The interface for sendable objects that gives the sendable a default name in the Smart Dashboard...
Definition: NamedSendable.h:19
The Command class is at the very core of the entire command framework.
Definition: Command.h:54
void SetDefaultCommand(Command *command)
Sets the default command.
Definition: Subsystem.cpp:44