本文整理汇总了C++中EventPtr::getSender方法的典型用法代码示例。如果您正苦于以下问题:C++ EventPtr::getSender方法的具体用法?C++ EventPtr::getSender怎么用?C++ EventPtr::getSender使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventPtr
的用法示例。
在下文中一共展示了EventPtr::getSender方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processEvents
bool EventManager::processEvents(Time max_process_time)
{
Time curr_time = g_app->getCurrentTime();
Time max_time = curr_time + max_process_time;
// swap active queues and clear the new queue after the swap
int queueToProcess = m_active_queue;
m_active_queue = (m_active_queue + 1) % EVENTMANAGER_NUM_QUEUES;
m_queues[m_active_queue].clear();
// Process the queue
while (!m_queues[queueToProcess].empty())
{
// pop the front of the queue
EventPtr event = m_queues[queueToProcess].front();
m_queues[queueToProcess].pop_front();
cout<<"Send event \""<<event->getName()<<"\""<<endl;
// find all the delegate functions registered for this event
auto findIt = m_event_listeners.find(typeid(*event));
if (findIt != m_event_listeners.end())
{
const EventListenerList& eventListeners = findIt->second;
// call each listener
for (auto it = eventListeners.begin(); it != eventListeners.end();++it)
{
EventListenerFunction event_function = (*it);
if (event_function.getOwner() != event->getSender())
event_function.execute(event);
}
}
// check to see if time ran out
curr_time = g_app->getCurrentTime();
if (curr_time >= max_time)
{
cout<<"EventLoop: Aborting event processing; time ran out. Already "<<(curr_time-max_time).asMilliseconds()<<"ms too long."<<endl;
break;
}
}
// If we couldn’t process all of the events, push the remaining events to
// the new active queue.
// Note: To preserve sequencing, go back-to-front, inserting them at the
// head of the active queue.
bool queueFlushed = (m_queues[queueToProcess].empty());
if (!queueFlushed)
{
while (!m_queues[queueToProcess].empty())
{
EventPtr event = m_queues[queueToProcess].back();
m_queues[queueToProcess].pop_back();
m_queues[m_active_queue].push_front(event);
}
}
return queueFlushed;
}