void CompoundPlug::setInput( PlugPtr input ) { if( input.get() == getInput<Plug>() ) { return; } // unfortunately we have to duplicate the check in Plug::setInput() // ourselves as we delay calling Plug::setInput() until we've connected // the children, but need to do the check first. /// \todo I think there's a case for not having CompoundPlug at all, /// and having Plug have all its functionality. if( input && !acceptsInput( input ) ) { std::string what = boost::str( boost::format( "Plug \"%s\" rejects input \"%s\"." ) % fullName() % input->fullName() ); throw IECore::Exception( what ); } { // we use the plugInputChangedConnection to trigger calls to updateInputFromChildInputs() // when child inputs are changed by code elsewhere. it would be counterproductive for // us to call updateInputFromChildInputs() while we ourselves are changing those inputs, // so we temporarily block the connection. BlockedConnection block( m_plugInputChangedConnection ); if( !input ) { for( ChildContainer::const_iterator it = children().begin(); it!=children().end(); it++ ) { IECore::staticPointerCast<Plug>( *it )->setInput( 0 ); } } else { CompoundPlugPtr p = IECore::staticPointerCast<CompoundPlug>( input ); ChildContainer::const_iterator it1, it2; for( it1 = children().begin(), it2 = p->children().begin(); it1!=children().end(); it1++, it2++ ) { IECore::staticPointerCast<Plug>( *it1 )->setInput( IECore::staticPointerCast<Plug>( *it2 ) ); } } } // we connect ourselves last, so that all our child plugs are correctly connected // before we signal our own connection change. ValuePlug::setInput( input ); }