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 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_VARIANT_SPEC_H
25 #define PXR_USD_SDF_VARIANT_SPEC_H
26 
27 /// \file sdf/variantSpec.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
32 #include "pxr/usd/sdf/proxyTypes.h"
33 #include "pxr/usd/sdf/spec.h"
34 #include <string>
35 
37 
42 
43 class SdfPath;
44 
45 /// \class SdfVariantSpec
46 ///
47 /// Represents a single variant in a variant set.
48 ///
49 /// A variant contains a prim. This prim is the root prim of the variant.
50 ///
51 /// SdfVariantSpecs are value objects. This means they are immutable
52 /// once created and they are passed by copy-in APIs. To change a variant
53 /// spec, you make a new one and replace the existing one.
54 ///
55 class SdfVariantSpec : public SdfSpec
56 {
57  SDF_DECLARE_SPEC(SdfVariantSpec, SdfSpec);
58 
59 public:
60  ///
61  /// \name Spec construction
62  /// @{
63 
64  /// Constructs a new instance.
65  SDF_API
66  static SdfVariantSpecHandle New(const SdfVariantSetSpecHandle& owner,
67  const std::string& name);
68 
69  /// @}
70 
71  /// \name Name
72  /// @{
73 
74  /// Returns the name of this variant.
75  SDF_API
76  std::string GetName() const;
77 
78  /// Returns the name of this variant.
79  SDF_API
80  TfToken GetNameToken() const;
81 
82  /// @}
83  /// \name Namespace hierarchy
84  /// @{
85 
86  /// Return the SdfVariantSetSpec that owns this variant.
87  SDF_API
88  SdfVariantSetSpecHandle GetOwner() const;
89 
90  /// Get the prim spec owned by this variant.
91  SDF_API
92  SdfPrimSpecHandle GetPrimSpec() const;
93 
94  /// Returns the nested variant sets.
95  ///
96  /// The result maps variant set names to variant sets. Variant sets
97  /// may be removed through the proxy.
98  SDF_API
100 
101  /// Returns list of variant names for the given variant set.
102  SDF_API
103  std::vector<std::string> GetVariantNames(const std::string& name) const;
104 
105  /// @}
106 };
107 
108 /// Convenience function to create a variant spec for a given variant set and
109 /// a prim at the given path with.
110 ///
111 /// The function creates the prim spec if it doesn't exist already and any
112 /// necessary parent prims, in the given layer.
113 ///
114 /// It adds the variant set to the variant set list if it doesn't already exist.
115 ///
116 /// It creates a variant spec with the given name under the specified variant
117 /// set if it doesn't already exist.
118 SDF_API SdfVariantSpecHandle SdfCreateVariantInLayer(
119  const SdfLayerHandle &layer,
120  const SdfPath &primPath,
121  const std::string &variantSetName,
122  const std::string &variantName );
123 
125 
126 #endif /* SDF_VARIANT_SPEC_H */
SDF_API SdfPrimSpecHandle GetPrimSpec() const
Get the prim spec owned by this variant.
Definition: layer.h:94
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
Definition: spec.h:49
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:87
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:291
#define SDF_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
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:91
SDF_API std::vector< std::string > GetVariantNames(const std::string &name) const
Returns list of variant names for the given variant set.