All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
primSpec.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_SDF_PRIM_SPEC_H
8#define PXR_USD_SDF_PRIM_SPEC_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/declareSpec.h"
14#include "pxr/usd/sdf/spec.h"
15#include "pxr/usd/sdf/path.h"
16#include "pxr/usd/sdf/payload.h"
17#include "pxr/usd/sdf/proxyTypes.h"
18#include "pxr/usd/sdf/types.h"
19#include "pxr/usd/sdf/api.h"
21
22#include <iosfwd>
23#include <map>
24#include <string>
25#include <vector>
26
27PXR_NAMESPACE_OPEN_SCOPE
28
57class SdfPrimSpec : public SdfSpec
58{
59 SDF_DECLARE_SPEC(SdfPrimSpec, SdfSpec);
60
61public:
66
70
75 SDF_API
76 static SdfPrimSpecHandle
77 New(const SdfLayerHandle& parentLayer,
78 const std::string& name, SdfSpecifier spec,
79 const std::string& typeName = std::string());
80
88 SDF_API
89 static SdfPrimSpecHandle
90 New(const SdfPrimSpecHandle& parentPrim,
91 const std::string& name, SdfSpecifier spec,
92 const std::string& typeName = std::string());
93
96
98 SDF_API
99 const std::string& GetName() const;
100
102 SDF_API
104
110 SDF_API
111 bool CanSetName(const std::string& newName, std::string* whyNot) const;
112
123 SDF_API
124 bool SetName(const std::string& newName, bool validate = true);
125
127 SDF_API
128 static bool IsValidName(const std::string& name);
129
133
135 SDF_API
136 SdfPrimSpecHandle GetNameRoot() const;
137
144 SDF_API
145 SdfPrimSpecHandle GetNameParent() const;
146
148 SDF_API
149 SdfPrimSpecHandle GetRealNameParent() const;
150
152 SDF_API
154
156 SDF_API
157 void SetNameChildren(const SdfPrimSpecHandleVector&);
158
164 SDF_API
165 bool InsertNameChild(const SdfPrimSpecHandle& child, int index = -1);
166
168 SDF_API
169 bool RemoveNameChild(const SdfPrimSpecHandle& child);
170
175 SDF_API
177
179 SDF_API
181
188 SDF_API
189 void SetNameChildrenOrder(const std::vector<TfToken>& names);
190
193 SDF_API
194 void InsertInNameChildrenOrder(const TfToken& name, int index = -1);
195
197 SDF_API
199
201 SDF_API
203
209 SDF_API
210 void ApplyNameChildrenOrder(std::vector<TfToken>* vec) const;
211
215
217 SDF_API
219
221 SDF_API
222 void SetProperties(const SdfPropertySpecHandleVector&);
223
229 SDF_API
230 bool InsertProperty(const SdfPropertySpecHandle& property, int index = -1);
231
233 SDF_API
234 void RemoveProperty(const SdfPropertySpecHandle& property);
235
237 SDF_API
239
241 SDF_API
243
248 SDF_API
250
252 SDF_API
253 bool HasPropertyOrder() const;
254
261 SDF_API
262 void SetPropertyOrder(const std::vector<TfToken>& names);
263
266 SDF_API
267 void InsertInPropertyOrder(const TfToken& name, int index = -1);
268
270 SDF_API
272
274 SDF_API
276
282 SDF_API
283 void ApplyPropertyOrder(std::vector<TfToken>* vec) const;
284
288
296 SDF_API
297 SdfSpecHandle GetObjectAtPath(const SdfPath& path) const;
298
303 SDF_API
304 SdfPrimSpecHandle GetPrimAtPath(const SdfPath& path) const;
305
310 SDF_API
311 SdfPropertySpecHandle GetPropertyAtPath(const SdfPath& path) const;
312
317 SDF_API
318 SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath& path) const;
319
324 SDF_API
325 SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath& path) const;
326
330
337 SDF_API
339
341 SDF_API
342 void SetTypeName(const std::string& value);
343
347 SDF_API
348 std::string GetComment() const;
349
351 SDF_API
352 void SetComment(const std::string& value);
353
357 SDF_API
358 std::string GetDocumentation() const;
359
361 SDF_API
362 void SetDocumentation(const std::string& value);
363
367 SDF_API
368 bool GetActive() const;
369
371 SDF_API
372 void SetActive(bool value);
373
375 SDF_API
376 bool HasActive() const;
377
379 SDF_API
381
385 SDF_API
386 bool GetHidden() const;
387
389 SDF_API
390 void SetHidden( bool value );
391
395 SDF_API
397
399 SDF_API
400 void SetKind(const TfToken& value);
401
403 SDF_API
404 bool HasKind() const;
405
407 SDF_API
408 void ClearKind();
409
413 SDF_API
415
420 SDF_API
421 void SetSymmetryFunction(const TfToken& functionName);
422
426 SDF_API
428
433 SDF_API
434 void SetSymmetryArgument(const std::string& name, const VtValue& value);
435
439 SDF_API
440 std::string GetSymmetricPeer() const;
441
446 SDF_API
447 void SetSymmetricPeer(const std::string& peerName);
448
452 SDF_API
453 std::string GetPrefix() const;
454
456 SDF_API
457 void SetPrefix(const std::string& value);
458
462 SDF_API
463 std::string GetSuffix() const;
464
466 SDF_API
467 void SetSuffix(const std::string& value);
468
480 SDF_API
482
492 SDF_API
494
498 SDF_API
499 void SetCustomData(const std::string& name, const VtValue& value);
500
507 SDF_API
508 void SetAssetInfo(const std::string& name, const VtValue& value);
509
511 SDF_API
513
515 SDF_API
517
521 SDF_API
523
525 SDF_API
527
531 SDF_API
533
535 SDF_API
536 void SetPrefixSubstitutions(const VtDictionary& prefixSubstitutions);
537
541 SDF_API
543
545 SDF_API
546 void SetSuffixSubstitutions(const VtDictionary& suffixSubstitutions);
547
549 SDF_API
550 void SetInstanceable(bool instanceable);
551
553 SDF_API
554 bool GetInstanceable() const;
555
558 SDF_API
559 bool HasInstanceable() const;
560
562 SDF_API
564
568
572 SDF_API
574
576 SDF_API
577 bool HasPayloads() const;
578
580 SDF_API
582
586
590 SDF_API
592
594 SDF_API
595 bool HasInheritPaths() const;
596
598 SDF_API
600
604
608 SDF_API
610
612 SDF_API
613 bool HasSpecializes() const;
614
616 SDF_API
618
622
626 SDF_API
628
630 SDF_API
631 bool HasReferences() const;
632
634 SDF_API
636
640
644 SDF_API
646
648 SDF_API
649 bool HasVariantSetNames() const;
650
652 SDF_API
653 std::vector<std::string> GetVariantNames(const std::string& name) const;
654
659 SDF_API
660 SdfVariantSetsProxy GetVariantSets() const;
661
666 SDF_API
667 void RemoveVariantSet(const std::string& name);
668
671 SDF_API
673
679 SDF_API
680 void SetVariantSelection(const std::string& variantSetName,
681 const std::string& variantName);
682
685 SDF_API
686 void BlockVariantSelection(const std::string& variantSetName);
687
691
702 SDF_API
704
707 SDF_API
708 void SetRelocates(const SdfRelocatesMap& newMap);
709
714 SDF_API
715 bool HasRelocates() const;
716
718 SDF_API
720
722
723private:
724 // Returns true if this object is the pseudo-root.
725 bool _IsPseudoRoot() const;
726
727 // Raises an error and returns false if this is the pseudo-root,
728 // otherwise returns true. We want to allow clients to be able
729 // to use pseudo-roots as any other prim in namespace editing
730 // operations as well as silently permit read accesses on fields
731 // pseudo-roots don't actually have in order to promote generic
732 // algorithm programming. Mutating methods on SdfPrimSpec use
733 // this function as write access validation.
734 bool _ValidateEdit(const TfToken& key) const;
735
736private:
737 static SdfPrimSpecHandle
738 _New(const SdfPrimSpecHandle &parentPrim,
739 const TfToken &name, SdfSpecifier spec,
740 const TfToken &typeName);
741};
742
751SDF_API
752SdfPrimSpecHandle SdfCreatePrimInLayer(const SdfLayerHandle& layer,
753 const SdfPath& primPath);
754
755
764SDF_API
765bool SdfJustCreatePrimInLayer(const SdfLayerHandle& layer,
766 const SdfPath& primPath);
767
768PXR_NAMESPACE_CLOSE_SCOPE
769
770#endif // PXR_USD_SDF_PRIM_SPEC_H
Provides a view onto an object's children.
Definition: childrenView.h:205
Represents a set of list editing operations.
Represents a single list of list editing operations.
Definition: listProxy.h:37
A proxy for editing map-like values.
Definition: mapEditProxy.h:101
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Represents a prim description in an SdfLayer object.
Definition: primSpec.h:58
SDF_API void SetNameChildrenOrder(const std::vector< TfToken > &names)
Given a list of (possibly sparse) child names, authors a reorder nameChildren statement for this prim...
SDF_API SdfPayloadsProxy GetPayloadList() const
Returns a proxy for the prim's payloads.
SDF_API void ClearInheritPathList()
Clears the inherit paths for this prim.
SDF_API void SetDocumentation(const std::string &value)
Sets the documentation string for this prim spec.
SDF_API SdfRelocatesMapProxy GetRelocates() const
Get an editing proxy for the map of namespace relocations specified on this prim.
SDF_API VtDictionary GetPrefixSubstitutions() const
Returns the prefixSubstitutions dictionary for this prim spec.
SDF_API bool RemoveNameChild(const SdfPrimSpecHandle &child)
Removes the child. Returns true if successful, false if failed.
SDF_API bool HasReferences() const
Returns true if this prim has references set.
SDF_API bool HasInheritPaths() const
Returns true if this prim has inherit paths set.
SDF_API void ClearSpecializesList()
Clears the specializes for this prim.
SDF_API bool InsertProperty(const SdfPropertySpecHandle &property, int index=-1)
Inserts a property.
SDF_API SdfSpecializesProxy GetSpecializesList() const
Returns a proxy for the prim's specializes paths.
SDF_API TfToken GetNameToken() const
Returns the prim's name, as a token.
SDF_API void SetHidden(bool value)
Sets whether this prim spec will be hidden in browsers.
SDF_API void RemoveFromPropertyOrder(const TfToken &name)
Remove a property name from the property order.
SDF_API void SetTypeName(const std::string &value)
Sets the typeName of the model prim.
SDF_API SdfPrimSpecHandle GetNameParent() const
Returns the prim's namespace parent.
SDF_API void SetAssetInfo(const std::string &name, const VtValue &value)
Sets a asset info entry for this prim.
SDF_API void ClearPayloadList()
Clears the payloads for this prim.
static SDF_API SdfPrimSpecHandle New(const SdfLayerHandle &parentLayer, const std::string &name, SdfSpecifier spec, const std::string &typeName=std::string())
Create a root prim spec.
SDF_API SdfSpecifier GetSpecifier() const
Returns the spec specifier (def, over or class).
SDF_API void SetActive(bool value)
Sets whether this prim spec is active.
SDF_API void SetSymmetryArgument(const std::string &name, const VtValue &value)
Sets a symmetry argument for this prim.
SDF_API SdfPrimSpecHandle GetNameRoot() const
Returns the prim's namespace pseudo-root prim.
SDF_API void SetInstanceable(bool instanceable)
Sets the value for the prim's instanceable flag.
SDF_API TfToken GetKind() const
Returns this prim spec's kind.
SDF_API void SetSymmetryFunction(const TfToken &functionName)
Sets the symmetry function for this prim.
SDF_API std::vector< std::string > GetVariantNames(const std::string &name) const
Returns list of variant names for the given variant set.
SDF_API SdfNameChildrenOrderProxy GetNameChildrenOrder() const
Returns the list of child names for this prim's reorder.
SDF_API void RemoveFromPropertyOrderByIndex(int index)
Remove a property name from the property order by index.
SDF_API SdfSpecHandle GetObjectAtPath(const SdfPath &path) const
Returns the object for the given path.
SDF_API void BlockVariantSelection(const std::string &variantSetName)
Blocks the variant selected for the given variant set by setting the variant selection to empty.
SDF_API SdfReferencesProxy GetReferenceList() const
Returns a proxy for the prim's references.
SDF_API TfToken GetSymmetryFunction() const
Returns the symmetry function for this prim.
SDF_API void ClearKind()
Remove the kind opinion from this prim spec if there is one.
SDF_API SdfPermission GetPermission() const
Returns the prim's permission restriction.
SDF_API void InsertInPropertyOrder(const TfToken &name, int index=-1)
Add a new property name in the property order.
SDF_API std::string GetDocumentation() const
Returns the documentation string for this prim spec.
SDF_API void SetPrefix(const std::string &value)
Sets the prefix string for this prim spec.
static SDF_API SdfPrimSpecHandle New(const SdfPrimSpecHandle &parentPrim, const std::string &name, SdfSpecifier spec, const std::string &typeName=std::string())
Create a prim spec.
SDF_API bool HasInstanceable() const
Returns true if this prim spec has a value authored for its instanceable flag, false otherwise.
SDF_API void SetPrefixSubstitutions(const VtDictionary &prefixSubstitutions)
Sets the prefixSubstitutions dictionary for this prim spec.
SDF_API AttributeSpecView GetAttributes() const
Returns a view of the attributes of this prim.
SDF_API void ApplyNameChildrenOrder(std::vector< TfToken > *vec) const
Reorders the given list of child names according to the reorder nameChildren statement for this prim.
SDF_API void SetVariantSelection(const std::string &variantSetName, const std::string &variantName)
Sets the variant selected for the given variant set.
SDF_API SdfVariantSelectionProxy GetVariantSelections() const
Returns an editable map whose keys are variant set names and whose values are the variants selected f...
SDF_API void RemoveFromNameChildrenOrder(const TfToken &name)
Removes a name child name from the name children order.
SDF_API bool GetHidden() const
Returns whether this prim spec will be hidden in browsers.
SDF_API void ClearInstanceable()
Clears the value for the prim's instanceable flag.
SDF_API SdfDictionaryProxy GetSymmetryArguments() const
Returns the symmetry arguments for this prim.
SDF_API bool HasVariantSetNames() const
Returns true if this prim has variant sets set.
SDF_API const std::string & GetName() const
Returns the prim's name.
SDF_API RelationshipSpecView GetRelationships() const
Returns a view of the relationships of this prim.
SDF_API PropertySpecView GetProperties() const
Returns the prim's properties.
SDF_API void SetNameChildren(const SdfPrimSpecHandleVector &)
Updates nameChildren to match the given vector of prims.
SDF_API void RemoveVariantSet(const std::string &name)
Removes the variant set with the given name.
SDF_API void ClearRelocates()
Clears the relocates opinion for this prim.
SDF_API bool CanSetName(const std::string &newName, std::string *whyNot) const
Returns true if setting the prim spec's name to newName will succeed.
SDF_API void SetPermission(SdfPermission value)
Sets the prim's permission restriction.
SDF_API bool GetInstanceable() const
Returns the value for the prim's instanceable flag.
SDF_API SdfPrimSpecHandle GetRealNameParent() const
Returns the prim's namespace parent.
SDF_API bool InsertNameChild(const SdfPrimSpecHandle &child, int index=-1)
Inserts a child.
SDF_API void SetCustomData(const std::string &name, const VtValue &value)
Sets a custom data entry for this prim.
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path) const
Returns a property given its path.
SDF_API SdfPropertyOrderProxy GetPropertyOrder() const
Returns the list of property names for this prim's reorder properties statement.
SDF_API void SetComment(const std::string &value)
Sets the comment string for this prim spec.
SDF_API void ApplyPropertyOrder(std::vector< TfToken > *vec) const
Reorders the given list of property names according to the reorder properties statement for this prim...
SDF_API std::string GetComment() const
Returns the comment string for this prim spec.
SDF_API bool SetName(const std::string &newName, bool validate=true)
Sets the prim's name.
SDF_API std::string GetPrefix() const
Returns the prefix string for this prim spec.
SDF_API void ClearReferenceList()
Clears the references for this prim.
SDF_API void SetProperties(const SdfPropertySpecHandleVector &)
Updates properties to match the given vector of properties.
SDF_API SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path) const
Returns a prim given its path.
SDF_API bool HasPropertyOrder() const
Returns true if this prim has a property ordering specified.
static SDF_API bool IsValidName(const std::string &name)
Returns true if the given string is a valid prim name.
SDF_API std::string GetSuffix() const
Returns the suffix string for this prim spec.
SDF_API SdfInheritsProxy GetInheritPathList() const
Returns a proxy for the prim's inherit paths.
SDF_API void RemoveFromNameChildrenOrderByIndex(int index)
Removes a name child name from the name children order by index.
SDF_API void SetSuffix(const std::string &value)
Sets the suffix string for this prim spec.
SDF_API void SetRelocates(const SdfRelocatesMap &newMap)
Set the entire map of namespace relocations specified on this prim.
SDF_API bool GetActive() const
Returns whether this prim spec is active.
SDF_API void SetSpecifier(SdfSpecifier value)
Sets the spec specifier (def or over).
SDF_API void InsertInNameChildrenOrder(const TfToken &name, int index=-1)
Adds a new name child name in the name children order.
SDF_API TfToken GetTypeName() const
Returns the typeName of the prim.
SDF_API SdfVariantSetsProxy GetVariantSets() const
Returns the variant sets.
SDF_API SdfDictionaryProxy GetAssetInfo() const
Returns the asset info dictionary for this prim.
SDF_API NameChildrenView GetNameChildren() const
Returns a keyed vector view of the prim's namespace children.
SDF_API bool HasNameChildrenOrder() const
Returns true if this prim has name children order specified.
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path) const
Returns a relationship given its path.
SDF_API bool HasPayloads() const
Returns true if this prim has payloads set.
SDF_API SdfDictionaryProxy GetCustomData() const
Returns the custom data for this prim.
SDF_API void ClearActive()
Removes the active opinion in this prim spec if there is one.
SDF_API void SetPropertyOrder(const std::vector< TfToken > &names)
Given a list of (possibly sparse) property names, authors a reorder properties statement for this pri...
SDF_API SdfVariantSetNamesProxy GetVariantSetNameList() const
Returns a proxy for the prim's variant sets.
SDF_API void RemoveProperty(const SdfPropertySpecHandle &property)
Removes the property.
SDF_API void SetKind(const TfToken &value)
Sets this prim spec's kind.
SDF_API void SetSymmetricPeer(const std::string &peerName)
Sets a symmetric peer for this prim.
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path) const
Returns an attribute given its path.
SDF_API std::string GetSymmetricPeer() const
Returns the symmetric peer for this prim.
SDF_API void SetSuffixSubstitutions(const VtDictionary &suffixSubstitutions)
Sets the suffixSubstitutions dictionary for this prim spec.
SDF_API VtDictionary GetSuffixSubstitutions() const
Returns the suffixSubstitutions dictionary for this prim spec.
SDF_API bool HasRelocates() const
Returns true if this prim has any relocates opinion, including that there should be no relocates (i....
SDF_API bool HasSpecializes() const
Returns true if this prim has specializes set.
SDF_API bool HasActive() const
Returns true if this prim spec has an opinion about active.
SDF_API bool HasKind() const
Returns true if this prim spec has an opinion about kind.
Base class for all Sdf spec classes.
Definition: spec.h:33
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A map with string keys and VtValue values.
Definition: dictionary.h:43
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
Standard pointer typedefs.
SDF_API SdfPrimSpecHandle SdfCreatePrimInLayer(const SdfLayerHandle &layer, const SdfPath &primPath)
Convenience function to create a prim at the given path, and any necessary parent prims,...
SDF_API bool SdfJustCreatePrimInLayer(const SdfLayerHandle &layer, const SdfPath &primPath)
Convenience function to create a prim at the given path, and any necessary parent prims,...
Basic Sdf data types.
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:100
SdfPermission
An enum that defines permission levels.
Definition: types.h:132
std::map< SdfPath, SdfPath > SdfRelocatesMap
A map of source SdfPaths to target SdfPaths for relocation.
Definition: types.h:267