本文整理汇总了C++中ListenerList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ListenerList::push_back方法的具体用法?C++ ListenerList::push_back怎么用?C++ ListenerList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListenerList
的用法示例。
在下文中一共展示了ListenerList::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetListenerList
//
// Manager::getListenerList - Chapter 10, page 300
//
// Get the list of listeners associated with a specific event
// type
//
ListenerList Manager::GetListenerList( TypeId const & eventType ) const
{
// invalid event type, so sad
if ( ! VValidateType( eventType ) )
return ListenerList();
EventListenerMap::const_iterator itListeners = m_registry.find( eventType.Value() );
// no listerners currently for this event type, so sad
if ( itListeners == m_registry.end() )
return ListenerList();
EventListenerTable const & table = itListeners->second;
// there was, but is not now, any listerners currently for
// this event type, so sad
if ( table.size() == 0 )
return ListenerList();
ListenerList result;
result.reserve( table.size() );
for ( EventListenerTable::const_iterator it = table.begin(), end = table.end();
it != end;
it++ )
{
result.push_back( *it );
}
return result;
}
示例2: addListener
void EventManager::addListener(GameObject *listener, EventID eventID)
{
ListenerMap::iterator mapIter = mListenerMap.find(eventID);
// listener list for eventID is empty, need create first
if (mapIter == mListenerMap.end())
{
ListenerList *newList = new ListenerList;
mListenerMap.insert(ListenerMap::value_type(eventID, newList));
newList->push_back(listener);
}
else
{
(mapIter->second)->push_back(listener);
}
}