All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
nodeDefAPI.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 USDSHADE_GENERATED_NODEDEFAPI_H
8#define USDSHADE_GENERATED_NODEDEFAPI_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usdShade/api.h"
15#include "pxr/usd/usd/prim.h"
16#include "pxr/usd/usd/stage.h"
18
19#include "pxr/usd/ndr/declare.h"
21
22
23#include "pxr/base/vt/value.h"
24
25#include "pxr/base/gf/vec3d.h"
26#include "pxr/base/gf/vec3f.h"
28
29#include "pxr/base/tf/token.h"
30#include "pxr/base/tf/type.h"
31
32PXR_NAMESPACE_OPEN_SCOPE
33
34class SdfAssetPath;
35
36// -------------------------------------------------------------------------- //
37// NODEDEFAPI //
38// -------------------------------------------------------------------------- //
39
68{
69public:
73 static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
74
79 explicit UsdShadeNodeDefAPI(const UsdPrim& prim=UsdPrim())
80 : UsdAPISchemaBase(prim)
81 {
82 }
83
87 explicit UsdShadeNodeDefAPI(const UsdSchemaBase& schemaObj)
88 : UsdAPISchemaBase(schemaObj)
89 {
90 }
91
93 USDSHADE_API
95
99 USDSHADE_API
100 static const TfTokenVector &
101 GetSchemaAttributeNames(bool includeInherited=true);
102
112 USDSHADE_API
113 static UsdShadeNodeDefAPI
114 Get(const UsdStagePtr &stage, const SdfPath &path);
115
116
133 USDSHADE_API
134 static bool
135 CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
136
152 USDSHADE_API
153 static UsdShadeNodeDefAPI
154 Apply(const UsdPrim &prim);
155
156protected:
160 USDSHADE_API
162
163private:
164 // needs to invoke _GetStaticTfType.
165 friend class UsdSchemaRegistry;
166 USDSHADE_API
167 static const TfType &_GetStaticTfType();
168
169 static bool _IsTypedSchema();
170
171 // override SchemaBase virtuals.
172 USDSHADE_API
173 const TfType &_GetTfType() const override;
174
175public:
176 // --------------------------------------------------------------------- //
177 // IMPLEMENTATIONSOURCE
178 // --------------------------------------------------------------------- //
202 USDSHADE_API
204
210 USDSHADE_API
211 UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
212
213public:
214 // --------------------------------------------------------------------- //
215 // ID
216 // --------------------------------------------------------------------- //
232 USDSHADE_API
234
240 USDSHADE_API
241 UsdAttribute CreateIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
242
243public:
244 // ===================================================================== //
245 // Feel free to add custom code below this line, it will be preserved by
246 // the code generator.
247 //
248 // Just remember to:
249 // - Close the class declaration with };
250 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
251 // - Close the include guard with #endif
252 // ===================================================================== //
253 // --(BEGIN CUSTOM CODE)--
254
255
256 // -------------------------------------------------------------------------
264
300 USDSHADE_API
302
306 USDSHADE_API
307 bool SetShaderId(const TfToken &id) const;
308
316 USDSHADE_API
317 bool GetShaderId(TfToken *id) const;
318
324 USDSHADE_API
326 const SdfAssetPath &sourceAsset,
327 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
328
344 USDSHADE_API
346 SdfAssetPath *sourceAsset,
347 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
348
355 USDSHADE_API
357 const TfToken &subIdentifier,
358 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
359
374 USDSHADE_API
376 TfToken *subIdentifier,
377 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
378
384 USDSHADE_API
386 const std::string &sourceCode,
387 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
388
404 USDSHADE_API
406 std::string *sourceCode,
407 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
408
416 USDSHADE_API
417 std::vector<std::string> GetSourceTypes() const;
418
420 // -------------------------------------------------------------------------
421
426 USDSHADE_API
427 SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType)
428 const;
429
430};
431
432PXR_NAMESPACE_CLOSE_SCOPE
433
434#endif
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfType represents a dynamic runtime type.
Definition: type.h:48
The base class for all API schemas.
Definition: apiSchemaBase.h:99
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:160
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
The base class for all schema types in Usd.
Definition: schemaBase.h:39
Singleton registry that provides access to schema type information and the prim definitions for regis...
UsdShadeNodeDefAPI is an API schema that provides attributes for a prim to select a corresponding Sha...
Definition: nodeDefAPI.h:68
USDSHADE_API bool GetSourceCode(std::string *sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader's source code for the specified sourceType value by reading the info:sourceType:so...
USDSHADE_API bool GetSourceAsset(SdfAssetPath *sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader's source asset value for the specified sourceType value from the info:sourceType:s...
USDSHADE_API UsdAttribute GetImplementationSourceAttr() const
Specifies the attribute that should be consulted to get the shader's implementation or its source cod...
USDSHADE_API bool SetSourceAsset(const SdfAssetPath &sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Sets the shader's source-asset path value to sourceAsset for the given source type,...
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: nodeDefAPI.h:73
USDSHADE_API bool SetShaderId(const TfToken &id) const
Sets the shader's ID value.
USDSHADE_API UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetImplementationSourceAttr(), and also Create vs Get Property Methods for when to use Get vs Cre...
USDSHADE_API std::vector< std::string > GetSourceTypes() const
Fetches the source types for the specified prim value by reading the info:sourceType:<implementationS...
UsdShadeNodeDefAPI(const UsdSchemaBase &schemaObj)
Construct a UsdShadeNodeDefAPI on the prim held by schemaObj .
Definition: nodeDefAPI.h:87
virtual USDSHADE_API ~UsdShadeNodeDefAPI()
Destructor.
static USDSHADE_API UsdShadeNodeDefAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdShadeNodeDefAPI holding the prim adhering to this schema at path on stage.
UsdShadeNodeDefAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeNodeDefAPI on UsdPrim prim .
Definition: nodeDefAPI.h:79
static USDSHADE_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
Returns true if this single-apply API schema can be applied to the given prim.
USDSHADE_API bool SetSourceCode(const std::string &sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Sets the shader's source-code value to sourceCode for the given source type, sourceType.
USDSHADE_API TfToken GetImplementationSource() const
Reads the value of info:implementationSource attribute and returns a token identifying the attribute ...
static USDSHADE_API UsdShadeNodeDefAPI Apply(const UsdPrim &prim)
Applies this single-apply API schema to the given prim.
USDSHADE_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
static USDSHADE_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
USDSHADE_API bool GetSourceAssetSubIdentifier(TfToken *subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader's sub-identifier for the source asset with the specified sourceType value from the...
USDSHADE_API SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType) const
This method attempts to ensure that there is a ShaderNode in the shader registry (i....
USDSHADE_API bool SetSourceAssetSubIdentifier(const TfToken &subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Set a sub-identifier to be used with a source asset of the given source type.
USDSHADE_API bool GetShaderId(TfToken *id) const
Fetches the shader's ID value from the info:id attribute, if the shader's info:implementationSource i...
USDSHADE_API UsdAttribute GetIdAttr() const
The id is an identifier for the type or purpose of the shader.
USDSHADE_API UsdAttribute CreateIdAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetIdAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:112
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Common typedefs that are used throughout the NDR library.
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.