bool SNotifyCenter::RegisterEventMap( const ISlotFunctor &slot ) { for(SPOSITION pos = m_evtHandlerMap.GetHeadPosition();pos;) { ISlotFunctor * pSlot = m_evtHandlerMap.GetNext(pos); if(pSlot->Equal(slot)) return false; } m_evtHandlerMap.AddTail(slot.Clone()); return true; }
bool SNotifyCenter::UnregisterEventMap( const ISlotFunctor &slot ) { for(SPOSITION pos = m_evtHandlerMap.GetHeadPosition();pos;) { SPOSITION posPrev = pos; ISlotFunctor * pSlot = m_evtHandlerMap.GetNext(pos); if(pSlot->Equal(slot)) { m_evtHandlerMap.RemoveAt(posPrev); delete pSlot; return true; } } return false; }
virtual bool Equal(const ISlotFunctor & sour)const { if(sour.GetSlotType()!=GetSlotType()) return false; const LuaFunctionSlot *psour=static_cast<const LuaFunctionSlot*>(&sour); SASSERT(psour); return psour->m_luaFun==m_luaFun && psour->m_pLuaState==m_pLuaState; }
////////////////////////////////////////////////////////////////////////// // SEvent bool SEvent::subscribe( const ISlotFunctor& slot ) { if(findSlotFunctor(slot) != -1) return false; m_evtSlots.Add(slot.Clone()); return true; }