Esempio n. 1
0
int FilteredConsumer::detach( Filter &filter )
{
    if ( filter.is_valid( ) )
    {
        Service *it = new Service( *first );
        while ( it->is_valid( ) && it->get_service( ) != filter.get_service( ) )
        {
            Service *consumer = it->consumer( );
            delete it;
            it = consumer;
        }
        if ( it->get_service( ) == filter.get_service( ) )
        {
            Service *producer = it->producer( );
            Service *consumer = it->consumer( );
            consumer->connect_producer( *producer );
            Service dummy( NULL );
            it->connect_producer( dummy );
            if ( first->get_service( ) == it->get_service( ) )
            {
                delete first;
                first = new Service( *consumer );
            }
        }
        delete it;
    }
    return 0;
}
Esempio n. 2
0
int FilteredProducer::detach( Filter &filter )
{
	if ( filter.is_valid( ) )
	{
		Service *it = new Service( *last );
		while ( it->is_valid( ) && it->get_service( ) != filter.get_service( ) )
		{
			Service *producer = it->producer( );
			delete it;
			it = producer;
		}
		if ( it->get_service( ) == filter.get_service( ) )
		{
			Service *producer = it->producer( );
			Service *consumer = it->consumer( );
			if ( consumer->is_valid( ) )
				consumer->connect_producer( *producer );
			Profile p( get_profile() );
			Producer dummy( p, "colour" );
			dummy.connect_producer( *it );
			if ( last->get_service( ) == it->get_service( ) )
			{
				delete last;
				last = new Service( *producer );
			}
		}
		delete it;
	}
	return 0;
}