usdrt::SdfPath
Defined in usdrt/scenegraph/usd/sdf/path.h
-
class SdfPath
A path value used to locate objects in the scenegraph.
Uses omni::fabric::Path for the prim path, and TfToken for the property part.
Note
USDRT paths support is limited to absolute paths.
Constructors
-
SdfPath() = default
Constructs the default, empty path.
-
inline SdfPath(const omni::fabric::Path &path, const TfToken prop = TfToken())
Create a new path from fabric data.
- Parameters
path – The fabric path.
prop – The property part of the new path. Default empty TfToken.
-
inline SdfPath(omni::fabric::Path &&path, TfToken &&prop = TfToken()) noexcept
Create a new path with a copy of the given fabric data.
- Parameters
path – The fabric path.
prop – The property part of the new path. Default empty TfToken.
-
inline SdfPath(const omni::fabric::PathC pathC, const TfToken prop = TfToken())
Create a new path from the given fabric data.
- Parameters
pathC – The fabric PathC - integer key that identifies paths in fabric.
prop – The property part of the new path. Default empty TfToken.
-
inline SdfPath(const std::string &path)
Create a new path from the given string.
Note
This does not currently check if the path string is valid. It only searches for the property delimiter to construct the fabric path and token.
- Parameters
path – String representation of the new path.
-
inline SdfPath(const char *path)
Create a new path from the given c-string.
Note
This does not currently check if the path string is valid. It only searches for the property delimiter to construct the fabric path and token
- Parameters
path – c-string representation of the new path.
-
inline SdfPath(const omni::fabric::Connection &conn)
Create a new path from the given omni::fabric::Connection.
- Parameters
conn – omni::fabric::Connection representation of the path.
-
inline SdfPath(const omni::fabric::PathC pathC, const omni::fabric::TokenC propC)
Create a new path from the given fabric data.
- Parameters
pathC – The fabric PathC - integer key that identifies paths in fabric.
propC – The fabric TokenC representation of thie property - integer key that identifies tokens in fabric.
-
inline SdfPath(omni::core::ObjectPtr<usdrt::IRtPath> rtPath)
Create a new path from the omni interface object.
- Parameters
rtPath – the omni interface object
-
inline ~SdfPath()
Destructor.
Public Functions
-
inline std::string GetString() const
Returns the string representation of this path as a std::string.
-
inline const char *GetText() const
Returns the string representation of this path as a c string.
-
inline bool IsEmpty() const
Returns true if this is the empty path (SdfPath::EmptyPath()).
-
inline std::string GetName() const
Returns the name of the prim, property or relational attribute identified by the path.
-
inline const TfToken &GetNameToken() const
Returns the name of the prim, property or relational attribute identified by the path, as a token.
-
inline SdfPath GetPrimPath() const
Create a new SdfPath by stripping all attributes, targets, and properties from the leaf prim in this path.
- Returns
A new SdfPath that is just the prim.
-
inline size_t GetHash() const
Get hash value for this path.
-
inline SdfPathVector GetPrefixes() const
Get the prefix paths of this path.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Returns
Return an SdfPathVector containing the prefix paths of this path, ordered shortest to longest.
-
inline void GetPrefixes(SdfPathVector *prefixes) const
Get the prefix paths of this path.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters
prefixes – [out] An SdfPathVector containing the prefix paths of this path, ordered shortest to longest.
-
inline SdfPathAncestorsRange GetAncestorsRange() const
Get a range for iterating over the ancestors of this path.
The range provides iteration over the prefixes of a path, ordered from longest to shortest (the opposite of the order of the prefixes returned by GetPrefixes).
- Returns
Return the SdfPathAncestorRange for iteration.
-
inline size_t GetPathElementCount() const
Returns the number of path elements in this path.
-
inline bool IsAbsolutePath() const
Returns whether the path is absolute.
-
inline bool IsAbsoluteRootPath() const
Return true if this path is the AbsoluteRootPath().
-
inline bool IsPrimPath() const
Returns whether the path identifies a prim.
-
inline bool IsAbsoluteRootOrPrimPath() const
Returns whether the path identifies a prim or the absolute root.
-
inline bool IsRootPrimPath() const
Returns whether the path identifies a root prim.
The path must be absolute and have a single element (for example
/foo
).
-
inline bool IsPropertyPath() const
Returns whether the path identifies a property.
A relational attribute is considered to be a property, so this method will return true for relational attributes as well as properties of prims.
-
inline bool IsPrimPropertyPath() const
Returns whether the path identifies a prim’s property.
A relational attribute is not a prim property.
-
inline bool IsNamespacedPropertyPath() const
Returns whether the path identifies a namespaced property.
A namespaced property has colon embedded in its name.
-
inline bool ContainsPropertyElements() const
Return true if this path contains any property elements (relationships or attributes), false otherwise.
-
inline SdfPath ReplaceName(TfToken const &newName) const
Replace the final component of this path with
newName
.- Parameters
newName – The token to replace this path’s name.
- Returns
Return a copy of this path with its final component changed to newName. If this path is not a prim or property path, it is invalid. Return empty path.
-
inline bool HasPrefix(const SdfPath &prefix) const
Check if this path has
prefix
as a prefix.Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters
prefix – Given prefix to check
- Returns
Return true if both this path and prefix are not the empty path and this path has prefix as a prefix. Return false otherwise.
-
inline SdfPath GetParentPath() const
Get the path that identifies this path’s namespace parent.
If this path is a property path, assume no target paths and trim the property part. Otherwise, use fabric get the parent path.
- Returns
Return a new path that identifies this path’s parent.
-
inline SdfPath GetAbsoluteRootOrPrimPath() const
Creates a path by stripping all properties and relational attributes from this path, leaving the path to the containing prim.
If the path is already a prim or absolute root path, the same path is returned.
-
inline SdfPath AppendPath(const SdfPath &newSuffix) const
Creates a path by appending a given relative path to this path.
This path and
newSuffix
must meet the following to be valid:If the newSuffix is a prim path, then this path must be a prim path or a root path.
If the newSuffix is a prim property path, then this path must be a prim path.
Neither path can be empty.
- Parameters
newSuffix – The relative path to append.
- Returns
Return a new path that appends
newSuffix
to this path. If this path ornewSuffix
are invalid, return the empty path.
-
inline SdfPath AppendChild(TfToken const &childName) const
Creates a path by appending an element for
childName
to this path.This path must be a prim path or the AbsoluteRootPath.
- Parameters
childName – the child prim name to append.
- Returns
Returns a new path with
childName
appended.
-
inline SdfPath AppendProperty(TfToken const &propName) const
Creates a path by appending an element for
propName
to this path.This path must be a prim path.
- Parameters
propName – The prop name to append.
- Returns
Return a new path with
propName
appended.
-
inline SdfPath ReplacePrefix(const SdfPath &oldPrefix, const SdfPath &newPrefix, bool fixTargetPaths = true) const
Replace all occurences of the prefix path
oldPrefix
withnewPrefix
.Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters
oldPrefix – Prefix to replace.
newPrefix – The new path prefix.
fixTargetPaths – This is not supported in fabric.
- Returns
Returns a path with all occurrences of the prefix path
oldPrefix
replaced with the prefix pathnewPrefix
.
-
inline SdfPath GetCommonPrefix(const SdfPath &path) const
Get a path with maximal length that is a prefix path of both this path and
path
.Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters
path – Path to query.
- Returns
Return a new path that is the longest common prefix of this path and
path
.
-
inline std::pair<SdfPath, SdfPath> RemoveCommonSuffix(const SdfPath &otherPath, bool stopAtRootPrim = false) const
Find and remove the longest common suffix from two paths.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters
otherPath – Other path to query.
stopAtRootPrim – If this flag is
true
then neither returned path will be the root path. Default false.
- Returns
Return a pair of new paths. This path and
otherPath
respectively, with the longest common suffix removed
Public Static Functions
-
static inline const SdfPath AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
-
static inline bool IsValidIdentifier(const std::string &name)
Check if the given string represents a legal path identifier.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters
name – string representation of the path
- Returns
Return
true
ifname
is a valid path identifier
-
static inline bool IsValidNamespacedIdentifier(const std::string &name)
Check if the given string represents a legal namespaced path identifier.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters
name – string representation of the path
- Returns
Return
true
ifIsValidIdentifier
does.
-
static inline bool IsValidPathString(const std::string &pathString, std::string *errMsg = 0)
Check if the given string represents a valid path.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters
pathString – string representation of the path
errMsg – [out] Error message set if the path is not valid. Default 0.
- Returns
Return
true
ifpathString
is a valid path string. Otherwise return false an iferrMsg
is not NULL, set the pointed-to string to the parse error.
-
static inline std::string JoinIdentifier(const TfToken &lhs, const TfToken &rhs)
Joins
lhs
andrhs
into a single identifier using the namesapce delimeter.- Returns
lhs
ifrhs
is empty, and vice verse.
-
static inline std::string JoinIdentifier(const std::string &lhs, const std::string &rhs)
Joins
lhs
andrhs
into a single identifier using the namesapce delimeter.- Returns
lhs
ifrhs
is empty, and vice verse.
-
static inline std::vector<std::string> TokenizeIdentifier(const std::string &name)
Tokenizes
name
by the namespace delimiter. Returns the empty vector ifname
is not a valid namespaced identifier.
-
static inline std::string JoinIdentifier(const TfTokenVector &names)
Join
names
into a single identifier using the namespace delimiter. Any empty strings present innames
are ignored when joining.
-
static inline std::pair<std::string, bool> StripPrefixNamespace(const std::string &name, const std::string &matchNamespace)
Returns (
name
,true
) wherename
is stripped of the prefix specified bymatchNamespace
ifname
indeed starts withmatchNamespace
. Returns (name
,false
) otherwise, withname
unmodified.This function deals with both the case where
matchNamespace
contains the trailing namespace delimiter ‘:’ or not.
-
SdfPath() = default