void CommandService::UnregisterElement(const SmartPointer<IElementReference>& elementReference) { if (commandCallbacks.contains(elementReference->GetCommandId())) { QList<IElementReference::Pointer>& parameterizedCommands = commandCallbacks[elementReference->GetCommandId()]; parameterizedCommands.removeAll(elementReference); if (parameterizedCommands.isEmpty()) { commandCallbacks.remove(elementReference->GetCommandId()); } } }
void CommandService::RegisterElement(const SmartPointer<IElementReference>& elementReference) { QList<IElementReference::Pointer>& parameterizedCommands = commandCallbacks[elementReference->GetCommandId()]; parameterizedCommands.push_back(elementReference); // If the active handler wants to update the callback, it can do // so now Command::Pointer command = GetCommand(elementReference->GetCommandId()); if (command->IsDefined()) { if (IElementUpdater::Pointer updater = command->GetHandler().Cast<IElementUpdater>()) { updater->UpdateElement(elementReference->GetElement().GetPointer(), elementReference->GetParameters()); } } }
SmartPointer<IHandlerActivation> HandlerService::ActivateHandler( const SmartPointer<IHandlerActivation>& childActivation) { const QString commandId = childActivation->GetCommandId(); const IHandler::Pointer handler = childActivation->GetHandler(); const Expression::Pointer expression = childActivation->GetExpression(); const int depth = childActivation->GetDepth() + 1; const IHandlerActivation::Pointer localActivation( new HandlerActivation(commandId, handler, expression, depth, this)); handlerAuthority->ActivateHandler(localActivation); return localActivation; }
SmartPointer<IHandlerActivation> SlaveHandlerService::ActivateHandler(const SmartPointer<IHandlerActivation>& childActivation) { const QString commandId = childActivation->GetCommandId(); const IHandler::Pointer handler = childActivation->GetHandler(); const Expression::Pointer childExpression = childActivation->GetExpression(); Expression::Pointer expression = defaultExpression; if (childExpression.IsNotNull() && defaultExpression.IsNotNull()) { const AndExpression::Pointer andExpression(new AndExpression()); andExpression->Add(childExpression); andExpression->Add(defaultExpression); expression = andExpression; } else if (childExpression.IsNotNull()) { expression = childExpression; } const int depth = childActivation->GetDepth() + 1; const IHandlerActivation::Pointer localActivation( new HandlerActivation(commandId, handler, expression, depth, this)); return DoActivation(localActivation); }