Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 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 | |
| 12 | using namespace frc; |
| 13 | |
| 14 | std::shared_ptr<RobotStateInterface> RobotState::impl; |
| 15 | |
| 16 | void RobotState::SetImplementation(RobotStateInterface& i) { |
| 17 | impl = std::shared_ptr<RobotStateInterface>( |
| 18 | &i, NullDeleter<RobotStateInterface>()); |
| 19 | } |
| 20 | |
| 21 | void RobotState::SetImplementation(std::shared_ptr<RobotStateInterface> i) { |
| 22 | impl = i; |
| 23 | } |
| 24 | |
| 25 | bool RobotState::IsDisabled() { |
| 26 | if (impl != nullptr) { |
| 27 | return impl->IsDisabled(); |
| 28 | } |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | bool RobotState::IsEnabled() { |
| 33 | if (impl != nullptr) { |
| 34 | return impl->IsEnabled(); |
| 35 | } |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | bool RobotState::IsOperatorControl() { |
| 40 | if (impl != nullptr) { |
| 41 | return impl->IsOperatorControl(); |
| 42 | } |
| 43 | return true; |
| 44 | } |
| 45 | |
| 46 | bool RobotState::IsAutonomous() { |
| 47 | if (impl != nullptr) { |
| 48 | return impl->IsAutonomous(); |
| 49 | } |
| 50 | return false; |
| 51 | } |
| 52 | |
| 53 | bool RobotState::IsTest() { |
| 54 | if (impl != nullptr) { |
| 55 | return impl->IsTest(); |
| 56 | } |
| 57 | return false; |
| 58 | } |