当前位置: 首页>>代码示例>>C++>>正文


C++ ListenerList类代码示例

本文整理汇总了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));
}
开发者ID:l1calo,项目名称:gaudi,代码行数:38,代码来源:IncidentSvc.cpp

示例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;
	}
开发者ID:entityhat,项目名称:style,代码行数:38,代码来源:Event.cpp

示例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);
}
开发者ID:master-g,项目名称:hourglass,代码行数:26,代码来源:HGEventManager.cpp

示例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());
	}
开发者ID:Ali-il,项目名称:gamekit,代码行数:35,代码来源:OgreCamera.cpp

示例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);
}
开发者ID:master-g,项目名称:hourglass,代码行数:27,代码来源:HGEventManager.cpp

示例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();
}
开发者ID:noriter,项目名称:nit,代码行数:29,代码来源:RefCounted.cpp

示例7:

    //-----------------------------------------------------------------------
    Camera::~Camera()
    {
		ListenerList listenersCopy = mListeners;
		for (ListenerList::iterator i = listenersCopy.begin(); i != listenersCopy.end(); ++i)
		{
			(*i)->cameraDestroyed(this);
		}
    }
开发者ID:Ali-il,项目名称:gamekit,代码行数:9,代码来源:OgreCamera.cpp

示例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;
  }
}
开发者ID:OMARTINEZ210,项目名称:server,代码行数:8,代码来源:script_environment.cpp

示例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;
}
开发者ID:OMARTINEZ210,项目名称:server,代码行数:13,代码来源:script_environment.cpp

示例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();
}
开发者ID:master-g,项目名称:hourglass,代码行数:15,代码来源:HGEventManager.cpp

示例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);
        }
    }
开发者ID:Ketzer2002,项目名称:meridian59-engine,代码行数:16,代码来源:OgreViewport.cpp

示例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);
    }
}
开发者ID:master-g,项目名称:hourglass,代码行数:16,代码来源:HGEventManager.cpp

示例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);
        }
    }
开发者ID:MattMulhern,项目名称:OpenMamaCassandra,代码行数:18,代码来源:MamdaMultiSecurityManager.cpp

示例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);
}
开发者ID:master-g,项目名称:hourglass,代码行数:19,代码来源:HGEventManager.cpp

示例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);
		}
	}
开发者ID:523793658,项目名称:directX,代码行数:24,代码来源:Camera.cpp


注:本文中的ListenerList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。