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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_SDF_VARIANT_SET_SPEC_H
8 #define PXR_USD_SDF_VARIANT_SET_SPEC_H
9 
10 /// \file sdf/variantSetSpec.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/sdf/api.h"
15 #include "pxr/usd/sdf/spec.h"
16 #include "pxr/usd/sdf/proxyTypes.h"
17 #include "pxr/usd/sdf/types.h"
18 
19 #include <iosfwd>
20 #include <map>
21 #include <string>
22 #include <vector>
23 
25 
26 /// \class SdfVariantSetSpec
27 ///
28 /// Represents a coherent set of alternate representations for part of a
29 /// scene.
30 ///
31 /// An SdfPrimSpec object may contain one or more named SdfVariantSetSpec
32 /// objects that define variations on the prim.
33 ///
34 /// An SdfVariantSetSpec object contains one or more named SdfVariantSpec
35 /// objects. It may also define the name of one of its variants to be used by
36 /// default.
37 ///
38 /// When a prim references another prim, the referencing prim may specify
39 /// one of the variants from each of the variant sets of the target prim.
40 /// The chosen variant from each set (or the default variant from those sets
41 /// that the referencing prim does not explicitly specify) is composited
42 /// over the target prim, and then the referencing prim is composited over
43 /// the result.
44 ///
45 class SdfVariantSetSpec : public SdfSpec
46 {
47  SDF_DECLARE_SPEC(SdfVariantSetSpec, SdfSpec);
48 
49 public:
50  ///
51  /// \name Spec construction
52  /// @{
53 
54  /// Constructs a new instance.
55  SDF_API
56  static SdfVariantSetSpecHandle
57  New(const SdfPrimSpecHandle& prim, const std::string& name);
58 
59  /// Constructs a new instance.
60  SDF_API
61  static SdfVariantSetSpecHandle
62  New(const SdfVariantSpecHandle& prim, const std::string& name);
63 
64  /// @}
65 
66  /// \name Name
67  /// @{
68 
69  /// Returns the name of this variant set.
70  SDF_API
71  std::string GetName() const;
72 
73  /// Returns the name of this variant set.
74  SDF_API
75  TfToken GetNameToken() const;
76 
77  /// @}
78  /// \name Namespace hierarchy
79  /// @{
80 
81  /// Returns the prim or variant that this variant set belongs to.
82  SDF_API
83  SdfSpecHandle GetOwner() const;
84 
85  /// @}
86  /// \name Variants
87  /// @{
88 
89  /// Returns the variants as a map.
90  SDF_API
92 
93  /// Returns the variants as a vector.
94  SDF_API
95  SdfVariantSpecHandleVector GetVariantList() const;
96 
97  /// Removes \p variant from the list of variants.
98  ///
99  /// If the variant set does not currently own \p variant, no action
100  /// is taken.
101  SDF_API
102  void RemoveVariant(const SdfVariantSpecHandle& variant);
103 
104  /// @}
105 };
106 
108 
109 #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:32
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:70
GLuint const GLchar * name
Definition: glcorearb.h:786
SDF_API TfToken GetNameToken() const
Returns the name of this variant set.
#define SDF_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
SDF_API std::string GetName() const
Returns the name of this variant set.
SDF_API void RemoveVariant(const SdfVariantSpecHandle &variant)