bool MsgRouter::endBroadcast( const Receiver_p& _pReceiver ) { Receiver * pReceiver = _pReceiver.rawPtr(); Route * p = m_broadcasts.first(); while( p ) { if( p->receiver() == pReceiver ) { delete p; return true; } p = p->next(); } return false; }
int MsgRouter::deleteRoutesTo( const Receiver_p& _pReceiver ) { Receiver * pReceiver = _pReceiver.rawPtr(); int nDeleted = 0; // Delete from source routes for( auto it = m_sourceRoutes.begin() ; it != m_sourceRoutes.end() ; it++ ) { Route * p = it->second.first(); while( p ) { if( p->receiver() == pReceiver ) { Route * pNext = p->next(); delete p; // Receiver is dead, delete route. nDeleted++; p = pNext; } else p = p->next(); } } // Delete from type routes for( auto it = m_typeRoutes.begin() ; it != m_typeRoutes.end() ; it++ ) { Route * p = it->second.first(); while( p ) { if( p->receiver() == pReceiver ) { Route * pNext = p->next(); delete p; // Receiver is dead, delete route. nDeleted++; p = pNext; } else p = p->next(); } } return nDeleted; }
bool MsgRouter::broadcastTo( const Receiver_p& pReceiver ) { Route * p = new Route( pReceiver.rawPtr(), MsgType::Dummy ); m_broadcasts.pushBack( p ); return true; }
RouteId MsgRouter::addRoute( MsgType msgType, const Receiver_p& pReceiver ) { Route * p = new Route( pReceiver.rawPtr(), MsgType::Dummy ); return _addRoute( msgType, p ); }
RouteId MsgRouter::addRoute( const Object_p& pSource, MsgType filter, const Receiver_p& pReceiver ) { Route * p = new Route( pReceiver.rawPtr(), filter ); return _addRoute( pSource, p ); }
WgRouteId MsgRouter::addRoute( const MsgFilter& filter, MsgType msgType, const Receiver_p& pReceiver ) { Route * p = new Route( filter, pReceiver.rawPtr() ); return _addRoute( msgType, p ); }
WgRouteId MsgRouter::addRoute( const MsgFilter& filter, const Object_p& pSource, const Receiver_p& pReceiver ) { Route * p = new Route( filter, pReceiver.rawPtr() ); return _addRoute( pSource, p ); }
bool MsgRouter::broadcastTo( const MsgFilter& filter, const Receiver_p& pReceiver ) { Route * p = new Route( filter, pReceiver.rawPtr() ); m_broadcasts.pushBack( p ); return true; }