Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2011. All Rights Reserved. |
| 3 | */ |
| 4 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 5 | /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ |
| 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); |
| 26 | Command *GetDefaultCommand(); |
| 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 |