24 #ifndef PXR_USD_SDF_CHILDREN_POLICIES_H 25 #define PXR_USD_SDF_CHILDREN_POLICIES_H 32 #include "pxr/usd/sdf/api.h" 33 #include "pxr/usd/sdf/path.h" 37 #include "pxr/usd/sdf/schema.h" 39 PXR_NAMESPACE_OPEN_SCOPE
52 template <
class SpecType>
53 class Sdf_TokenChildPolicy {
56 typedef KeyPolicy::value_type KeyType;
58 typedef SpecType ValueType;
60 static KeyType GetKey(
const ValueType &spec) {
61 return spec->GetPath().GetName();
68 static FieldType GetFieldValue(
const SdfPath &childPath) {
72 static bool IsValidIdentifier(
const std::string &name) {
73 return SdfSchema::IsValidIdentifier(name);
78 class Sdf_PrimChildPolicy :
79 public Sdf_TokenChildPolicy<SdfPrimSpecHandle>
83 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
88 return SdfChildrenKeys->PrimChildren;
92 class Sdf_PropertyChildPolicy :
93 public Sdf_TokenChildPolicy<SdfPropertySpecHandle>
96 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
106 return SdfChildrenKeys->PropertyChildren;
109 static bool IsValidIdentifier(
const std::string &name) {
110 return SdfSchema::IsValidNamespacedIdentifier(name);
114 class Sdf_AttributeChildPolicy :
115 public Sdf_TokenChildPolicy<SdfAttributeSpecHandle>
118 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
128 return SdfChildrenKeys->PropertyChildren;
131 static bool IsValidIdentifier(
const std::string &name) {
132 return SdfSchema::IsValidNamespacedIdentifier(name);
136 class Sdf_RelationshipChildPolicy :
137 public Sdf_TokenChildPolicy<SdfRelationshipSpecHandle>
141 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
146 return SdfChildrenKeys->PropertyChildren;
149 static bool IsValidIdentifier(
const std::string &name) {
150 return SdfSchema::IsValidNamespacedIdentifier(name);
154 class Sdf_MapperArgChildPolicy :
155 public Sdf_TokenChildPolicy<SdfSpecHandle>
159 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
164 return SdfChildrenKeys->MapperArgChildren;
168 class Sdf_ExpressionChildPolicy :
169 public Sdf_TokenChildPolicy<SdfSpecHandle>
172 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
177 return SdfChildrenKeys->ExpressionChildren;
181 class Sdf_VariantChildPolicy :
182 public Sdf_TokenChildPolicy<SdfVariantSpecHandle>
186 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
199 return SdfChildrenKeys->VariantChildren;
203 class Sdf_VariantSetChildPolicy :
204 public Sdf_TokenChildPolicy<SdfVariantSetSpecHandle>
208 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
213 return SdfChildrenKeys->VariantSetChildren;
221 template <
class SpecType>
222 class Sdf_PathChildPolicy
226 typedef KeyPolicy::value_type KeyType;
227 typedef SpecType ValueType;
234 static KeyType GetKey(
const ValueType &value) {
238 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
242 static FieldType GetFieldValue(
const SdfPath &childPath) {
246 static bool IsValidIdentifier(
const FieldType &path) {
250 static bool IsValidIdentifier(
const std::string &path) {
255 class Sdf_MapperChildPolicy :
256 public Sdf_PathChildPolicy<SdfSpecHandle>
259 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
264 static FieldType GetFieldValue(
const SdfPath &childPath) {
270 return SdfChildrenKeys->MapperChildren;
274 class Sdf_AttributeConnectionChildPolicy :
275 public Sdf_PathChildPolicy<SdfSpecHandle> {
278 return SdfChildrenKeys->ConnectionChildren;
282 class Sdf_RelationshipTargetChildPolicy :
283 public Sdf_PathChildPolicy<SdfSpecHandle> {
287 return SdfChildrenKeys->RelationshipTargetChildren;
291 PXR_NAMESPACE_CLOSE_SCOPE
293 #endif // PXR_USD_SDF_CHILDREN_POLICIES_H SDF_API SdfPath AppendMapper(const SdfPath &targetPath) const
Creates a path by appending a mapper element for targetPath.
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Key policy for std::string names.
static SDF_API bool IsValidPathString(const std::string &pathString, std::string *errMsg=0)
Return true if pathString is a valid path string, meaning that passing the string to the SdfPath cons...
SDF_API SdfPath GetParentPath() const
Return the path that identifies this path's namespace parent.
Token for efficient comparison, assignment, and hashing of known strings.
A subclass of SdfPropertySpec that holds typed data.
SDF_API SdfPath MakeAbsolutePath(const SdfPath &anchor) const
Returns the absolute form of this path using anchor as the relative basis.
Represents a coherent set of alternate representations for part of a scene.
SDF_API const TfToken & GetNameToken() const
Returns the name of the prim, property or relational attribute identified by the path,...
A path value used to locate objects in layers or scenegraphs.
SDF_API SdfPath GetPrimPath() const
Creates a path by stripping all relational attributes, targets, properties, and variant selections fr...
SDF_API SdfPath AppendTarget(const SdfPath &targetPath) const
Creates a path by appending an element for targetPath.
SDF_API SdfPath AppendMapperArg(TfToken const &argName) const
Creates a path by appending an element for argName.
Represents a prim description in an SdfLayer object.
A property that contains a reference to one or more SdfPrimSpec instances.
SDF_API SdfPath AppendExpression() const
Creates a path by appending an expression element.
SDF_API SdfPath AppendProperty(TfToken const &propName) const
Creates a path by appending an element for propName to this path.
SDF_API SdfPath AppendRelationalAttribute(TfToken const &attrName) const
Creates a path by appending an element for attrName to this path.
SDF_API SdfPath AppendVariantSelection(const std::string &variantSet, const std::string &variant) const
Creates a path by appending an element for variantSet and variant to this path.
SDF_API const SdfPath & GetTargetPath() const
Returns the relational attribute or mapper target path for this path.
Represents a single variant in a variant set.
SDF_API std::pair< std::string, std::string > GetVariantSelection() const
Returns the variant selection for this path, if this is a variant selection path.
SDF_API SdfPath AppendChild(TfToken const &childName) const
Creates a path by appending an element for childName to this path.
Key policy for SdfPath; converts all SdfPaths to absolute.
SDF_API bool IsTargetPath() const
Returns whether the path identifies a relationship or connection target.