NodeGadgetPtr NodeGadget::create( Gaffer::NodePtr node ) { const CreatorMap &cr = creators(); IECore::TypeId typeId = node->typeId(); while( typeId != IECore::InvalidTypeId ) { const CreatorMap::const_iterator it = cr.find( typeId ); if( it != cr.end() ) { return it->second( node ); } typeId = IECore::RunTimeTyped::baseTypeId( typeId ); } return NULL; }
NodeGadgetPtr NodeGadget::create( Gaffer::NodePtr node ) { IECore::ConstStringDataPtr nodeGadgetType = Gaffer::Metadata::value<IECore::StringData>( node.get(), "nodeGadget:type" ); if( nodeGadgetType ) { if( nodeGadgetType->readable() == "" ) { return nullptr; } const TypeCreatorMap &m = typeCreators(); TypeCreatorMap::const_iterator it = m.find( nodeGadgetType->readable() ); if( it != m.end() ) { return it->second( node ); } else { IECore::msg( IECore::Msg::Warning, "NodeGadget::create", boost::format( "Nonexistent type \"%s\" requested for node \"%s\"" ) % nodeGadgetType->readable() % node->fullName() ); } } const NodeCreatorMap &cr = nodeCreators(); IECore::TypeId typeId = node->typeId(); while( typeId != IECore::InvalidTypeId ) { const NodeCreatorMap::const_iterator it = cr.find( typeId ); if( it != cr.end() ) { return it->second( node ); } typeId = IECore::RunTimeTyped::baseTypeId( typeId ); } return nullptr; }