Пример #1
0
	bool FrameTrigger::isTriggerInputEventEquivalentTo(InputEvent inputEventReceived)
	{
		//Compare trigger input event with the one received
		std::string inputEventReceivedMedium = inputEventReceived.getMedium();
		std::string inputEventReceivedMode = inputEventReceived.getMode();
		std::string inputEventReceivedTokens = inputEventReceived.getTokens();

		std::transform(inputEventReceivedMedium.begin(), inputEventReceivedMedium.end(), inputEventReceivedMedium.begin(), ::tolower);
		std::transform(inputEventReceivedMode.begin(), inputEventReceivedMode.end(), inputEventReceivedMode.begin(), ::tolower);
		std::transform(inputEventReceivedTokens.begin(), inputEventReceivedTokens.end(), inputEventReceivedTokens.begin(), ::tolower);

		std::string triggerInputEventMedium = triggerInputEvent.getMedium();
		std::string triggerInputEventMode = triggerInputEvent.getMode();
		std::string triggerInputEventTokens = triggerInputEvent.getTokens();

		std::transform(triggerInputEventMedium.begin(), triggerInputEventMedium.end(), triggerInputEventMedium.begin(), ::tolower);
		std::transform(triggerInputEventMode.begin(), triggerInputEventMode.end(), triggerInputEventMode.begin(), ::tolower);
		std::transform(triggerInputEventTokens.begin(), triggerInputEventTokens.end(), triggerInputEventTokens.begin(), ::tolower);

		bool result = (inputEventReceivedMedium == triggerInputEventMedium) &&
			(inputEventReceivedMode == triggerInputEventMode) &&
			(inputEventReceivedTokens == triggerInputEventTokens);

		return result;
	}
Пример #2
0
	bool MeaningFrame::processInput(InputEvent inputReceived)
	{
        std::stringstream resultsOfActivatedSubFrames;
        
        bool matched = false;
        
        if(subFrames.size() > 0)
        {
			for(std::vector<MeaningFrame>::iterator it2 = subFrames.begin(); (it2 != subFrames.end() && !matched); ++it2)
			{
				if(!(*it2).isValid())
				{
					matched = (*it2).processInput(inputReceived);
                    
				}
			}
            validate(inputReceived);
            return matched;
            
        }
        else if(triggers.size() > 0)
        {
            for(std::vector<FrameTrigger>::iterator it = triggers.begin(); (it != triggers.end() && !matched); ++it)
            {
                if(!(*it).isValid())
                {
                    matched = (*it).processInput(inputReceived);
                    if(matched && (*it).triggerInputEvent.getTokens() == "")
                    {
                        (*it).triggerInputEvent.setTokens(inputReceived.getTokens());
                        addResult(inputReceived.getTokens());
                    }
                }
            }
            
            validate(inputReceived);
            return matched;
        }
        else activated = false;
        return matched;
    }