本文整理汇总了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);
}
}
}
示例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
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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();
}
}