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