コード例 #1
0
void NotifyingAlertParser::parseAttribute(const AlertAttribute& attribute,
		json_object* const & pValue)
{
	switch (attribute)
	{
	case AlertAttribute::DESCRIPTION:
	{
		const std::string description(json_object_get_string(pValue));
		for (listeners::AlertDetailsListener* const & pListener : getListeners())
		{
			pListener->notifyDescription(description);
		}
		break;
	}
	case AlertAttribute::EXPIRY_TIME:
	{
		const time_t expiryTime(
				static_cast<time_t>(json_object_get_int64(pValue)));
		for (listeners::AlertDetailsListener* const & pListener : getListeners())
		{
			pListener->notifyExpiryTime(expiryTime);
		}
		break;
	}
	case AlertAttribute::TITLE:
	{
		const std::string title(json_object_get_string(pValue));
		for (listeners::AlertDetailsListener* const & pListener : getListeners())
		{
			pListener->notifyTitle(title);
		}
		break;
	}
	case AlertAttribute::URI:
	{
		const std::string uri(json_object_get_string(pValue));
		for (listeners::AlertDetailsListener* const & pListener : getListeners())
		{
			pListener->notifyUri(uri);
		}
		break;
	}
	default:
	{
		throw std::logic_error(
				createUndefinedAttributeErrorMessage(AlertAttribute_NAME,
						attribute));
		break;
	}
	}
}
コード例 #2
0
void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener::ListenerID& listenerID, Node* rootNode)
{
    auto listeners = getListeners(listenerID);
    
    if (listeners == nullptr)
        return;
    auto sceneGraphListeners = listeners->getSceneGraphPriorityListeners();
    
    if (sceneGraphListeners == nullptr)
        return;

    // Reset priority index
    _nodePriorityIndex = 0;
    _nodePriorityMap.clear();

    visitTarget(rootNode, true);
    
    // After sort: priority < 0, > 0
    std::sort(sceneGraphListeners->begin(), sceneGraphListeners->end(), [this](const EventListener* l1, const EventListener* l2) {
        return _nodePriorityMap[l1->getAssociatedNode()] > _nodePriorityMap[l2->getAssociatedNode()];
    });
    
#if DUMP_LISTENER_ITEM_PRIORITY_INFO
    log("-----------------------------------");
    for (auto& l : *sceneGraphListeners)
    {
        log("listener priority: node ([%s]%p), priority (%d)", typeid(*l->_node).name(), l->_node, _nodePriorityMap[l->_node]);
    }
#endif
}
コード例 #3
0
int LuaEngine::executeAccelerometerEvent(Node* pNode, Acceleration* pAccelerationValue)
{
    CCScriptEventListenersForEvent *listeners = getListeners(pNode, ACCELERATE_EVENT);
    if (!listeners) return 1;
    
    _stack->clean();
    LuaValueDict event;
    event["name"] = LuaValue::stringValue("changed");
    event["x"] = LuaValue::floatValue(pAccelerationValue->x);
    event["y"] = LuaValue::floatValue(pAccelerationValue->y);
    event["z"] = LuaValue::floatValue(pAccelerationValue->z);
    event["timestamp"] = LuaValue::floatValue(pAccelerationValue->timestamp);
    
    _stack->pushLuaValueDict(event);
    bool flagNeedClean = false;
    for (auto it=listeners->begin(); it!=listeners->end(); ++it) {
        if ((*it)->removed) {
            flagNeedClean = true;
            continue;
        }
        _stack->copyValue(1);
        _stack->executeFunctionByHandler((*it)->listener, 1);
        _stack->settop(1);
    }
    cleanListeners(listeners, pNode, flagNeedClean);
    return 0;
}
コード例 #4
0
void EventDispatcher::sortEventListenersOfFixedPriority(const EventListener::ListenerID& listenerID)
{
    auto listeners = getListeners(listenerID);

    if (listeners == nullptr)
        return;
    
    // After sort: priority < 0, > 0
    auto fixedListeners = listeners->getFixedPriorityListeners();
    std::sort(fixedListeners->begin(), fixedListeners->end(), [](const EventListener* l1, const EventListener* l2) {
        return l1->getFixedPriority() < l2->getFixedPriority();
    });
    
    // FIXME: Should use binary search
    int index = 0;
    for (auto& listener : *fixedListeners)
    {
        if (listener->getFixedPriority() >= 0)
            break;
        ++index;
    }
    
    listeners->setGt0Index(index);
    
#if DUMP_LISTENER_ITEM_PRIORITY_INFO
    log("-----------------------------------");
    for (auto& l : *fixedListeners)
    {
        log("listener priority: node (%p), fixed (%d)", l->_node, l->_fixedPriority);
    }    
#endif
    
}
コード例 #5
0
int real_main(int argc, char* argv[])
{
   OptionList options;

   options.parse(argc, argv, "f:L:l:c:t:s");

   if(options.args.size() == 0)
   {
      usage("testngppst-runner");
   }

   //showOptions(options);
   
   StringList listeners;
   getListeners(listeners, options);   

   StringList searchingPathsOfListeners;
   getSearchingPathsOfListeners(searchingPathsOfListeners, options);   

   StringList fixtures;
	getSpecifiedFixtures(fixtures, options);

   bool usesSandbox = useSandbox(options);
   
   unsigned int maxConcurrent = 0;
   if(usesSandbox)
   {
      maxConcurrent = getMaxConcurrent(options);
   }
   
   std::string tagsFilterOption = getSingleOption("t", options, "*");
                                                 
   return TestRunner().runTests(useSandbox(options), maxConcurrent, options.args, listeners
                         , searchingPathsOfListeners, fixtures, tagsFilterOption);
}
コード例 #6
0
ファイル: KiwiConsole.cpp プロジェクト: EQ4/KiwiPatcher
    void Console::warning(string const& message) noexcept
    {
#if defined(DEBUG) || defined(NO_GUI)
        cerr << "warning : " << message << endl;
#endif
        shared_ptr<const Message> mess = make_shared<Message>(nullptr, nullptr, nullptr, Message::Warning, message);
        
        ListenerSet<Listener>& listeners(getListeners());
        listeners.call(&Listener::receive, mess);
    }
