blob: 312109857d57345d063a73f4053059b9dcd5e5eb [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2011-2017. 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
16namespace frc {
17
18class Command;
19
20class 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);
28 Command* GetDefaultCommand();
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