本文整理汇总了C++中ListenerList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ListenerList::empty方法的具体用法?C++ ListenerList::empty怎么用?C++ ListenerList::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListenerList
的用法示例。
在下文中一共展示了ListenerList::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: broadcastEvent
void EventManager::broadcastEvent(const Event &event)
{
do
{
if (mListenerMap.empty())
break;
EventID eid = event.getEventID();
ListenerList *listenerList = NULL;
ListenerMap::iterator mapIter = mListenerMap.find(eid);
if (mapIter == mListenerMap.end())
break;
listenerList = mapIter->second;
if (listenerList->empty())
break;
ListenerList::iterator listIter;
for (listIter = listenerList->begin(); listIter != listenerList->end(); ++listIter)
{
(*listIter)->handleEvent(event);
}
} while (0);
}
示例2: ev
//.........这里部分代码省略.........
iter != currentList->end(); ++iter) {
SILOG(task,insane," \t"
"[" << (i==MIDDLE?'=':i<MIDDLE?'*':'/') << "] " <<
(*iter).second);
}
}
typename SecondaryListenerMap::const_iterator secIter;
secIter = secondaryMap->begin();
while (secIter != secondaryMap->end()) {
SILOG(task,insane,"\tSec ID " << (*secIter).first << ":");
for (int i = 0; i < NUM_EVENTORDER; i++) {
ListenerList *currentList = &((*secIter).second->get(i));
for (typename ListenerList::const_iterator iter = currentList->begin();
iter != currentList->end(); ++iter) {
SILOG(task,insane," \t\t"
"[" << (i==MIDDLE?'=':i<MIDDLE?'*':'/') << "] " <<
(*iter).second);
}
}
++secIter;
}
++priIter;
}
SILOG(task,insane,"==== ---------------------------------- ====");
}
EventPtr *evTemp;
int numProcessed = 0;
while ((evTemp = processingList.next())!=NULL) {
EventPtr ev (*evTemp);
++numProcessed;
typename PrimaryListenerMap::iterator priIter =
mListeners.find(ev->getId().mPriId);
if (priIter == mListeners.end()) {
// FIXME: Should this ever happen?
SILOG(task,warning," >>>\tWARNING: No listeners for type " <<
"event type " << ev->getId().mPriId);
continue;
}
PartiallyOrderedListenerList *primaryLists =
&((*priIter).second->first);
SecondaryListenerMap *secondaryMap =
&((*priIter).second->second);
typename SecondaryListenerMap::iterator secIter;
secIter = secondaryMap->find(ev->getId().mSecId);
bool cancel = false;
EventHistory eventHistory=EVENT_UNHANDLED;
// Call once per event order.
for (int i = 0; i < NUM_EVENTORDER && cancel == false; i++) {
SILOG(task,debug," >>>\tFiring " << ev << ": " << ev->getId() <<
" [order " << i << "]");
ListenerList *currentList = &(primaryLists->get(i));
if (!currentList->empty())
eventHistory=EVENT_HANDLED;
if (callAllListeners(ev, currentList, forceCompletionBy)) {
cancel = cancel || true;
}
if (secIter != secondaryMap->end() &&
!(*secIter).second->get(i).empty()) {
currentList = &((*secIter).second->get(i));
if (!currentList->empty())
eventHistory=EVENT_HANDLED;
if (callAllListeners(ev, currentList, forceCompletionBy)) {
cancel = cancel || true;
}
// all listeners may have returned false.
// cleanUp(secondaryMap, secIter);
// secIter = secondaryMap->find(ev->getId().mSecId);
}
if (cancel) {
SILOG(task,debug," >>>\tCancelling " << ev->getId());
}
}
if (secIter != secondaryMap->end()) {
cleanUp(secondaryMap, secIter);
}
if (cancel) eventHistory=EVENT_CANCELED;
(*ev)(eventHistory);
SILOG(task,debug," >>>\tFinished " << ev->getId());
}
if (mEventCV) {
mPendingEvents -= numProcessed;
}
AbsTime finishTime = AbsTime::now();
SILOG(task,insane, "**** Done processing events this round. " <<
"Took " << (finishTime-startTime).toSeconds() <<
" seconds.");
}