| 1204 | } |
| 1205 | |
| 1206 | SceneInterfacePtr LinkedScene::child( const Name &name, MissingBehaviour missingBehaviour ) |
| 1207 | { |
| 1208 | if ( missingBehaviour == SceneInterface::CreateIfMissing ) |
| 1209 | { |
| 1210 | if ( m_readOnly ) |
| 1211 | { |
| 1212 | throw Exception( "No write access to scene file!" ); |
| 1213 | } |
| 1214 | } |
| 1215 | |
| 1216 | if ( m_linkedScene ) |
| 1217 | { |
| 1218 | ConstSceneInterfacePtr c = m_linkedScene->child( name, SceneInterface::NullIfMissing ); |
| 1219 | if ( c ) |
| 1220 | { |
| 1221 | return new LinkedScene( m_mainScene.get(), c.get(), m_linkLocationsData, m_rootLinkDepth, m_readOnly, false, m_timeRemapped ); |
| 1222 | } |
| 1223 | if( !m_atLink ) |
| 1224 | { |
| 1225 | if( missingBehaviour == SceneInterface::ThrowIfMissing ) |
| 1226 | { |
| 1227 | throw Exception( "IECore::LinkedScene::child(): Couldn't find child named " + name.string() ); |
| 1228 | } |
| 1229 | else if( missingBehaviour == SceneInterface::NullIfMissing ) |
| 1230 | { |
| 1231 | return nullptr; |
| 1232 | } |
| 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | if( missingBehaviour == SceneInterface::CreateIfMissing && m_atLink ) |
| 1237 | { |
| 1238 | if( !m_mainScene->hasChild( name ) ) |
| 1239 | { |
| 1240 | // check for name clashes with the link: |
| 1241 | NameList linkChildNames; |
| 1242 | m_linkedScene->childNames( linkChildNames ); |
| 1243 | |
| 1244 | if( std::find( linkChildNames.begin(), linkChildNames.end(), name ) != linkChildNames.end() ) |
| 1245 | { |
| 1246 | throw Exception( "IECore::LinkedScene::child(): Child name " + name.string() + " clashes with a child in the link" ); |
| 1247 | } |
| 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | |
| 1252 | SceneInterfacePtr c = m_mainScene->child( name, missingBehaviour ); |
| 1253 | if ( !c ) |
| 1254 | { |
| 1255 | return nullptr; |
| 1256 | } |
| 1257 | if ( m_readOnly ) |
| 1258 | { |
| 1259 | if( c->hasAttribute( fileNameLinkAttribute ) && c->hasAttribute( rootLinkAttribute ) ) |
| 1260 | { |
| 1261 | ConstStringDataPtr fileName = runTimeCast< const StringData >( c->readAttribute( fileNameLinkAttribute, 0 ) ); |
| 1262 | ConstInternedStringVectorDataPtr root = runTimeCast< const InternedStringVectorData >( c->readAttribute( rootLinkAttribute, 0 ) ); |
| 1263 | |