NodulePtr Nodule::create( Gaffer::PlugPtr plug ) { IECore::ConstStringDataPtr noduleType = Gaffer::Metadata::plugValue<IECore::StringData>( plug.get(), "nodule:type" ); if( noduleType ) { if( noduleType->readable() == "" ) { return NULL; } const TypeNameCreatorMap &m = typeNameCreators(); TypeNameCreatorMap::const_iterator it = m.find( noduleType->readable() ); if( it != m.end() ) { return it->second( plug ); } else { IECore::msg( IECore::Msg::Warning, "Nodule::create", boost::format( "Nonexistent nodule type \"%s\" requested for plug \"%s\"" ) % noduleType->readable() % plug->fullName() ); } } const Gaffer::Node *node = plug->node(); if( node ) { std::string plugPath = plug->relativeName( node ); const NamedCreatorMap &m = namedCreators(); IECore::TypeId t = node->typeId(); while( t!=IECore::InvalidTypeId ) { NamedCreatorMap::const_iterator it = m.find( t ); if( it!=m.end() ) { for( RegexAndCreatorVector::const_reverse_iterator nIt = it->second.rbegin(); nIt!=it->second.rend(); nIt++ ) { if( boost::regex_match( plugPath, nIt->first ) ) { return nIt->second( plug ); } } } t = IECore::RunTimeTyped::baseTypeId( t ); } } const PlugCreatorMap &m = plugCreators(); IECore::TypeId t = plug->typeId(); while( t!=IECore::InvalidTypeId ) { PlugCreatorMap::const_iterator it = m.find( t ); if( it!=m.end() ) { return it->second( plug ); } t = IECore::RunTimeTyped::baseTypeId( t ); } return 0; }
NodulePtr Nodule::create( Gaffer::PlugPtr plug ) { if( !plug->getFlags( Gaffer::Plug::AcceptsInputs ) ) { return 0; } Gaffer::ConstNodePtr node = plug->node(); if( node ) { std::string plugPath = plug->relativeName( node ); const NamedCreatorMap &m = namedCreators(); IECore::TypeId t = node->typeId(); while( t!=IECore::InvalidTypeId ) { NamedCreatorMap::const_iterator it = m.find( t ); if( it!=m.end() ) { for( RegexAndCreatorVector::const_reverse_iterator nIt = it->second.rbegin(); nIt!=it->second.rend(); nIt++ ) { if( boost::regex_match( plugPath, nIt->first ) ) { return nIt->second( plug ); } } } t = IECore::RunTimeTyped::baseTypeId( t ); } } CreatorMap &m = creators(); IECore::TypeId t = plug->typeId(); while( t!=IECore::InvalidTypeId ) { CreatorMap::const_iterator it = m.find( t ); if( it!=m.end() ) { return it->second( plug ); } t = IECore::RunTimeTyped::baseTypeId( t ); } return 0; }
ConnectionGadgetPtr ConnectionGadget::create( NodulePtr srcNodule, NodulePtr dstNodule ) { const Gaffer::Plug *plug = dstNodule->plug(); if( const Gaffer::Node *node = plug->node() ) { std::string plugPath = plug->relativeName( node ); const NamedCreatorMap &m = namedCreators(); IECore::TypeId t = node->typeId(); while( t!=IECore::InvalidTypeId ) { NamedCreatorMap::const_iterator it = m.find( t ); if( it!=m.end() ) { for( RegexAndCreatorVector::const_reverse_iterator nIt = it->second.rbegin(); nIt!=it->second.rend(); nIt++ ) { if( boost::regex_match( plugPath, nIt->first ) ) { return nIt->second( srcNodule, dstNodule ); } } } t = IECore::RunTimeTyped::baseTypeId( t ); } } CreatorMap &m = creators(); IECore::TypeId t = plug->typeId(); while( t!=IECore::InvalidTypeId ) { CreatorMap::const_iterator it = m.find( t ); if( it!=m.end() ) { return it->second( srcNodule, dstNodule ); } t = IECore::RunTimeTyped::baseTypeId( t ); } return NULL; }