コード例 #7
0
void ScriptDebugServer::dispatchFunctionToListeners(JavaScriptExecutionCallback callback)
{
    if (m_callingListeners)
        return;

    TemporaryChange<bool> change(m_callingListeners, true);

    ListenerSet& listeners = getListeners();
    if (!listeners.isEmpty())
        dispatchFunctionToListeners(listeners, callback);
}
コード例 #8
0
void DnaAssemblyMultiTask::prepare() {
    // perform assembly
    QString algName = settings.algName;
    DnaAssemblyAlgorithmEnv* env= AppContext::getDnaAssemblyAlgRegistry()->getAlgorithm(algName);
    assert(env);
    if (env == NULL) {
        setError(QString("Algorithm %1 is not found").arg(algName));
        return;
    }
    assemblyToRefTask = env->getTaskFactory()->createTaskInstance(settings, justBuildIndex);
    assemblyToRefTask->addListeners(getListeners());
    addSubTask(assemblyToRefTask);
}
コード例 #9
0
int LuaEngine::executeNodeEvent(Node* pNode, int nAction)
{
    CCScriptEventListenersForEvent *listeners = getListeners(pNode, NODE_EVENT);
    if (!listeners) return 1;
    
    LuaValueDict event;
    switch (nAction)
    {
        case kNodeOnEnter:
            event["name"] = LuaValue::stringValue("enter");
            break;
            
        case kNodeOnExit:
            event["name"] = LuaValue::stringValue("exit");
            break;
            
        case kNodeOnEnterTransitionDidFinish:
            event["name"] = LuaValue::stringValue("enterTransitionFinish");
            break;
            
        case kNodeOnExitTransitionDidStart:
            event["name"] = LuaValue::stringValue("exitTransitionStart");
            break;
            
        case kNodeOnCleanup:
            event["name"] = LuaValue::stringValue("cleanup");
            break;
            
        default:
            return 0;
    }
    
    _stack->clean();
    _stack->pushLuaValueDict(event);
    bool flagNeedClean = false;
    for (auto it=listeners->begin(); it!=listeners->end(); ++it)
    {
        if ((*it)->removed) {
            flagNeedClean = true;
            continue;
        }
        
        _stack->copyValue(1);
        _stack->executeFunctionByHandler((*it)->listener, 1);
        _stack->settop(1);
    }
    cleanListeners(listeners, pNode, flagNeedClean);
    _stack->clean();
    return 0;
}
コード例 #10
0
void ScriptDebugServer::dispatchBreakpointActionLog(ExecState* exec, const String& message)
{
    if (m_callingListeners)
        return;

    ListenerSet& listeners = getListeners();
    if (listeners.isEmpty())
        return;

    TemporaryChange<bool> change(m_callingListeners, true);

    Vector<ScriptDebugListener*> listenersCopy;
    copyToVector(listeners, listenersCopy);
    for (auto* listener : listenersCopy)
        listener->breakpointActionLog(exec, message);
}
コード例 #11
0
void ScriptDebugServer::dispatchBreakpointActionSound(ExecState*, int breakpointActionIdentifier)
{
    if (m_callingListeners)
        return;

    ListenerSet& listeners = getListeners();
    if (listeners.isEmpty())
        return;

    TemporaryChange<bool> change(m_callingListeners, true);

    Vector<ScriptDebugListener*> listenersCopy;
    copyToVector(listeners, listenersCopy);
    for (auto* listener : listenersCopy)
        listener->breakpointActionSound(breakpointActionIdentifier);
}
コード例 #12
0
void ScriptDebugServer::sourceParsed(ExecState* exec, SourceProvider* sourceProvider, int errorLine, const String& errorMessage)
{
    if (m_callingListeners)
        return;

    ListenerSet& listeners = getListeners();
    if (listeners.isEmpty())
        return;

    TemporaryChange<bool> change(m_callingListeners, true);

    bool isError = errorLine != -1;
    if (isError)
        dispatchFailedToParseSource(listeners, sourceProvider, errorLine, errorMessage);
    else
        dispatchDidParseSource(listeners, sourceProvider, isContentScript(exec));
}
コード例 #13
0
ファイル: KiwiConsole.cpp プロジェクト: EQ4/KiwiPatcher
    void Console::post(scObject object, string const& message) noexcept
    {
#if defined(DEBUG) || defined(NO_GUI)
        cerr << object->getText() << " : " << message << endl;
#endif
        scInstance instance = nullptr;
        scPatcher  patcher  = nullptr;
        if(object)
        {
            instance= object->getInstance();
            patcher = object->getPatcher();
        }
        shared_ptr<const Message> mess = make_shared<Message>(instance, patcher, object, Message::Post, message);
        
        ListenerSet<Listener>& listeners(getListeners());
        listeners.call(&Listener::receive, mess);
    }
