HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
purposeSchema.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 ////////////////////////////////////////////////////////////////////////
8 
9 /* ************************************************************************** */
10 /* ** ** */
11 /* ** This file is generated by a script. ** */
12 /* ** ** */
13 /* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
14 /* ** Edit hdSchemaDefs.py instead to make changes. ** */
15 /* ** ** */
16 /* ************************************************************************** */
17 
18 #ifndef PXR_IMAGING_HD_PURPOSE_SCHEMA_H
19 #define PXR_IMAGING_HD_PURPOSE_SCHEMA_H
20 
21 /// \file
22 
23 #include "pxr/imaging/hd/api.h"
24 
25 #include "pxr/imaging/hd/schema.h"
26 
27 // --(BEGIN CUSTOM CODE: Includes)--
28 // --(END CUSTOM CODE: Includes)--
29 
31 
32 // --(BEGIN CUSTOM CODE: Declares)--
33 // --(END CUSTOM CODE: Declares)--
34 
35 #define HD_PURPOSE_SCHEMA_TOKENS \
36  (purpose) \
37  (inheritable) \
38  (fallback) \
39 
40 TF_DECLARE_PUBLIC_TOKENS(HdPurposeSchemaTokens, HD_API,
42 
43 //-----------------------------------------------------------------------------
44 
45 
46 /// \class HdPurposeSchema
47 ///
48 class HdPurposeSchema : public HdSchema
49 {
50 public:
51  /// \name Schema retrieval
52  /// @{
53 
54  HdPurposeSchema(HdContainerDataSourceHandle container)
55  : HdSchema(container) {}
56 
57  /// Retrieves a container data source with the schema's default name token
58  /// "purpose" from the parent container and constructs a
59  /// HdPurposeSchema instance.
60  /// Because the requested container data source may not exist, the result
61  /// should be checked with IsDefined() or a bool comparison before use.
62  HD_API
64  const HdContainerDataSourceHandle &fromParentContainer);
65 
66  /// @}
67 
68 // --(BEGIN CUSTOM CODE: Schema Methods)--
69 
70  /// Resolve purpose to a TfToken value.
71  /// This applies the fallback value as needed, and ultimately
72  /// uses "geometry" if no other value is provided.
73  HD_API
75 
76 // --(END CUSTOM CODE: Schema Methods)--
77 
78  /// \name Member accessor
79  /// @{
80 
81  HD_API
83 
84  /// The "inheritable" flag indicates if this purpose schema should be
85  /// inherited by the HdFlattenedPurposeDataSourceProvider.
86  HD_API
88 
89  /// The "purpose" concept in Hydra is modelled after the UsdGeomImageable
90  /// concept, which allows prim types to define a purpose fallback value to
91  /// be used when no purpose value is found on a prim or its ancestors. The
92  /// Hydra schema transports this fallback, if present, to apply it during
93  /// flattening.
94  HD_API
96 
97  /// @}
98 
99  /// \name Schema location
100  /// @{
101 
102  /// Returns a token where the container representing this schema is found in
103  /// a container by default.
104  HD_API
105  static const TfToken &GetSchemaToken();
106 
107  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
108  /// where the container representing this schema is found by default.
109  HD_API
110  static const HdDataSourceLocator &GetDefaultLocator();
111 
112  /// @}
113 
114  /// \name Schema construction
115  /// @{
116 
117  /// \deprecated Use Builder instead.
118  ///
119  /// Builds a container data source which includes the provided child data
120  /// sources. Parameters with nullptr values are excluded. This is a
121  /// low-level interface. For cases in which it's desired to define
122  /// the container with a sparse set of child fields, the Builder class
123  /// is often more convenient and readable.
124  HD_API
125  static HdContainerDataSourceHandle
127  const HdTokenDataSourceHandle &purpose,
128  const HdBoolDataSourceHandle &inheritable,
129  const HdTokenDataSourceHandle &fallback
130  );
131 
132  /// \class HdPurposeSchema::Builder
133  ///
134  /// Utility class for setting sparse sets of child data source fields to be
135  /// filled as arguments into BuildRetained. Because all setter methods
136  /// return a reference to the instance, this can be used in the "builder
137  /// pattern" form.
138  class Builder
139  {
140  public:
141  HD_API
143  const HdTokenDataSourceHandle &purpose);
144  HD_API
146  const HdBoolDataSourceHandle &inheritable);
147  HD_API
149  const HdTokenDataSourceHandle &fallback);
150 
151  /// Returns a container data source containing the members set thus far.
152  HD_API
153  HdContainerDataSourceHandle Build();
154 
155  private:
156  HdTokenDataSourceHandle _purpose;
157  HdBoolDataSourceHandle _inheritable;
158  HdTokenDataSourceHandle _fallback;
159 
160  };
161 
162  /// @}
163 };
164 
166 
167 #endif
static HD_API const TfToken & GetSchemaToken()
HD_API Builder & SetInheritable(const HdBoolDataSourceHandle &inheritable)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
#define HD_PURPOSE_SCHEMA_TOKENS
Definition: purposeSchema.h:35
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
static HD_API HdPurposeSchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
HD_API Builder & SetPurpose(const HdTokenDataSourceHandle &purpose)
HdPurposeSchema(HdContainerDataSourceHandle container)
Definition: purposeSchema.h:54
#define HD_API
Definition: api.h:23
static HD_API HdContainerDataSourceHandle BuildRetained(const HdTokenDataSourceHandle &purpose, const HdBoolDataSourceHandle &inheritable, const HdTokenDataSourceHandle &fallback)
HD_API HdBoolDataSourceHandle GetInheritable() const
HD_API Builder & SetFallback(const HdTokenDataSourceHandle &fallback)
Definition: token.h:70
HD_API HdTokenDataSourceHandle GetPurpose() const
HdBoolDataSource::Handle HdBoolDataSourceHandle
HD_API TfToken ResolvePurposeValue()
TF_DECLARE_PUBLIC_TOKENS(HdPurposeSchemaTokens, HD_API, HD_PURPOSE_SCHEMA_TOKENS)
HD_API HdTokenDataSourceHandle GetFallback() const
static HD_API const HdDataSourceLocator & GetDefaultLocator()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdTokenDataSource::Handle HdTokenDataSourceHandle