HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
variantSetSpec.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_SET_SPEC_H
25 #define PXR_USD_SDF_VARIANT_SET_SPEC_H
26 
27 /// \file sdf/variantSetSpec.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
32 #include "pxr/usd/sdf/spec.h"
33 #include "pxr/usd/sdf/proxyTypes.h"
34 #include "pxr/usd/sdf/types.h"
35 
36 #include <iosfwd>
37 #include <map>
38 #include <string>
39 #include <vector>
40 
42 
43 /// \class SdfVariantSetSpec
44 ///
45 /// Represents a coherent set of alternate representations for part of a
46 /// scene.
47 ///
48 /// An SdfPrimSpec object may contain one or more named SdfVariantSetSpec
49 /// objects that define variations on the prim.
50 ///
51 /// An SdfVariantSetSpec object contains one or more named SdfVariantSpec
52 /// objects. It may also define the name of one of its variants to be used by
53 /// default.
54 ///
55 /// When a prim references another prim, the referencing prim may specify
56 /// one of the variants from each of the variant sets of the target prim.
57 /// The chosen variant from each set (or the default variant from those sets
58 /// that the referencing prim does not explicitly specify) is composited
59 /// over the target prim, and then the referencing prim is composited over
60 /// the result.
61 ///
62 class SdfVariantSetSpec : public SdfSpec
63 {
64  SDF_DECLARE_SPEC(SdfVariantSetSpec, SdfSpec);
65 
66 public:
67  ///
68  /// \name Spec construction
69  /// @{
70 
71  /// Constructs a new instance.
72  SDF_API
73  static SdfVariantSetSpecHandle
74  New(const SdfPrimSpecHandle& prim, const std::string& name);
75 
76  /// Constructs a new instance.
77  SDF_API
78  static SdfVariantSetSpecHandle
79  New(const SdfVariantSpecHandle& prim, const std::string& name);
80 
81  /// @}
82 
83  /// \name Name
84  /// @{
85 
86  /// Returns the name of this variant set.
87  SDF_API
88  std::string GetName() const;
89 
90  /// Returns the name of this variant set.
91  SDF_API
92  TfToken GetNameToken() const;
93 
94  /// @}
95  /// \name Namespace hierarchy
96  /// @{
97 
98  /// Returns the prim or variant that this variant set belongs to.
99  SDF_API
100  SdfSpecHandle GetOwner() const;
101 
102  /// @}
103  /// \name Variants
104  /// @{
105 
106  /// Returns the variants as a map.
107  SDF_API
108  SdfVariantView GetVariants() const;
109 
110  /// Returns the variants as a vector.
111  SDF_API
112  SdfVariantSpecHandleVector GetVariantList() const;
113 
114  /// Removes \p variant from the list of variants.
115  ///
116  /// If the variant set does not currently own \p variant, no action
117  /// is taken.
118  SDF_API
119  void RemoveVariant(const SdfVariantSpecHandle& variant);
120 
121  /// @}
122 };
123 
125 
126 #endif // SD_VARIANTSETSPEC_H
static SDF_API SdfVariantSetSpecHandle New(const SdfPrimSpecHandle &prim, const std::string &name)
Constructs a new instance.
SDF_API SdfVariantView GetVariants() const
Returns the variants as a map.
Definition: spec.h:51
GLuint const GLchar * name
Definition: glcorearb.h:785
SDF_API SdfVariantSpecHandleVector GetVariantList() const
Returns the variants as a vector.
SDF_API SdfSpecHandle GetOwner() const
Returns the prim or variant that this variant set belongs to.
Definition: token.h:87
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
SDF_API TfToken GetNameToken() const
Returns the name of this variant set.
#define SDF_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
SDF_API std::string GetName() const
Returns the name of this variant set.
SDF_API void RemoveVariant(const SdfVariantSpecHandle &variant)