コード例 #14
0
ファイル: KiwiConsole.cpp プロジェクト: EQ4/KiwiPatcher
    void Console::warning(scObject object, string const& message) noexcept
    {
#if defined(DEBUG) || defined(NO_GUI)
        cerr << "warning : " << object->getName()->getName() << " : " << message << endl;
#endif
        shared_ptr<const Kiwi::Instance> instance = nullptr;
        shared_ptr<const Kiwi::Patcher> patcher = nullptr;
        if(object)
        {
            instance    = object->getInstance();
            patcher     = object->getPatcher();
        }
        shared_ptr<const Message> mess = make_shared<Message>(instance, patcher, object, Message::Warning, message);
        
        ListenerSet<Listener>& listeners(getListeners());
        listeners.call(&Listener::receive, mess);
    }
コード例 #15
0
void ScriptDebugServer::dispatchBreakpointActionProbe(ExecState* exec, const ScriptBreakpointAction& action, const Deprecated::ScriptValue& sampleValue)
{
    if (m_callingListeners)
        return;

    ListenerSet& listeners = getListeners();
    if (listeners.isEmpty())
        return;

    TemporaryChange<bool> change(m_callingListeners, true);

    unsigned sampleId = m_nextProbeSampleId++;

    Vector<ScriptDebugListener*> listenersCopy;
    copyToVector(listeners, listenersCopy);
    for (auto* listener : listenersCopy)
        listener->breakpointActionProbe(exec, action, m_currentProbeBatchId, sampleId, sampleValue);
}
コード例 #16
0
int LuaEngine::executeNodeEnterFrameEvent(Node* pNode, float dt)
{
    CCScriptEventListenersForEvent *listeners = getListeners(pNode, NODE_ENTER_FRAME_EVENT);
    if (!listeners) return 1;
    
    bool flagNeedClean = false;
    for (auto it=listeners->begin(); it!=listeners->end(); ++it) {
        if ((*it)->removed) {
            flagNeedClean = true;
            continue;
        }
        _stack->pushFloat(dt);
        _stack->executeFunctionByHandler((*it)->listener, 1);
        _stack->clean();
    }
    cleanListeners(listeners, pNode, flagNeedClean);
    return 0;
}
コード例 #17
0
int LuaEngine::executeKeypadEvent(Node* pNode, int eventType)
{
    CCScriptEventListenersForEvent *listeners = getListeners(pNode, KEYPAD_EVENT);
    if (!listeners) return 1;
    
    _stack->clean();
    LuaValueDict event;
    event["name"] = LuaValue::stringValue("clicked");
    switch (eventType)
    {
        case (int)EventKeyboard::KeyCode::KEY_BACK:
            event["key"] = LuaValue::stringValue("back");
            break;
            
        case (int)EventKeyboard::KeyCode::KEY_MENU:
            event["key"] = LuaValue::stringValue("menu");
            break;
            
        default:
            event["key"] = LuaValue::intValue(eventType);
            break;
    }
    
    _stack->pushLuaValueDict(event);
    bool flagNeedClean = false;
    for (auto it=listeners->begin(); it!=listeners->end(); ++it) {
        if ((*it)->removed) {
            flagNeedClean = true;
            continue;
        }
        _stack->copyValue(1);
        _stack->executeFunctionByHandler((*it)->listener, 1);
        _stack->settop(1);
    }
    cleanListeners(listeners, pNode, flagNeedClean);
    _stack->clean();
    return 0;
}
コード例 #18
0
int LuaEngine::executeNodeTouchEvent(Node* pNode, int eventType, Touch *pTouch, int phase)
{
    CCScriptEventListenersForEvent *listeners = getListeners(pNode, (phase == NODE_TOUCH_CAPTURING_PHASE) ? NODE_TOUCH_CAPTURE_EVENT : NODE_TOUCH_EVENT);
    if (!listeners) return 1;
    
    _stack->clean();
    LuaValueDict event;
    switch (eventType)
    {
        case CCTOUCHBEGAN:
            event["name"] = LuaValue::stringValue("began");
            break;
            
        case CCTOUCHMOVED:
            event["name"] = LuaValue::stringValue("moved");
            break;
            
        case CCTOUCHENDED:
            event["name"] = LuaValue::stringValue("ended");
            break;
            
        case CCTOUCHCANCELLED:
            event["name"] = LuaValue::stringValue("cancelled");
            break;
            
        default:
            CCAssert(false, "INVALID touch event");
            return 0;
    }
    
    event["mode"] = LuaValue::intValue((int)Touch::DispatchMode::ONE_BY_ONE);
    switch (phase)
    {
        case NODE_TOUCH_CAPTURING_PHASE:
            event["phase"] = LuaValue::stringValue("capturing");
            break;
            
        case NODE_TOUCH_TARGETING_PHASE:
            event["phase"] = LuaValue::stringValue("targeting");
            break;
            
        default:
            event["phase"] = LuaValue::stringValue("unknown");
    }
    
    const Point pt = Director::getInstance()->convertToGL(pTouch->getLocationInView());
    event["x"] = LuaValue::floatValue(pt.x);
    event["y"] = LuaValue::floatValue(pt.y);
    const Point prev = Director::getInstance()->convertToGL(pTouch->getPreviousLocationInView());
    event["prevX"] = LuaValue::floatValue(prev.x);
    event["prevY"] = LuaValue::floatValue(prev.y);
    
    _stack->pushLuaValueDict(event);
    int ret = 1;
    bool flagNeedClean = false;
    for (auto it=listeners->begin(); it!=listeners->end(); ++it)
    {
        if ((*it)->removed) {
            flagNeedClean = true;
            continue;
        }
        
        if (eventType == CCTOUCHBEGAN)
        {
            // enable listener when touch began
            (*it)->enabled = true;
        }
        
        if ((*it)->enabled)
        {
            _stack->copyValue(1);
            int listenerRet = _stack->executeFunctionByHandler((*it)->listener, 1);
            if (listenerRet == 0)
            {
                if (phase == NODE_TOUCH_CAPTURING_PHASE && (eventType == CCTOUCHBEGAN || eventType == CCTOUCHMOVED))
                {
                    ret = 0;
                }
                else if (phase == NODE_TOUCH_TARGETING_PHASE && eventType == CCTOUCHBEGAN)
                {
                    // if listener return false when touch began, disable this listener
                    (*it)->enabled = false;
                    ret = 0;
                }
            }
            _stack->settop(1);
        }
    }
    
    cleanListeners(listeners, pNode, flagNeedClean);
    
    //CCLOG("executeNodeTouchEvent %p, ret = %d, event = %d, phase = %d", pNode, ret, eventType, phase);
    _stack->clean();
    
    return ret;
}
コード例 #19
0
void NEWSkeletonAnimation::setStartListener (spTrackEntry* entry, StartListener listener) {
	getListeners(entry)->startListener = listener;
}
コード例 #20
0
void SkeletonAnimation::setTrackCompleteListener (spTrackEntry* entry, const CompleteListener& listener) {
	getListeners(entry)->completeListener = listener;
}
コード例 #21
0
void SkeletonAnimation::setEventListener (spTrackEntry* entry, spine::EventListener listener) {
	getListeners(entry)->eventListener = listener;
}
コード例 #22
0
void SkeletonAnimation::setEndListener (spTrackEntry* entry, EndListener listener) {
	getListeners(entry)->endListener = listener;
}
コード例 #23
0
ファイル: ExecuteStage.cpp プロジェクト: alex-t/llvm
void ExecuteStage::notifyResourceAvailable(const ResourceRef &RR) const {
  LLVM_DEBUG(dbgs() << "[E] Resource Available: [" << RR.first << '.'
                    << RR.second << "]\n");
  for (HWEventListener *Listener : getListeners())
    Listener->onResourceAvailable(RR);
}
コード例 #24
0
void NEWSkeletonAnimation::setCompleteListener (spTrackEntry* entry, CompleteListener listener) {
	getListeners(entry)->completeListener = listener;
}
コード例 #25
0
int LuaEngine::executeNodeTouchesEvent(Node* pNode, int eventType, const std::vector<Touch*>& touches, int phase)
{
    CCScriptEventListenersForEvent *listeners = getListeners(pNode, phase == NODE_TOUCH_CAPTURING_PHASE ? NODE_TOUCH_CAPTURE_EVENT : NODE_TOUCH_EVENT);
    if (!listeners) return 1;
    
    _stack->clean();
    LuaValueDict event;
    switch (eventType)
    {
        case CCTOUCHBEGAN:
            event["name"] = LuaValue::stringValue("began");
            break;
            
        case CCTOUCHMOVED:
            event["name"] = LuaValue::stringValue("moved");
            break;
            
        case CCTOUCHENDED:
            event["name"] = LuaValue::stringValue("ended");
            break;
            
        case CCTOUCHCANCELLED:
            event["name"] = LuaValue::stringValue("cancelled");
            break;
            
        case CCTOUCHADDED:
            event["name"] = LuaValue::stringValue("added");
            break;
            
        case CCTOUCHREMOVED:
            event["name"] = LuaValue::stringValue("removed");
            break;
            
        default:
            return 0;
    }
    
    event["mode"] = LuaValue::intValue((int)Touch::DispatchMode::ALL_AT_ONCE);
    switch (phase)
    {
        case NODE_TOUCH_CAPTURING_PHASE:
            event["phase"] = LuaValue::stringValue("capturing");
            break;
            
        case NODE_TOUCH_TARGETING_PHASE:
            event["phase"] = LuaValue::stringValue("targeting");
            break;
            
        default:
            event["phase"] = LuaValue::stringValue("unknown");
    }
    
    LuaValueDict points;
    Director* pDirector = Director::getInstance();
    char touchId[16];
    for (auto touchIt = touches.begin(); touchIt != touches.end(); ++touchIt)
    {
        LuaValueDict point;
        Touch* pTouch = (Touch*)*touchIt;
        sprintf(touchId, "%d", pTouch->getID());
        point["id"] = LuaValue::stringValue(touchId);
        
        const Point pt = pDirector->convertToGL(pTouch->getLocationInView());
        point["x"] = LuaValue::floatValue(pt.x);
        point["y"] = LuaValue::floatValue(pt.y);
        const Point prev = pDirector->convertToGL(pTouch->getPreviousLocationInView());
        point["prevX"] = LuaValue::floatValue(prev.x);
        point["prevY"] = LuaValue::floatValue(prev.y);
        
        points[touchId] = LuaValue::dictValue(point);
    }
    event["points"] = LuaValue::dictValue(points);
    _stack->pushLuaValueDict(event);
    
    bool flagNeedClean = false;
    for (auto it=listeners->begin(); it!=listeners->end(); ++it)
    {
        if ((*it)->removed) {
            flagNeedClean = true;
            continue;
        }
        
        _stack->copyValue(1);
        _stack->executeFunctionByHandler((*it)->listener, 1);
        _stack->settop(1);
    }
    
    cleanListeners(listeners, pNode, flagNeedClean);
    
    _stack->clean();
    
    return 1;
}
コード例 #26
0
void EventDispatcher::dispatchTouchEvent(EventTouch* event)
{
    sortEventListeners(EventListenerTouchOneByOne::LISTENER_ID);
    sortEventListeners(EventListenerTouchAllAtOnce::LISTENER_ID);
    
    auto oneByOneListeners = getListeners(EventListenerTouchOneByOne::LISTENER_ID);
    auto allAtOnceListeners = getListeners(EventListenerTouchAllAtOnce::LISTENER_ID);
    
    // If there aren't any touch listeners, return directly.
    if (nullptr == oneByOneListeners && nullptr == allAtOnceListeners)
        return;
    
    bool isNeedsMutableSet = (oneByOneListeners && allAtOnceListeners);
    
    const std::vector<Touch*>& originalTouches = event->getTouches();
    std::vector<Touch*> mutableTouches(originalTouches.size());
    std::copy(originalTouches.begin(), originalTouches.end(), mutableTouches.begin());

    //
    // process the target handlers 1st
    //
    if (oneByOneListeners)
    {
        auto mutableTouchesIter = mutableTouches.begin();
        auto touchesIter = originalTouches.begin();
        
        for (; touchesIter != originalTouches.end(); ++touchesIter)
        {
            bool isSwallowed = false;

            auto onTouchEvent = [&](EventListener* l) -> bool { // Return true to break
                EventListenerTouchOneByOne* listener = static_cast<EventListenerTouchOneByOne*>(l);
                
                // Skip if the listener was removed.
                if (!listener->_isRegistered)
                    return false;
             
                event->setCurrentTarget(listener->_node);
                
                bool isClaimed = false;
                std::vector<Touch*>::iterator removedIter;
                
                EventTouch::EventCode eventCode = event->getEventCode();
                
                if (eventCode == EventTouch::EventCode::BEGAN)
                {
                    if (listener->onTouchBegan)
                    {
                        isClaimed = listener->onTouchBegan(*touchesIter, event);
                        if (isClaimed && listener->_isRegistered)
                        {
                            listener->_claimedTouches.push_back(*touchesIter);
                        }
                    }
                }
                else if (listener->_claimedTouches.size() > 0
                         && ((removedIter = std::find(listener->_claimedTouches.begin(), listener->_claimedTouches.end(), *touchesIter)) != listener->_claimedTouches.end()))
                {
                    isClaimed = true;
                    
                    switch (eventCode)
                    {
                        case EventTouch::EventCode::MOVED:
                            if (listener->onTouchMoved)
                            {
                                listener->onTouchMoved(*touchesIter, event);
                            }
                            break;
                        case EventTouch::EventCode::ENDED:
                            if (listener->onTouchEnded)
                            {
                                listener->onTouchEnded(*touchesIter, event);
                            }
                            if (listener->_isRegistered)
                            {
                                listener->_claimedTouches.erase(removedIter);
                            }
                            break;
                        case EventTouch::EventCode::CANCELLED:
                            if (listener->onTouchCancelled)
                            {
                                listener->onTouchCancelled(*touchesIter, event);
                            }
                            if (listener->_isRegistered)
                            {
                                listener->_claimedTouches.erase(removedIter);
                            }
                            break;
                        default:
                            CCASSERT(false, "The eventcode is invalid.");
                            break;
                    }
                }
                
                // If the event was stopped, return directly.
                if (event->isStopped())
                {
                    updateListeners(event);
                    return true;
                }
                
                CCASSERT((*touchesIter)->getID() == (*mutableTouchesIter)->getID(),
                         "touchesIter ID should be equal to mutableTouchesIter's ID.");
                
                if (isClaimed && listener->_isRegistered && listener->_needSwallow)
                {
                    if (isNeedsMutableSet)
                    {
                        mutableTouchesIter = mutableTouches.erase(mutableTouchesIter);
                        isSwallowed = true;
                    }
                    return true;
                }
                
                return false;
            };
            
            //
            dispatchTouchEventToListeners(oneByOneListeners, onTouchEvent);
            if (event->isStopped())
            {
                return;
            }
            
            if (!isSwallowed)
                ++mutableTouchesIter;
        }
    }
    
    //
    // process standard handlers 2nd
    //
    if (allAtOnceListeners && mutableTouches.size() > 0)
    {
        
        auto onTouchesEvent = [&](EventListener* l) -> bool{
            EventListenerTouchAllAtOnce* listener = static_cast<EventListenerTouchAllAtOnce*>(l);
            // Skip if the listener was removed.
            if (!listener->_isRegistered)
                return false;
            
            event->setCurrentTarget(listener->_node);
            
            switch (event->getEventCode())
            {
                case EventTouch::EventCode::BEGAN:
                    if (listener->onTouchesBegan)
                    {
                        listener->onTouchesBegan(mutableTouches, event);
                    }
                    break;
                case EventTouch::EventCode::MOVED:
                    if (listener->onTouchesMoved)
                    {
                        listener->onTouchesMoved(mutableTouches, event);
                    }
                    break;
                case EventTouch::EventCode::ENDED:
                    if (listener->onTouchesEnded)
                    {
                        listener->onTouchesEnded(mutableTouches, event);
                    }
                    break;
                case EventTouch::EventCode::CANCELLED:
                    if (listener->onTouchesCancelled)
                    {
                        listener->onTouchesCancelled(mutableTouches, event);
                    }
                    break;
                default:
                    CCASSERT(false, "The eventcode is invalid.");
                    break;
            }
            
            // If the event was stopped, return directly.
            if (event->isStopped())
            {
                updateListeners(event);
                return true;
            }
            
            return false;
        };
        
        dispatchTouchEventToListeners(allAtOnceListeners, onTouchesEvent);
        if (event->isStopped())
        {
            return;
        }
    }
    
    updateListeners(event);
}
コード例 #27
0
void SkeletonAnimation::setTrackStartListener (spTrackEntry* entry, const StartListener& listener) {
	getListeners(entry)->startListener = listener;
}
コード例 #28
0
void NotifyingForecastParser::parseAttribute(const ForecastAttribute& attribute,
		json_object* const & pValue)
{
	switch (attribute)
	{
	case ForecastAttribute::ALERTS:
	{
		alertsParser.parse(pValue);
		break;
	}
	case ForecastAttribute::CURRENTLY:
	{
		synchronicDataPointParser.parse(pValue);
		break;
	}
	case ForecastAttribute::DAILY:
	{
		// TODO: Implement parsing of "daily" data points
		break;
	}
	case ForecastAttribute::FLAGS:
	{
		flagParser.parse(pValue);
		break;
	}
	case ForecastAttribute::HOURLY:
	{
		// TODO: Implement parsing of "hourly" data points
		break;
	}
	case ForecastAttribute::LATITUDE:
	{
		const double latitude(json_object_get_double(pValue));
		for (listeners::ForecastDetailsListener* const & pListener : getListeners())
		{
			pListener->notifyLatitude(latitude);
		}
		break;
	}
	case ForecastAttribute::LONGITUDE:
	{
		const double longitude(json_object_get_double(pValue));
		for (listeners::ForecastDetailsListener* const & pListener : getListeners())
		{
			pListener->notifyLongitude(longitude);
		}
		break;
	}
	case ForecastAttribute::MINUTELY:
	{
		// TODO: Implement parsing of "minutely" data points
		break;
	}
	case ForecastAttribute::OFFSET:
	{
		const signed char offset(
				static_cast<signed char>(json_object_get_int64(pValue)));
		for (listeners::ForecastDetailsListener* const & pListener : getListeners())
		{
			pListener->notifyOffset(offset);
		}
		break;
	}
	case ForecastAttribute::TIMEZONE:
	{
		const std::string timezone(json_object_get_string(pValue));
		for (listeners::ForecastDetailsListener* const & pListener : getListeners())
		{
			pListener->notifyTimezone(timezone);
		}
		break;
	}
	default:
	{
		throw std::logic_error(
				createUndefinedAttributeErrorMessage(ForecastAttribute_NAME,
						attribute));
		break;
	}
	}
}
コード例 #29
0
void SkeletonAnimation::setTrackEventListener (spTrackEntry* entry, const EventListener& listener) {
	getListeners(entry)->eventListener = listener;
}
void
NokiaMaemoLocationInterfaceImpl::lbsCallback()
{
   m_receivedGPSPosition = false;
   wf_int statusCode = OK;
   nav2log << "Entered lbsCallback" << endl;
   if (!m_device) {
      nav2log << "GPSDevice is null" << endl;
      return;
   }
   nav2log << "lbsCallback: GPSMode [ "
        << m_device->fix->mode << " ]" << endl;
   switch (m_device->fix->mode) {
   case 2: //LOCATION_GPS_DEVICE_MODE_2D
      nav2log << "mode = LOCATION_GPS_DEVICE_MODE_2D" << endl;
   case 3: //LOCATION_GPS_DEVICE_MODE_3D
      nav2log << "mode = LOCATION_GPS_DEVICE_MODE_3D" << endl;
      if (m_needSendStartedCallback) {
         nav2log << "first callback since lbs started" << endl;
         // This is the first callback since the lbs was started,
         // we need to call startedLbs for the listeners.
         const ListenerCont& listeners = getListeners();
         for (ListenerCont::iterator it = listeners.begin(); 
            it != listeners.end(); ++it) {
            (*it)->startedLbs();
         }
         m_needSendStartedCallback = false;
      }
      if ( (m_device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) || 
           (m_device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET) ) {
         nav2log << "LATLONG or ALTITUDE is set, time="
                 << (double)m_device->fix->time << endl;
         m_receivedGPSPosition = true;
         // Print the gps data to nav2log, for debug purposes
         printGpsData();

         // Write the nmea data to the bt channel
         writeNmeaData();
      } else {
         nav2log << "lbsCallback: Gps state not available (no positions)."
              << endl;
      } 
      break;
   default:
      break;
   }

   // Slightly hacky but I'm testing if we have changed cell id
   if (!m_receivedGPSPosition) {
      checkAndSendCellIDRequest();
   }

   if (statusCode != OK) {
      const ListenerCont& listeners = getListeners();
      for (ListenerCont::iterator it = listeners.begin(); 
         it != listeners.end(); ++it) {
         // Report the error to the listeners.
         (*it)->error(AsynchronousStatus(RequestID::INVALID_REQUEST_ID,
                                         statusCode,
                                         "", ""));
      }
   }
}