void _VisitImpl(SdfPathVector const &paths) { if (!paths.empty()) { for (SdfPath const &p: paths) { _workQueue.push(p); } _consumerTask.Wake(); } if (_recurse) { WorkParallelForEach( paths.begin(), paths.end(), [this](SdfPath const &path) { if (!path.HasPrefix(_prim.GetPath())) { if (UsdPrim owningPrim = _prim.GetStage()-> GetPrimAtPath(path.GetPrimPath())) { _VisitSubtree(owningPrim); } } }); } }
void SdfAttributeSpec::ChangeMapperPath( const SdfPath& oldPath, const SdfPath& newPath) { if (not PermissionToEdit()) { TF_CODING_ERROR("Change mapper path: Permission denied."); return; } const SdfPath& attrPath = GetPath(); // Absolutize. SdfPath oldAbsPath = oldPath.MakeAbsolutePath(attrPath.GetPrimPath()); SdfPath newAbsPath = newPath.MakeAbsolutePath(attrPath.GetPrimPath()); // Validate. if (oldAbsPath == newAbsPath) { // Nothing to do. return; } if (not newAbsPath.IsPropertyPath()) { TF_CODING_ERROR("cannot change connection path for attribute %s's " "mapper at connection path <%s> to <%s> because it's " "not a property path", attrPath.GetString().c_str(), oldAbsPath.GetString().c_str(), newAbsPath.GetString().c_str()); return; } SdfPathVector mapperPaths = GetFieldAs<SdfPathVector>(SdfChildrenKeys->MapperChildren); // Check that a mapper actually exists at the old path. SdfPathVector::iterator mapperIt = std::find(mapperPaths.begin(), mapperPaths.end(), oldAbsPath); if (mapperIt == mapperPaths.end()) { TF_CODING_ERROR("Change mapper path: No mapper exists for " "connection path <%s>.", oldAbsPath.GetText()); return; } // Check that no mapper already exists at the new path. const bool mapperExistsAtNewPath = (std::find(mapperPaths.begin(), mapperPaths.end(), newAbsPath) != mapperPaths.end()); if (mapperExistsAtNewPath) { TF_CODING_ERROR("Change mapper path: Mapper already exists for " "connection path <%s>.", newAbsPath.GetText()); return; } // Things look OK -- let's go ahead and move the mapper over to the // new path. SdfChangeBlock block; const SdfPath oldMapperSpecPath = attrPath.AppendMapper(oldAbsPath); const SdfPath newMapperSpecPath = attrPath.AppendMapper(newAbsPath); _MoveSpec(oldMapperSpecPath, newMapperSpecPath); *mapperIt = newAbsPath; SetField(SdfChildrenKeys->MapperChildren, VtValue(mapperPaths)); }