blob: f3db1dadc31ff7d1753545e9a318c2d41521807b [file] [log] [blame]
Brian Silverman1a675112016-02-20 20:42:49 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 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
Brian Silverman26e4e522015-12-17 01:56:40 -05008#include "RobotState.h"
9
10#include "Base.h"
11
12std::shared_ptr<RobotStateInterface> RobotState::impl;
13
14void RobotState::SetImplementation(RobotStateInterface& i) {
15 impl = std::shared_ptr<RobotStateInterface>(
16 &i, NullDeleter<RobotStateInterface>());
17}
18
19void RobotState::SetImplementation(
20 std::shared_ptr<RobotStateInterface> i) {
21 impl = i;
22}
23
24bool RobotState::IsDisabled() {
25 if (impl != nullptr) {
26 return impl->IsDisabled();
27 }
28 return true;
29}
30
31bool RobotState::IsEnabled() {
32 if (impl != nullptr) {
33 return impl->IsEnabled();
34 }
35 return false;
36}
37
38bool RobotState::IsOperatorControl() {
39 if (impl != nullptr) {
40 return impl->IsOperatorControl();
41 }
42 return true;
43}
44
45bool RobotState::IsAutonomous() {
46 if (impl != nullptr) {
47 return impl->IsAutonomous();
48 }
49 return false;
50}
51
52bool RobotState::IsTest() {
53 if (impl != nullptr) {
54 return impl->IsTest();
55 }
56 return false;
57}