All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primSpec.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_SDF_PRIM_SPEC_H
25 #define PXR_USD_SDF_PRIM_SPEC_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/declareSpec.h"
31 #include "pxr/usd/sdf/spec.h"
32 #include "pxr/usd/sdf/path.h"
33 #include "pxr/usd/sdf/payload.h"
34 #include "pxr/usd/sdf/proxyTypes.h"
35 #include "pxr/usd/sdf/types.h"
36 #include "pxr/usd/sdf/api.h"
38 
39 #include <iosfwd>
40 #include <map>
41 #include <string>
42 #include <vector>
43 
44 PXR_NAMESPACE_OPEN_SCOPE
45 
74 class SdfPrimSpec : public SdfSpec
75 {
76  SDF_DECLARE_SPEC(SdfPrimSpec, SdfSpec);
77 
78 public:
83 
87 
92  SDF_API
93  static SdfPrimSpecHandle
94  New(const SdfLayerHandle& parentLayer,
95  const std::string& name, SdfSpecifier spec,
96  const std::string& typeName = std::string());
97 
105  SDF_API
106  static SdfPrimSpecHandle
107  New(const SdfPrimSpecHandle& parentPrim,
108  const std::string& name, SdfSpecifier spec,
109  const std::string& typeName = std::string());
110 
113 
115  SDF_API
116  const std::string& GetName() const;
117 
119  SDF_API
120  TfToken GetNameToken() const;
121 
127  SDF_API
128  bool CanSetName(const std::string& newName, std::string* whyNot) const;
129 
140  SDF_API
141  bool SetName(const std::string& newName, bool validate = true);
142 
144  SDF_API
145  static bool IsValidName(const std::string& name);
146 
150 
152  SDF_API
153  SdfPrimSpecHandle GetNameRoot() const;
154 
161  SDF_API
162  SdfPrimSpecHandle GetNameParent() const;
163 
165  SDF_API
166  SdfPrimSpecHandle GetRealNameParent() const;
167 
169  SDF_API
171 
173  SDF_API
174  void SetNameChildren(const SdfPrimSpecHandleVector&);
175 
181  SDF_API
182  bool InsertNameChild(const SdfPrimSpecHandle& child, int index = -1);
183 
185  SDF_API
186  bool RemoveNameChild(const SdfPrimSpecHandle& child);
187 
192  SDF_API
194 
196  SDF_API
197  bool HasNameChildrenOrder() const;
198 
205  SDF_API
206  void SetNameChildrenOrder(const std::vector<TfToken>& names);
207 
210  SDF_API
211  void InsertInNameChildrenOrder(const TfToken& name, int index = -1);
212 
214  SDF_API
215  void RemoveFromNameChildrenOrder(const TfToken& name);
216 
218  SDF_API
219  void RemoveFromNameChildrenOrderByIndex(int index);
220 
226  SDF_API
227  void ApplyNameChildrenOrder(std::vector<TfToken>* vec) const;
228 
232 
234  SDF_API
236 
238  SDF_API
239  void SetProperties(const SdfPropertySpecHandleVector&);
240 
246  SDF_API
247  bool InsertProperty(const SdfPropertySpecHandle& property, int index = -1);
248 
250  SDF_API
251  void RemoveProperty(const SdfPropertySpecHandle& property);
252 
254  SDF_API
256 
258  SDF_API
260 
265  SDF_API
267 
269  SDF_API
270  bool HasPropertyOrder() const;
271 
278  SDF_API
279  void SetPropertyOrder(const std::vector<TfToken>& names);
280 
283  SDF_API
284  void InsertInPropertyOrder(const TfToken& name, int index = -1);
285 
287  SDF_API
288  void RemoveFromPropertyOrder(const TfToken& name);
289 
291  SDF_API
292  void RemoveFromPropertyOrderByIndex(int index);
293 
299  SDF_API
300  void ApplyPropertyOrder(std::vector<TfToken>* vec) const;
301 
305 
313  SDF_API
314  SdfSpecHandle GetObjectAtPath(const SdfPath& path) const;
315 
320  SDF_API
321  SdfPrimSpecHandle GetPrimAtPath(const SdfPath& path) const;
322 
327  SDF_API
328  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath& path) const;
329 
334  SDF_API
335  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath& path) const;
336 
341  SDF_API
342  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath& path) const;
343 
347 
354  SDF_API
355  TfToken GetTypeName() const;
356 
358  SDF_API
359  void SetTypeName(const std::string& value);
360 
364  SDF_API
365  std::string GetComment() const;
366 
368  SDF_API
369  void SetComment(const std::string& value);
370 
374  SDF_API
375  std::string GetDocumentation() const;
376 
378  SDF_API
379  void SetDocumentation(const std::string& value);
380 
384  SDF_API
385  bool GetActive() const;
386 
388  SDF_API
389  void SetActive(bool value);
390 
392  SDF_API
393  bool HasActive() const;
394 
396  SDF_API
397  void ClearActive();
398 
402  SDF_API
403  bool GetHidden() const;
404 
406  SDF_API
407  void SetHidden( bool value );
408 
412  SDF_API
413  TfToken GetKind() const;
414 
416  SDF_API
417  void SetKind(const TfToken& value);
418 
420  SDF_API
421  bool HasKind() const;
422 
424  SDF_API
425  void ClearKind();
426 
430  SDF_API
432 
437  SDF_API
438  void SetSymmetryFunction(const TfToken& functionName);
439 
443  SDF_API
445 
450  SDF_API
451  void SetSymmetryArgument(const std::string& name, const VtValue& value);
452 
456  SDF_API
457  std::string GetSymmetricPeer() const;
458 
463  SDF_API
464  void SetSymmetricPeer(const std::string& peerName);
465 
469  SDF_API
470  std::string GetPrefix() const;
471 
473  SDF_API
474  void SetPrefix(const std::string& value);
475 
479  SDF_API
480  std::string GetSuffix() const;
481 
483  SDF_API
484  void SetSuffix(const std::string& value);
485 
497  SDF_API
499 
509  SDF_API
511 
515  SDF_API
516  void SetCustomData(const std::string& name, const VtValue& value);
517 
524  SDF_API
525  void SetAssetInfo(const std::string& name, const VtValue& value);
526 
528  SDF_API
529  SdfSpecifier GetSpecifier() const;
530 
532  SDF_API
533  void SetSpecifier(SdfSpecifier value);
534 
538  SDF_API
540 
542  SDF_API
543  void SetPermission(SdfPermission value);
544 
548  SDF_API
550 
552  SDF_API
553  void SetPrefixSubstitutions(const VtDictionary& prefixSubstitutions);
554 
558  SDF_API
560 
562  SDF_API
563  void SetSuffixSubstitutions(const VtDictionary& suffixSubstitutions);
564 
566  SDF_API
567  void SetInstanceable(bool instanceable);
568 
570  SDF_API
571  bool GetInstanceable() const;
572 
575  SDF_API
576  bool HasInstanceable() const;
577 
579  SDF_API
580  void ClearInstanceable();
581 
585 
589  SDF_API
591 
593  SDF_API
594  bool HasPayloads() const;
595 
597  SDF_API
598  void ClearPayloadList();
599 
603 
607  SDF_API
609 
611  SDF_API
612  bool HasInheritPaths() const;
613 
615  SDF_API
616  void ClearInheritPathList();
617 
621 
625  SDF_API
627 
629  SDF_API
630  bool HasSpecializes() const;
631 
633  SDF_API
634  void ClearSpecializesList();
635 
639 
643  SDF_API
645 
647  SDF_API
648  bool HasReferences() const;
649 
651  SDF_API
652  void ClearReferenceList();
653 
657 
661  SDF_API
663 
665  SDF_API
666  bool HasVariantSetNames() const;
667 
669  SDF_API
670  std::vector<std::string> GetVariantNames(const std::string& name) const;
671 
676  SDF_API
677  SdfVariantSetsProxy GetVariantSets() const;
678 
683  SDF_API
684  void RemoveVariantSet(const std::string& name);
685 
688  SDF_API
690 
696  SDF_API
697  void SetVariantSelection(const std::string& variantSetName,
698  const std::string& variantName);
699 
702  SDF_API
703  void BlockVariantSelection(const std::string& variantSetName);
704 
708 
719  SDF_API
721 
724  SDF_API
725  void SetRelocates(const SdfRelocatesMap& newMap);
726 
731  SDF_API
732  bool HasRelocates() const;
733 
735  SDF_API
736  void ClearRelocates();
737 
739 
740 private:
741  // Returns true if this object is the pseudo-root.
742  bool _IsPseudoRoot() const;
743 
744  // Raises an error and returns false if this is the pseudo-root,
745  // otherwise returns true. We want to allow clients to be able
746  // to use pseudo-roots as any other prim in namespace editing
747  // operations as well as silently permit read accesses on fields
748  // pseudo-roots don't actually have in order to promote generic
749  // algorithm programming. Mutating methods on SdfPrimSpec use
750  // this function as write access validation.
751  bool _ValidateEdit(const TfToken& key) const;
752 
753 private:
754  static SdfPrimSpecHandle
755  _New(const SdfPrimSpecHandle &parentPrim,
756  const TfToken &name, SdfSpecifier spec,
757  const TfToken &typeName);
758 };
759 
768 SDF_API
769 SdfPrimSpecHandle SdfCreatePrimInLayer(const SdfLayerHandle& layer,
770  const SdfPath& primPath);
771 
772 
781 SDF_API
782 bool SdfJustCreatePrimInLayer(const SdfLayerHandle& layer,
783  const SdfPath& primPath);
784 
785 PXR_NAMESPACE_CLOSE_SCOPE
786 
787 #endif // PXR_USD_SDF_PRIM_SPEC_H
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...
SDF_API TfToken GetNameToken() const
Returns the prim&#39;s name, as a token.
SDF_API bool SetName(const std::string &newName, bool validate=true)
Sets the prim&#39;s name.
SDF_API void SetComment(const std::string &value)
Sets the comment string for this prim spec.
Standard pointer typedefs.
SDF_API bool HasInheritPaths() const
Returns true if this prim has inherit paths set.
std::map< SdfPath, SdfPath > SdfRelocatesMap
A map of source SdfPaths to target SdfPaths for relocation.
Definition: types.h:293
SDF_API bool GetActive() const
Returns whether this prim spec is active.
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.
Represents a set of list editing operations.
SDF_API SdfInheritsProxy GetInheritPathList() const
Returns a proxy for the prim&#39;s inherit paths.
SDF_API bool GetHidden() const
Returns whether this prim spec will be hidden in browsers.
SDF_API void SetSymmetricPeer(const std::string &peerName)
Sets a symmetric peer for this prim.
SDF_API bool InsertProperty(const SdfPropertySpecHandle &property, int index=-1)
Inserts a property.
A map with string keys and VtValue values.
Definition: dictionary.h:63
Base class for all Sdf spec classes.
Definition: spec.h:51
SDF_API void SetSuffix(const std::string &value)
Sets the suffix string for this prim spec.
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 SetProperties(const SdfPropertySpecHandleVector &)
Updates properties to match the given vector of properties.
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 void BlockVariantSelection(const std::string &variantSetName)
Blocks the variant selected for the given variant set by setting the variant selection to empty...
SDF_API void SetInstanceable(bool instanceable)
Sets the value for the prim&#39;s instanceable flag.
SDF_API bool HasRelocates() const
Returns true if this prim has any relocates opinion, including that there should be no relocates (i...
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 GetDocumentation() const
Returns the documentation string for this prim spec.
SDF_API void SetSymmetryFunction(const TfToken &functionName)
Sets the symmetry function for this prim.
SDF_API void SetSpecifier(SdfSpecifier value)
Sets the spec specifier (def or over).
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path) const
Returns a property given its path.
SDF_API VtDictionary GetSuffixSubstitutions() const
Returns the suffixSubstitutions dictionary for this prim spec.
SDF_API SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path) const
Returns a prim given its path.
SDF_API TfToken GetTypeName() const
Returns the typeName of the model prim.
SDF_API void SetRelocates(const SdfRelocatesMap &newMap)
Set the entire map of namespace relocations specified on this prim.
Basic Sdf data types.
SDF_API void InsertInPropertyOrder(const TfToken &name, int index=-1)
Add a new property name in the property order.
SDF_API bool GetInstanceable() const
Returns the value for the prim&#39;s instanceable flag.
SDF_API void SetTypeName(const std::string &value)
Sets the typeName of the model prim.
SDF_API void SetActive(bool value)
Sets whether this prim spec is active.
SDF_API void RemoveFromNameChildrenOrder(const TfToken &name)
Removes a name child name from the name children order.
SDF_API void RemoveProperty(const SdfPropertySpecHandle &property)
Removes the property.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
SDF_API bool HasReferences() const
Returns true if this prim has references set.
SDF_API SdfDictionaryProxy GetAssetInfo() const
Returns the asset info dictionary for this prim.
SDF_API TfToken GetKind() const
Returns this prim spec&#39;s kind.
SDF_API SdfRelocatesMapProxy GetRelocates() const
Get an editing proxy for the map of namespace relocations specified on this prim. ...
SDF_API void ClearActive()
Removes the active opinion in this prim spec if there is one.
SDF_API SdfVariantSetsProxy GetVariantSets() const
Returns the variant sets.
SDF_API void ClearSpecializesList()
Clears the specializes for this prim.
SDF_API void SetAssetInfo(const std::string &name, const VtValue &value)
Sets a asset info entry for this prim.
Represents a single list of list editing operations.
Definition: listProxy.h:57
SDF_API PropertySpecView GetProperties() const
Returns the prim&#39;s properties.
SDF_API bool HasActive() const
Returns true if this prim spec has an opinion about active.
SDF_API SdfDictionaryProxy GetCustomData() const
Returns the custom data for this prim.
SDF_API void SetPrefixSubstitutions(const VtDictionary &prefixSubstitutions)
Sets the prefixSubstitutions dictionary for this prim spec.
SDF_API bool HasKind() const
Returns true if this prim spec has an opinion about kind.
static SDF_API bool IsValidName(const std::string &name)
Returns true if the given string is a valid prim name.
SDF_API SdfNameChildrenOrderProxy GetNameChildrenOrder() const
Returns the list of child names for this prim&#39;s reorder.
SDF_API SdfPrimSpecHandle GetNameParent() const
Returns the prim&#39;s namespace parent.
SDF_API bool HasNameChildrenOrder() const
Returns true if this prim has name children order specified.
SDF_API bool HasPayloads() const
Returns true if this prim has payloads set.
SDF_API void SetCustomData(const std::string &name, const VtValue &value)
Sets a custom data entry for this prim.
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path) const
Returns an attribute given its path.
SDF_API bool HasInstanceable() const
Returns true if this prim spec has a value authored for its instanceable flag, false otherwise...
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:123
A proxy for editing map-like values.
Definition: mapEditProxy.h:120
SDF_API void ClearRelocates()
Clears the relocates opinion for this prim.
SDF_API SdfPermission GetPermission() const
Returns the prim&#39;s permission restriction.
SDF_API bool HasPropertyOrder() const
Returns true if this prim has a property ordering specified.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path) const
Returns a relationship given its path.
SDF_API bool InsertNameChild(const SdfPrimSpecHandle &child, int index=-1)
Inserts a child.
SDF_API SdfPayloadsProxy GetPayloadList() const
Returns a proxy for the prim&#39;s payloads.
SDF_API void SetPermission(SdfPermission value)
Sets the prim&#39;s permission restriction.
SDF_API std::string GetSuffix() const
Returns the suffix string for this prim spec.
SDF_API NameChildrenView GetNameChildren() const
Returns a keyed vector view of the prim&#39;s namespace children.
SDF_API SdfPrimSpecHandle GetRealNameParent() const
Returns the prim&#39;s namespace parent.
SDF_API void SetHidden(bool value)
Sets whether this prim spec will be hidden in browsers.
SDF_API void ClearInstanceable()
Clears the value for the prim&#39;s instanceable flag.
SDF_API void SetNameChildren(const SdfPrimSpecHandleVector &)
Updates nameChildren to match the given vector of prims.
SDF_API const std::string & GetName() const
Returns the prim&#39;s name.
SDF_API std::string GetPrefix() const
Returns the prefix string for this prim spec.
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 AttributeSpecView GetAttributes() const
Returns a view of the attributes of this prim.
SDF_API bool HasVariantSetNames() const
Returns true if this prim has variant sets set.
SDF_API SdfSpecializesProxy GetSpecializesList() const
Returns a proxy for the prim&#39;s specializes paths.
SDF_API VtDictionary GetPrefixSubstitutions() const
Returns the prefixSubstitutions dictionary for this prim spec.
SDF_API std::vector< std::string > GetVariantNames(const std::string &name) const
Returns list of variant names for the given variant set.
SDF_API SdfSpecifier GetSpecifier() const
Returns the spec specifier (def, over or class).
SDF_API SdfDictionaryProxy GetSymmetryArguments() const
Returns the symmetry arguments for this prim.
SDF_API void ClearReferenceList()
Clears the references for this prim.
Represents a prim description in an SdfLayer object.
Definition: primSpec.h:74
SDF_API void RemoveVariantSet(const std::string &name)
Removes the variant set with the given name.
SDF_API SdfPropertyOrderProxy GetPropertyOrder() const
Returns the list of property names for this prim&#39;s reorder properties statement.
SDF_API void ClearInheritPathList()
Clears the inherit paths for this prim.
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 void SetKind(const TfToken &value)
Sets this prim spec&#39;s kind.
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 SdfReferencesProxy GetReferenceList() const
Returns a proxy for the prim&#39;s references.
Provides a view onto an object&#39;s children.
Definition: childrenView.h:171
SDF_API std::string GetComment() const
Returns the comment string for this prim spec.
SDF_API void SetVariantSelection(const std::string &variantSetName, const std::string &variantName)
Sets the variant selected for the given variant set.
SDF_API void RemoveFromPropertyOrder(const TfToken &name)
Remove a property name from the property order.
SDF_API bool RemoveNameChild(const SdfPrimSpecHandle &child)
Removes the child. Returns true if successful, false if failed.
SDF_API void SetPrefix(const std::string &value)
Sets the prefix string for this prim spec.
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 SdfPrimSpecHandle GetNameRoot() const
Returns the prim&#39;s namespace pseudo-root prim.
SDF_API SdfVariantSetNamesProxy GetVariantSetNameList() const
Returns a proxy for the prim&#39;s variant sets.
SDF_API bool CanSetName(const std::string &newName, std::string *whyNot) const
Returns true if setting the prim spec&#39;s name to newName will succeed.
SDF_API void ClearPayloadList()
Clears the payloads for this prim.
SDF_API void SetSymmetryArgument(const std::string &name, const VtValue &value)
Sets a symmetry argument for this prim.
SDF_API std::string GetSymmetricPeer() const
Returns the symmetric peer for this prim.
SDF_API void SetDocumentation(const std::string &value)
Sets the documentation string for this prim spec.
SDF_API void RemoveFromNameChildrenOrderByIndex(int index)
Removes a name child name from the name children order by index.
SDF_API void InsertInNameChildrenOrder(const TfToken &name, int index=-1)
Adds a new name child name in the name children order.
SDF_API void SetSuffixSubstitutions(const VtDictionary &suffixSubstitutions)
Sets the suffixSubstitutions dictionary for this prim spec.
SDF_API bool HasSpecializes() const
Returns true if this prim has specializes set.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
SDF_API void ClearKind()
Remove the kind opinion from this prim spec if there is one.
SDF_API RelationshipSpecView GetRelationships() const
Returns a view of the relationships of this prim.
SdfPermission
An enum that defines permission levels.
Definition: types.h:155
SDF_API TfToken GetSymmetryFunction() const
Returns the symmetry function for this prim.