本文整理汇总了C++中ListenerList类的典型用法代码示例。如果您正苦于以下问题:C++ ListenerList类的具体用法?C++ ListenerList怎么用?C++ ListenerList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListenerList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
// ============================================================================
// Inherited IIncidentSvc overrides:
// ============================================================================
void IncidentSvc::addListener
( IIncidentListener* lis ,
const std::string& type ,
long prio, bool rethrow, bool singleShot)
{
boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);
std::string ltype;
if( type == "" ) ltype = "ALL";
else ltype = type;
// find if the type already exists
ListenerMap::iterator itMap = m_listenerMap.find( ltype );
if( itMap == m_listenerMap.end() ) {
// if not found, create and insert now a list of listeners
ListenerList* newlist = new ListenerList();
std::pair<ListenerMap::iterator, bool> p;
p = m_listenerMap.insert(ListenerMap::value_type(ltype, newlist));
if( p.second ) itMap = p.first;
}
ListenerList* llist = (*itMap).second;
// add Listener in the ListenerList according to the priority
ListenerList::iterator itlist;
for( itlist = llist->begin(); itlist != llist->end(); itlist++ ) {
if( (*itlist).priority < prio ) {
// We insert before the current position
break;
}
}
DEBMSG << "Adding [" << type << "] listener '" << getListenerName(lis)
<< "' with priority " << prio << endmsg;
llist->insert(itlist, Listener(lis, prio, rethrow, singleShot));
}
示例2: ListenerList
//
// 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;
}
示例3: 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);
}
示例4: OgreProfileBeginGPUEvent
//-----------------------------------------------------------------------
void Camera::_renderScene(Viewport *vp, bool includeOverlays)
{
OgreProfileBeginGPUEvent("Camera: " + getName());
//update the pixel display ratio
if (mProjType == Ogre::PT_PERSPECTIVE)
{
mPixelDisplayRatio = (2 * Ogre::Math::Tan(mFOVy * 0.5f)) / vp->getActualHeight();
}
else
{
mPixelDisplayRatio = (mTop - mBottom) / vp->getActualHeight();
}
//notify prerender scene
ListenerList listenersCopy = mListeners;
for (ListenerList::iterator i = listenersCopy.begin(); i != listenersCopy.end(); ++i)
{
(*i)->cameraPreRenderScene(this);
}
//render scene
mSceneMgr->_renderScene(this, vp, includeOverlays);
// Listener list may have change
listenersCopy = mListeners;
//notify postrender scene
for (ListenerList::iterator i = listenersCopy.begin(); i != listenersCopy.end(); ++i)
{
(*i)->cameraPostRenderScene(this);
}
OgreProfileEndGPUEvent("Camera: " + getName());
}
示例5: removeListener
void EventManager::removeListener(GameObject *listener)
{
do
{
if (mListenerMap.empty())
break;
ListenerMap::iterator mapIter = mListenerMap.begin();
for (; mapIter != mListenerMap.end(); ++mapIter)
{
ListenerList *list = mapIter->second;
if (list == NULL)
continue;
ListenerList::iterator listIter = list->begin();
for (; listIter != list->end(); ++listIter)
{
if (*listIter == listener)
{
list->erase(listIter);
break;
}
}
}
} while (0);
}
示例6: incRefCount
void WeakRef::_notifyDestroy()
{
incRefCount();
ListenerList* listeners = _listeners;
_listeners = NULL; // prevent removeListener mutate this
if (listeners)
{
for (ListenerList::iterator itr = listeners->begin(), end = listeners->end(); itr != end; ++itr)
{
(*itr)->onDestroy(_object);
}
delete listeners;
}
_object = NULL;
if (_listeners)
{
decRefCount();
NIT_THROW_FMT(EX_INVALID_STATE, "Can't add listener while destroying one");
return;
}
decRefCount();
}
示例7:
//-----------------------------------------------------------------------
Camera::~Camera()
{
ListenerList listenersCopy = mListeners;
for (ListenerList::iterator i = listenersCopy.begin(); i != listenersCopy.end(); ++i)
{
(*i)->cameraDestroyed(this);
}
}
示例8: cleanupUnusedListeners
void Environment::cleanupUnusedListeners(ListenerList& list)
{
for(ListenerList::iterator giter = list.begin(); giter != list.end();){
if((*giter)->isActive() == false){
giter = list.erase(giter);
} else ++giter;
}
}
示例9: stopListener
bool Environment::stopListener(ListenerList& list, uint32_t id)
{
for(ListenerList::iterator giter = list.begin(),
gend = list.end(); giter != gend;
++giter)
{
if((*giter)->getID() == id && (*giter)->isActive()){
(*giter)->deactivate();
return true;
}
}
return false;
}
示例10: removeListenerByEventID
void EventManager::removeListenerByEventID(EventID eventID)
{
if (mListenerMap.empty())
return;
ListenerMap::iterator mapIter = mListenerMap.find(eventID);
if (mapIter == mListenerMap.end())
return;
ListenerList *list = mapIter->second;
if (list == NULL)
return;
list->clear();
}
示例11:
//---------------------------------------------------------------------
Viewport::~Viewport()
{
ListenerList listenersCopy;
std::swap(mListeners, listenersCopy);
for (ListenerList::iterator i = listenersCopy.begin(); i != listenersCopy.end(); ++i)
{
(*i)->viewportDestroyed(this);
}
RenderSystem* rs = Root::getSingleton().getRenderSystem();
if ((rs) && (rs->_getViewport() == this))
{
rs->_setViewport(NULL);
}
}
示例12: 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);
}
}
示例13:
void MamdaMultiSecurityManager::MamdaMultiSecurityManagerImpl::forwardMsg (
ListenerList& listeners,
MamdaSubscription* subscription,
const MamaMsg& msg,
short msgType)
{
ListenerList::iterator end = listeners.end();
ListenerList::iterator i = listeners.begin();
for (; i != end; ++i)
{
MamdaMsgListener* listener = *i;
listener->onMsg (subscription,
msg,
msgType);
}
}
示例14: removeAllListeners
void EventManager::removeAllListeners()
{
do
{
if (mListenerMap.empty())
break;
ListenerMap::iterator mapIter = mListenerMap.begin();
for (; mapIter != mListenerMap.end(); ++mapIter)
{
ListenerList *list = mapIter->second;
if (list == NULL)
continue;
list->clear();
}
} while (0);
}
示例15: _renderScene
void Camera::_renderScene(Viewport *vp, BOOL includeOverlays)
{
if (mProjType == PT_PERSPECTIVE)
{
mPixelDisplayRatio = (2 * Math::Tan((Radian)(mFOVy * 0.5f))) / vp->getActualHeight();
}
else
{
mPixelDisplayRatio = (mTop - mBottom) / vp->getActualHeight();
}
ListenerList listenersCopy = mListeners;
for (ListenerList::iterator i = listenersCopy.begin(); i != listenersCopy.end(); ++i)
{
(*i)->cameraPreRenderScene(this);
}
mSceneMgr->renderScene(this, vp, includeOverlays);
listenersCopy = mListeners;
for (ListenerList::iterator i = listenersCopy.begin(); i != listenersCopy.end(); ++i)
{
(*i)->cameraPostRenderScene(this);
}
}