/** * Returns number dropped. Check to confirm that all went. * Concern in doing this is that we don't want to mess up the iterators. * Also need to be sure that no one else is using the iterators. */ bool Element::dropVec( int msg, const vector< const ConnTainer* >& vec ) { if ( vec.size() == 0 ) return 0; if ( !validMsg( msg ) ) return 0; if ( msg >= 0 ) { Msg* m = varMsg( msg ); assert ( m != 0 ); vector< const ConnTainer* >::const_iterator i; for ( i = vec.begin(); i != vec.end(); i++ ) { bool ret = m->drop( ( *i )->e1(), *i ); assert( ret ); } return 1; } else { vector< ConnTainer* >* ctv = getDest( msg ); assert ( ctv->size() >= vec.size() ); vector< const ConnTainer* >::const_iterator i; for ( i = vec.begin(); i != vec.end(); i++ ) { int otherMsg = ( *i )->msg1(); Element* otherElement = ( *i )->e1(); Msg* om = otherElement->varMsg( otherMsg ); assert( om ); bool ret = om->drop( otherElement, *i ); assert( ret ); } return 1; } return 0; }
bool CPhonographCylinder::UseWithOtherMsg(CUseWithOtherMsg *msg) { CPhonograph *phonograph = static_cast<CPhonograph *>(msg->_other); if (phonograph) { CSetVarMsg varMsg("m_RecordStatus", 1); return true; } else { return CCarry::UseWithOtherMsg(msg); } }
bool Element::drop( int msg, unsigned int doomed ) { if ( !validMsg( msg ) ) return 0; if ( msg >= 0 ) { return varMsg( msg )->drop( this, doomed ); } else { cout << "Not sure what to do here, as the lookup is non-sequential\n"; vector< ConnTainer* >* ctv = getDest( msg ); if ( doomed >= ctv->size() ) return 0; } return 0; }
bool Element::dropAll( int msg ) { if ( !validMsg( msg ) ) return 0; if ( msg >= 0 ) { varMsg( msg )->dropAll( this ); return 1; } else { vector< ConnTainer* >* ctv = getDest( msg ); vector< ConnTainer* >::iterator k; for ( k = ctv->begin(); k != ctv->end(); k++ ) { bool ret = Msg::innerDrop( ( *k )->e1(), ( *k )->msg1(), *k ); if ( ret ) delete ( *k ); else cout << "Error: Element::dropAll(): innerDrop failed\n"; *k = 0; } ctv->resize( 0 ); // I could erase the entry in the dest_ map too. Later. return 1; } }