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 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 ////////////////////////////////////////////////////////////////////////
25 
26 /* ************************************************************************** */
27 /* ** ** */
28 /* ** This file is generated by a script. ** */
29 /* ** ** */
30 /* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
31 /* ** Edit hdGen/schema.py instead to make changes. ** */
32 /* ** ** */
33 /* ************************************************************************** */
34 
35 #ifndef PXR_IMAGING_HD_INSTANCED_BY_SCHEMA_H
36 #define PXR_IMAGING_HD_INSTANCED_BY_SCHEMA_H
37 
38 #include "pxr/imaging/hd/api.h"
39 
40 #include "pxr/imaging/hd/schema.h"
41 
42 // --(BEGIN CUSTOM CODE: Includes)--
43 // --(END CUSTOM CODE: Includes)--
44 
46 
47 //-----------------------------------------------------------------------------
48 
49 // --(BEGIN CUSTOM CODE: Declares)--
50 // --(END CUSTOM CODE: Declares)--
51 
52 //-----------------------------------------------------------------------------
53 
54 #define HD_INSTANCED_BY_SCHEMA_TOKENS \
55  (instancedBy) \
56  (paths) \
57  (prototypeRoots) \
58 
59 TF_DECLARE_PUBLIC_TOKENS(HdInstancedBySchemaTokens, HD_API,
61 
62 //-----------------------------------------------------------------------------
63 // A schema marking a prim as instanced by another prim.
64 //
65 // Many renderers need to know not what prototypes an instancer has, but
66 // rather what instancers a prototype has; this is encoded in "instancedBy". A
67 // prim is "instancedBy" /Instancer if /Instancer has a prototype path that's
68 // a parent of the prim. A complicating exception is if /A instances /A/B,
69 // which instances /A/B/C, we don't consider /A to be instancing /A/B/C
70 // directly; this is to support nested explicit instancing of things like
71 // leaves/trees/forests.
72 //
73 // This value is computed based on the instancer topology of instancer prims
74 // in the scene.
75 //
76 // Note: if multiple instancers reference a prototype, it's possible for
77 // instancedBy to contain multiple entries. Some renderers may be able to read
78 // this directly, but some may need to duplicate prims with an op so that each
79 // prim has a single instancer, depending on how the renderer exposes
80 // instancing.
81 //
83 {
84 public:
85  HdInstancedBySchema(HdContainerDataSourceHandle container)
86  : HdSchema(container) {}
87 
88 // --(BEGIN CUSTOM CODE: Schema Methods)--
89 // --(END CUSTOM CODE: Schema Methods)--
90 
91  //ACCESSORS
92 
93 
94  HD_API
96 
97  HD_API
99 
100  // RETRIEVING AND CONSTRUCTING
101 
102  /// Builds a container data source which includes the provided child data
103  /// sources. Parameters with nullptr values are excluded. This is a
104  /// low-level interface. For cases in which it's desired to define
105  /// the container with a sparse set of child fields, the Builder class
106  /// is often more convenient and readable.
107  HD_API
108  static HdContainerDataSourceHandle
110  const HdPathArrayDataSourceHandle &paths,
111  const HdPathArrayDataSourceHandle &prototypeRoots
112  );
113 
114  /// \class HdInstancedBySchema::Builder
115  ///
116  /// Utility class for setting sparse sets of child data source fields to be
117  /// filled as arguments into BuildRetained. Because all setter methods
118  /// return a reference to the instance, this can be used in the "builder
119  /// pattern" form.
120  class Builder
121  {
122  public:
123  HD_API
124  Builder &SetPaths(
125  const HdPathArrayDataSourceHandle &paths);
126  HD_API
128  const HdPathArrayDataSourceHandle &prototypeRoots);
129 
130  /// Returns a container data source containing the members set thus far.
131  HD_API
132  HdContainerDataSourceHandle Build();
133 
134  private:
136  HdPathArrayDataSourceHandle _prototypeRoots;
137  };
138 
139  /// Retrieves a container data source with the schema's default name token
140  /// "instancedBy" from the parent container and constructs a
141  /// HdInstancedBySchema instance.
142  /// Because the requested container data source may not exist, the result
143  /// should be checked with IsDefined() or a bool comparison before use.
144  HD_API
146  const HdContainerDataSourceHandle &fromParentContainer);
147 
148  /// Returns a token where the container representing this schema is found in
149  /// a container by default.
150  HD_API
151  static const TfToken &GetSchemaToken();
152 
153  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
154  /// where the container representing this schema is found by default.
155  HD_API
156  static const HdDataSourceLocator &GetDefaultLocator();
157 
158 };
159 
161 
162 #endif
static HD_API const TfToken & GetSchemaToken()
HdPathArrayDataSource::Handle HdPathArrayDataSourceHandle
#define HD_API
Definition: api.h:40
Definition: token.h:87
static HD_API const HdDataSourceLocator & GetDefaultLocator()
#define HD_INSTANCED_BY_SCHEMA_TOKENS
TF_DECLARE_PUBLIC_TOKENS(HdInstancedBySchemaTokens, HD_API, HD_INSTANCED_BY_SCHEMA_TOKENS)
HD_API HdPathArrayDataSourceHandle GetPaths()
HD_API Builder & SetPaths(const HdPathArrayDataSourceHandle &paths)
static HD_API HdInstancedBySchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
HdInstancedBySchema(HdContainerDataSourceHandle container)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
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.
HD_API HdPathArrayDataSourceHandle GetPrototypeRoots()