7#ifndef PXR_USD_SDF_CHILDREN_POLICIES_H
8#define PXR_USD_SDF_CHILDREN_POLICIES_H
15#include "pxr/usd/sdf/api.h"
16#include "pxr/usd/sdf/path.h"
20#include "pxr/usd/sdf/schema.h"
22PXR_NAMESPACE_OPEN_SCOPE
35template <
class SpecType>
36class Sdf_TokenChildPolicy {
39 typedef KeyPolicy::value_type KeyType;
41 typedef SpecType ValueType;
43 static KeyType GetKey(
const ValueType &spec) {
44 return spec->GetPath().GetName();
51 static FieldType GetFieldValue(
const SdfPath &childPath) {
55 static bool IsValidIdentifier(
const std::string &name) {
56 return SdfSchema::IsValidIdentifier(name);
61class Sdf_PrimChildPolicy :
62 public Sdf_TokenChildPolicy<SdfPrimSpecHandle>
66 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
71 return SdfChildrenKeys->PrimChildren;
75class Sdf_PropertyChildPolicy :
76 public Sdf_TokenChildPolicy<SdfPropertySpecHandle>
79 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
89 return SdfChildrenKeys->PropertyChildren;
92 static bool IsValidIdentifier(
const std::string &name) {
93 return SdfSchema::IsValidNamespacedIdentifier(name);
97class Sdf_AttributeChildPolicy :
98 public Sdf_TokenChildPolicy<SdfAttributeSpecHandle>
101 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
111 return SdfChildrenKeys->PropertyChildren;
114 static bool IsValidIdentifier(
const std::string &name) {
115 return SdfSchema::IsValidNamespacedIdentifier(name);
119class Sdf_RelationshipChildPolicy :
120 public Sdf_TokenChildPolicy<SdfRelationshipSpecHandle>
124 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
129 return SdfChildrenKeys->PropertyChildren;
132 static bool IsValidIdentifier(
const std::string &name) {
133 return SdfSchema::IsValidNamespacedIdentifier(name);
137class Sdf_MapperArgChildPolicy :
138 public Sdf_TokenChildPolicy<SdfSpecHandle>
142 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
147 return SdfChildrenKeys->MapperArgChildren;
151class Sdf_ExpressionChildPolicy :
152 public Sdf_TokenChildPolicy<SdfSpecHandle>
155 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
160 return SdfChildrenKeys->ExpressionChildren;
164class Sdf_VariantChildPolicy :
165 public Sdf_TokenChildPolicy<SdfVariantSpecHandle>
169 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
182 return SdfChildrenKeys->VariantChildren;
186class Sdf_VariantSetChildPolicy :
187 public Sdf_TokenChildPolicy<SdfVariantSetSpecHandle>
191 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
196 return SdfChildrenKeys->VariantSetChildren;
204template <
class SpecType>
205class Sdf_PathChildPolicy
209 typedef KeyPolicy::value_type KeyType;
210 typedef SpecType ValueType;
217 static KeyType GetKey(
const ValueType &value) {
221 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
225 static FieldType GetFieldValue(
const SdfPath &childPath) {
229 static bool IsValidIdentifier(
const FieldType &path) {
233 static bool IsValidIdentifier(
const std::string &path) {
238class Sdf_MapperChildPolicy :
239 public Sdf_PathChildPolicy<SdfSpecHandle>
242 static SdfPath GetChildPath(
const SdfPath &parentPath,
const FieldType &key) {
247 static FieldType GetFieldValue(
const SdfPath &childPath) {
253 return SdfChildrenKeys->MapperChildren;
257class Sdf_AttributeConnectionChildPolicy :
258 public Sdf_PathChildPolicy<SdfSpecHandle> {
261 return SdfChildrenKeys->ConnectionChildren;
265class Sdf_RelationshipTargetChildPolicy :
266 public Sdf_PathChildPolicy<SdfSpecHandle> {
270 return SdfChildrenKeys->RelationshipTargetChildren;
274PXR_NAMESPACE_CLOSE_SCOPE
A subclass of SdfPropertySpec that holds typed data.
Key policy for std::string names.
A path value used to locate objects in layers or scenegraphs.
SDF_API SdfPath MakeAbsolutePath(const SdfPath &anchor) const
Returns the absolute form of this path using anchor as the relative basis.
SDF_API SdfPath GetParentPath() const
Return the path that identifies this path's namespace parent.
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 AppendExpression() const
Creates a path by appending an expression element.
SDF_API SdfPath AppendRelationalAttribute(TfToken const &attrName) const
Creates a path by appending an element for attrName to this path.
SDF_API SdfPath AppendMapper(const SdfPath &targetPath) const
Creates a path by appending a mapper element for targetPath.
SDF_API bool IsTargetPath() const
Returns whether the path identifies a relationship or connection target.
SDF_API const SdfPath & GetTargetPath() const
Returns the relational attribute or mapper target path for this path.
SDF_API const TfToken & GetNameToken() const
Returns the name of the prim, property or relational attribute identified by the 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 SdfPath AppendProperty(TfToken const &propName) const
Creates a path by appending an element for propName to this path.
SDF_API SdfPath AppendMapperArg(TfToken const &argName) const
Creates a path by appending an element for argName.
SDF_API SdfPath AppendChild(TfToken const &childName) const
Creates a path by appending an element for childName to this path.
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 AppendTarget(const SdfPath &targetPath) const
Creates a path by appending an element for targetPath.
SDF_API SdfPath GetPrimPath() const
Creates a path by stripping all relational attributes, targets, properties, and variant selections fr...
Key policy for SdfPath; converts all SdfPaths to absolute.
Represents a prim description in an SdfLayer object.
Base class for SdfAttributeSpec and SdfRelationshipSpec.
A property that contains a reference to one or more SdfPrimSpec instances.
Represents a coherent set of alternate representations for part of a scene.
Represents a single variant in a variant set.
Token for efficient comparison, assignment, and hashing of known strings.