当前位置: 首页>>代码示例>>C++>>正文


C++ ListenerVector类代码示例

本文整理汇总了C++中ListenerVector的典型用法代码示例。如果您正苦于以下问题:C++ ListenerVector类的具体用法?C++ ListenerVector怎么用?C++ ListenerVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ListenerVector类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Event

void XMLHttpRequest::callReadyStateChangeListener()
{
    if (m_doc && m_doc->frame() && m_onReadyStateChangeListener) {
        RefPtr<Event> evt = new Event(readystatechangeEvent, true, true);
        evt->setTarget(this);
        evt->setCurrentTarget(this);
        m_onReadyStateChangeListener->handleEvent(evt.get(), false);
    }
    
    if (m_doc && m_doc->frame() && m_state == Loaded) {
        if (m_onLoadListener) {
            RefPtr<Event> evt = new Event(loadEvent, true, true);
            evt->setTarget(this);
            evt->setCurrentTarget(this);
            m_onLoadListener->handleEvent(evt.get(), false);
        }
        
        ListenerVector listenersCopy = m_eventListeners.get(loadEvent.impl());
        for (ListenerVector::const_iterator listenerIter = listenersCopy.begin(); listenerIter != listenersCopy.end(); ++listenerIter) {
            RefPtr<Event> evt = new Event(loadEvent, true, true);
            evt->setTarget(this);
            evt->setCurrentTarget(this);
            listenerIter->get()->handleEvent(evt.get(), false);
        }
    }
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:26,代码来源:xmlhttprequest.cpp

示例2: TouchEvent

void EventManager::TouchEvent( const int eventId, Producer* producer, void *data ) {
  ListenerVector listenersListProc;
  for( auto& listener: this->listenersList ) {
    if( listener.eventId == eventId ) {
      listenersListProc.push_back( listener );
    }
  }

  for( auto& listener: listenersListProc ) {
    listener.proc( listener.listener, producer, eventId, data );
  }
}//TouchEvent
开发者ID:KoMaTo3,项目名称:Biominator,代码行数:12,代码来源:eventmanager.cpp

示例3: dispatchEvent

bool MessagePort::dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec)
{
    if (!event || event->type().isEmpty()) {
        ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR;
        return true;
    }
    
    ListenerVector listenersCopy = m_eventListeners.get(event->type());
    for (ListenerVector::const_iterator listenerIter = listenersCopy.begin(); listenerIter != listenersCopy.end(); ++listenerIter) {
        event->setTarget(this);
        event->setCurrentTarget(this);
        listenerIter->get()->handleEvent(event.get(), false);
    }
    
    return !event->defaultPrevented();
}
开发者ID:boyliang,项目名称:ComponentSuperAccessor,代码行数:16,代码来源:MessagePort.cpp

示例4: dispatchEvent

bool XMLHttpRequest::dispatchEvent(PassRefPtr<Event> evt, ExceptionCode& ec, bool /*tempEvent*/)
{
    // FIXME: check for other error conditions enumerated in the spec.
    if (evt->type().isEmpty()) {
        ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR;
        return true;
    }

    ListenerVector listenersCopy = m_eventListeners.get(evt->type().impl());
    for (ListenerVector::const_iterator listenerIter = listenersCopy.begin(); listenerIter != listenersCopy.end(); ++listenerIter) {
        evt->setTarget(this);
        evt->setCurrentTarget(this);
        listenerIter->get()->handleEvent(evt.get(), false);
    }

    return !evt->defaultPrevented();
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:17,代码来源:XMLHttpRequest.cpp

示例5: addEventListener

void XMLHttpRequest::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> eventListener, bool)
{
    EventListenersMap::iterator iter = m_eventListeners.find(eventType.impl());
    if (iter == m_eventListeners.end()) {
        ListenerVector listeners;
        listeners.append(eventListener);
        m_eventListeners.add(eventType.impl(), listeners);
    } else {
        ListenerVector& listeners = iter->second;
        for (ListenerVector::iterator listenerIter = listeners.begin(); listenerIter != listeners.end(); ++listenerIter)
            if (*listenerIter == eventListener)
                return;
        
        listeners.append(eventListener);
        m_eventListeners.add(eventType.impl(), listeners);
    }
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:17,代码来源:XMLHttpRequest.cpp

示例6: addEventListener

void WorkerContext::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> eventListener, bool)
{
    EventListenersMap::iterator iter = m_eventListeners.find(eventType);
    if (iter == m_eventListeners.end()) {
        ListenerVector listeners;
        listeners.append(eventListener);
        m_eventListeners.add(eventType, listeners);
    } else {
        ListenerVector& listeners = iter->second;
        for (ListenerVector::iterator listenerIter = listeners.begin(); listenerIter != listeners.end(); ++listenerIter) {
            if (*listenerIter == eventListener)
                return;
        }
        
        listeners.append(eventListener);
        m_eventListeners.add(eventType, listeners);
    }    
}
开发者ID:halfkiss,项目名称:ComponentSuperAccessor,代码行数:18,代码来源:WorkerContext.cpp

