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