HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instancedBySchema.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_INSTANCED_BY_SCHEMA_H
19 #define PXR_IMAGING_HD_INSTANCED_BY_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_INSTANCED_BY_SCHEMA_TOKENS \
36  (instancedBy) \
37  (paths) \
38  (prototypeRoots) \
39 
40 TF_DECLARE_PUBLIC_TOKENS(HdInstancedBySchemaTokens, HD_API,
42 
43 //-----------------------------------------------------------------------------
44 
45 
46 /// \class HdInstancedBySchema
47 ///
48 /// A schema marking a prim as instanced by another prim.
49 ///
50 /// Many renderers need to know not what prototypes an instancer has, but
51 /// rather what instancers a prototype has; this is encoded in "instancedBy". A
52 /// prim is "instancedBy" /Instancer if /Instancer has a prototype path that's
53 /// a parent of the prim. A complicating exception is if /A instances /A/B,
54 /// which instances /A/B/C, we don't consider /A to be instancing /A/B/C
55 /// directly; this is to support nested explicit instancing of things like
56 /// leaves/trees/forests.
57 ///
58 /// This value is computed based on the instancer topology of instancer prims
59 /// in the scene.
60 ///
61 /// Note: if multiple instancers reference a prototype, it's possible for
62 /// instancedBy to contain multiple entries. Some renderers may be able to read
63 /// this directly, but some may need to duplicate prims with an op so that each
64 /// prim has a single instancer, depending on how the renderer exposes
65 /// instancing.
66 ///
68 {
69 public:
70  /// \name Schema retrieval
71  /// @{
72 
73  HdInstancedBySchema(HdContainerDataSourceHandle container)
74  : HdSchema(container) {}
75 
76  /// Retrieves a container data source with the schema's default name token
77  /// "instancedBy" from the parent container and constructs a
78  /// HdInstancedBySchema instance.
79  /// Because the requested container data source may not exist, the result
80  /// should be checked with IsDefined() or a bool comparison before use.
81  HD_API
83  const HdContainerDataSourceHandle &fromParentContainer);
84 
85  /// @}
86 
87 // --(BEGIN CUSTOM CODE: Schema Methods)--
88 // --(END CUSTOM CODE: Schema Methods)--
89 
90  /// \name Member accessor
91  /// @{
92 
93  HD_API
95 
96  HD_API
98 
99  /// @}
100 
101  /// \name Schema location
102  /// @{
103 
104  /// Returns a token where the container representing this schema is found in
105  /// a container by default.
106  HD_API
107  static const TfToken &GetSchemaToken();
108 
109  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
110  /// where the container representing this schema is found by default.
111  HD_API
112  static const HdDataSourceLocator &GetDefaultLocator();
113 
114  /// @}
115 
116  /// \name Data source locators for members
117  ///
118  /// The following methods return an HdDataSourceLocator (relative to the
119  /// prim-level data source) where the data source for a member can be found.
120  ///
121  /// This is often useful for checking intersection against the
122  /// HdDataSourceLocatorSet sent with HdDataSourceObserver::PrimsDirtied.
123  /// @{
124 
125  /// Prim-level relative data source locator to locate paths.
126  HD_API
127  static const HdDataSourceLocator &GetPathsLocator();
128  /// @}
129 
130  /// \name Schema construction
131  /// @{
132 
133  /// \deprecated Use Builder instead.
134  ///
135  /// Builds a container data source which includes the provided child data
136  /// sources. Parameters with nullptr values are excluded. This is a
137  /// low-level interface. For cases in which it's desired to define
138  /// the container with a sparse set of child fields, the Builder class
139  /// is often more convenient and readable.
140  HD_API
141  static HdContainerDataSourceHandle
143  const HdPathArrayDataSourceHandle &paths,
144  const HdPathArrayDataSourceHandle &prototypeRoots
145  );
146 
147  /// \class HdInstancedBySchema::Builder
148  ///
149  /// Utility class for setting sparse sets of child data source fields to be
150  /// filled as arguments into BuildRetained. Because all setter methods
151  /// return a reference to the instance, this can be used in the "builder
152  /// pattern" form.
153  class Builder
154  {
155  public:
156  HD_API
157  Builder &SetPaths(
158  const HdPathArrayDataSourceHandle &paths);
159  HD_API
161  const HdPathArrayDataSourceHandle &prototypeRoots);
162 
163  /// Returns a container data source containing the members set thus far.
164  HD_API
165  HdContainerDataSourceHandle Build();
166 
167  private:
169  HdPathArrayDataSourceHandle _prototypeRoots;
170 
171  };
172 
173  /// @}
174 };
175 
177 
178 #endif
static HD_API const HdDataSourceLocator & GetPathsLocator()
Prim-level relative data source locator to locate paths.
HD_API HdPathArrayDataSourceHandle GetPaths() const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
static HD_API const TfToken & GetSchemaToken()
HdPathArrayDataSource::Handle HdPathArrayDataSourceHandle
#define HD_API
Definition: api.h:23
Definition: token.h:70
static HD_API const HdDataSourceLocator & GetDefaultLocator()
HD_API HdPathArrayDataSourceHandle GetPrototypeRoots() const
#define HD_INSTANCED_BY_SCHEMA_TOKENS
TF_DECLARE_PUBLIC_TOKENS(HdInstancedBySchemaTokens, HD_API, HD_INSTANCED_BY_SCHEMA_TOKENS)
HD_API Builder & SetPaths(const HdPathArrayDataSourceHandle &paths)
static HD_API HdInstancedBySchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
HdInstancedBySchema(HdContainerDataSourceHandle container)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
static HD_API HdContainerDataSourceHandle BuildRetained(const HdPathArrayDataSourceHandle &paths, const HdPathArrayDataSourceHandle &prototypeRoots)
HD_API Builder & SetPrototypeRoots(const HdPathArrayDataSourceHandle &prototypeRoots)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.