HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
variantSpec.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_VARIANT_SPEC_H
8 #define PXR_USD_SDF_VARIANT_SPEC_H
9 
10 /// \file sdf/variantSpec.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/sdf/api.h"
15 #include "pxr/usd/sdf/proxyTypes.h"
16 #include "pxr/usd/sdf/spec.h"
17 #include <string>
18 
20 
25 
26 class SdfPath;
27 
28 /// \class SdfVariantSpec
29 ///
30 /// Represents a single variant in a variant set.
31 ///
32 /// A variant contains a prim. This prim is the root prim of the variant.
33 ///
34 /// SdfVariantSpecs are value objects. This means they are immutable
35 /// once created and they are passed by copy-in APIs. To change a variant
36 /// spec, you make a new one and replace the existing one.
37 ///
38 class SdfVariantSpec : public SdfSpec
39 {
40  SDF_DECLARE_SPEC(SdfVariantSpec, SdfSpec);
41 
42 public:
43  ///
44  /// \name Spec construction
45  /// @{
46 
47  /// Constructs a new instance.
48  SDF_API
49  static SdfVariantSpecHandle New(const SdfVariantSetSpecHandle& owner,
50  const std::string& name);
51 
52  /// @}
53 
54  /// \name Name
55  /// @{
56 
57  /// Returns the name of this variant.
58  SDF_API
59  std::string GetName() const;
60 
61  /// Returns the name of this variant.
62  SDF_API
63  TfToken GetNameToken() const;
64 
65  /// @}
66  /// \name Namespace hierarchy
67  /// @{
68 
69  /// Return the SdfVariantSetSpec that owns this variant.
70  SDF_API
71  SdfVariantSetSpecHandle GetOwner() const;
72 
73  /// Get the prim spec owned by this variant.
74  SDF_API
75  SdfPrimSpecHandle GetPrimSpec() const;
76 
77  /// Returns the nested variant sets.
78  ///
79  /// The result maps variant set names to variant sets. Variant sets
80  /// may be removed through the proxy.
81  SDF_API
83 
84  /// Returns list of variant names for the given variant set.
85  SDF_API
86  std::vector<std::string> GetVariantNames(const std::string& name) const;
87 
88  /// @}
89 };
90 
91 /// Convenience function to create a variant spec for a given variant set and
92 /// a prim at the given path with.
93 ///
94 /// The function creates the prim spec if it doesn't exist already and any
95 /// necessary parent prims, in the given layer.
96 ///
97 /// It adds the variant set to the variant set list if it doesn't already exist.
98 ///
99 /// It creates a variant spec with the given name under the specified variant
100 /// set if it doesn't already exist.
101 SDF_API SdfVariantSpecHandle SdfCreateVariantInLayer(
102  const SdfLayerHandle &layer,
103  const SdfPath &primPath,
104  const std::string &variantSetName,
105  const std::string &variantName );
106 
108 
109 #endif /* SDF_VARIANT_SPEC_H */
SDF_API SdfPrimSpecHandle GetPrimSpec() const
Get the prim spec owned by this variant.
Definition: layer.h:81
Definition: spec.h:32
SDF_API SdfVariantSpecHandle SdfCreateVariantInLayer(const SdfLayerHandle &layer, const SdfPath &primPath, const std::string &variantSetName, const std::string &variantName)
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
Definition: token.h:70
SDF_API std::string GetName() const
Returns the name of this variant.
SDF_API TfToken GetNameToken() const
Returns the name of this variant.
static SDF_API SdfVariantSpecHandle New(const SdfVariantSetSpecHandle &owner, const std::string &name)
Constructs a new instance.
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:273
#define SDF_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
SDF_API SdfVariantSetSpecHandle GetOwner() const
Return the SdfVariantSetSpec that owns this variant.
SDF_API SdfVariantSetsProxy GetVariantSets() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
SDF_API std::vector< std::string > GetVariantNames(const std::string &name) const
Returns list of variant names for the given variant set.