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