示例7: assert

		//*************************************************************//
		// SEND EVENT NOW
		bool EventManager::SendEventNow( const Event* pEvent, const void* destination )
		{
			// Sanity-check the wrapper's status
			assert( m_eStatus == E_INITIALIZED && "EventManager::SendMessageNow - wrapper has not been initialized" );
			if( m_eStatus != E_INITIALIZED )
				return false;
			
			// Sanity-check the parameter
			assert( pEvent != nullptr && "EventManager::SendEventNow - event parameter cannot be null" );
			if( pEvent == nullptr )
				return false;

				
			// Hold a local ref (for readability)
			const EventID& id = pEvent->GetEventID();


			// Send the event to all registered listeners to process
			// (does not deallocate the event)
			LMapRange range = m_mListeners.equal_range( id );
			if( range.first != range.second )
			{
				// Copy the intended listeners
				ListenerVector vec;

				// All listeners?
				if( destination == nullptr )
				{
					for( LMapIter iter = range.first; iter != range.second; ++iter )
						vec.push_back( iter->second );
				}
				else 
				{
					// One intended listener (which may not exist)
					for( LMapIter iter = range.first; iter != range.second; ++iter )
					{
						if( iter->second->GetChild() == destination )
						{
							vec.push_back( iter->second );
							break;
						}
					}
				}


				// Send the event to the current listeners
				for( unsigned int i = 0; i < vec.size(); i++ )
				{
					// Has this listener been removed from the event?
					if( m_mUnlisteners.empty() == false )
					{
						LMapRange removed = m_mUnlisteners.equal_range( id );
						if( removed.first != removed.second )
						{
							LMapIter iter = std::find( removed.first, removed.second, LMapValue( id, vec[i] ) );
							if( iter != removed.second )
								continue;
						}
					}

					// Send event
					vec[ i ]->HandleEvent( pEvent );
				}
			}

			return true;
		}
开发者ID:DeVonFire27,项目名称:DTW_Desolate,代码行数:69,代码来源:SGD_EventManager.cpp

示例8: notify

   void notify(T func, A newA, B newB, C newC, D newD){
     for (int32 i=(int32)mListeners.size()-1;
          i>=0&&i<mListeners.size();
          --i) {
         ((&*mListeners[i])->*func)(newA,newB,newC,newD);
     }
 }
开发者ID:princeofcode,项目名称:sirikata,代码行数:7,代码来源:ListenerProvider.hpp

示例9: addListener

 /**
  *  This function adds a new listener to listen for notification
  *  This may be called during a notify call, but new functions will not be called until the next notification
  */
 virtual void addListener(ListenerPtr p) {
     if (mListeners.empty()) {
         mListeners.push_back(p);
         this->firstListenerAdded(p);
     }else if (mListeners.size()==1) {
         mListenerIndex[mListeners[0]]=0;
         mListenerIndex[p]=1;
         mListeners.push_back(p);
     }else {
         mListenerIndex[p]=mListeners.size();
         mListeners.push_back(p);
     }
     this->listenerAdded(p);
 }
开发者ID:princeofcode,项目名称:sirikata,代码行数:18,代码来源:ListenerProvider.hpp

示例10: removeListener

 /**
  *  This function removes a listener from listening for notification
  *  This may be called during a notify call on the currently notified listener only
  */
 virtual void removeListener(ListenerPtr p) {
     this->listenerRemoved(p);
     if (mListeners.size()>1) {
         typename ListenerMap::iterator where=mListenerIndex.find(p);
         assert(where!=mListenerIndex.end());
         if (where->second+1!=mListeners.size()) {
             mListenerIndex[mListeners.back()]=where->second;
             mListeners[where->second]=mListeners.back();
         }
         mListeners.resize(mListeners.size()-1);                
         mListenerIndex.erase(where);
     }else {
         this->lastListenerRemoved(p);
         assert(mListeners[0]==p);
         mListeners.resize(0);
         mListenerIndex=ListenerMap();
     }
 }
开发者ID:princeofcode,项目名称:sirikata,代码行数:22,代码来源:ListenerProvider.hpp


注:本文中的ListenerVector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。