| 352 | } |
| 353 | |
| 354 | bool HandlerUtil::ToggleCommandState(const SmartPointer<Command>& command) |
| 355 | { |
| 356 | State::Pointer state = command->GetState(RegistryToggleState::STATE_ID); |
| 357 | if(state.IsNull()) |
| 358 | { |
| 359 | throw ExecutionException("The command does not have a toggle state"); |
| 360 | } |
| 361 | if(ObjectBool::Pointer boolObj = state->GetValue().Cast<ObjectBool>()) |
| 362 | { |
| 363 | bool oldValue = boolObj->GetValue(); |
| 364 | Object::Pointer newValue(new ObjectBool(!oldValue)); |
| 365 | state->SetValue(newValue); |
| 366 | return oldValue; |
| 367 | } |
| 368 | else |
| 369 | { |
| 370 | throw ExecutionException("The command's toggle state doesn't contain a boolean value"); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | bool HandlerUtil::MatchesRadioState(const SmartPointer<ExecutionEvent>& event) |
| 375 | { |