All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nodeDefAPI.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 #ifndef USDSHADE_GENERATED_NODEDEFAPI_H
25 #define USDSHADE_GENERATED_NODEDEFAPI_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdShade/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
35 
36 #include "pxr/usd/ndr/declare.h"
37 #include "pxr/usd/sdr/shaderNode.h"
38 
39 
40 #include "pxr/base/vt/value.h"
41 
42 #include "pxr/base/gf/vec3d.h"
43 #include "pxr/base/gf/vec3f.h"
44 #include "pxr/base/gf/matrix4d.h"
45 
46 #include "pxr/base/tf/token.h"
47 #include "pxr/base/tf/type.h"
48 
49 PXR_NAMESPACE_OPEN_SCOPE
50 
51 class SdfAssetPath;
52 
53 // -------------------------------------------------------------------------- //
54 // NODEDEFAPI //
55 // -------------------------------------------------------------------------- //
56 
85 {
86 public:
91 
96  explicit UsdShadeNodeDefAPI(const UsdPrim& prim=UsdPrim())
97  : UsdAPISchemaBase(prim)
98  {
99  }
100 
104  explicit UsdShadeNodeDefAPI(const UsdSchemaBase& schemaObj)
105  : UsdAPISchemaBase(schemaObj)
106  {
107  }
108 
110  USDSHADE_API
111  virtual ~UsdShadeNodeDefAPI();
112 
116  USDSHADE_API
117  static const TfTokenVector &
118  GetSchemaAttributeNames(bool includeInherited=true);
119 
129  USDSHADE_API
130  static UsdShadeNodeDefAPI
131  Get(const UsdStagePtr &stage, const SdfPath &path);
132 
133 
150  USDSHADE_API
151  static bool
152  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
153 
169  USDSHADE_API
170  static UsdShadeNodeDefAPI
171  Apply(const UsdPrim &prim);
172 
173 protected:
177  USDSHADE_API
178  UsdSchemaKind _GetSchemaKind() const override;
179 
180 private:
181  // needs to invoke _GetStaticTfType.
182  friend class UsdSchemaRegistry;
183  USDSHADE_API
184  static const TfType &_GetStaticTfType();
185 
186  static bool _IsTypedSchema();
187 
188  // override SchemaBase virtuals.
189  USDSHADE_API
190  const TfType &_GetTfType() const override;
191 
192 public:
193  // --------------------------------------------------------------------- //
194  // IMPLEMENTATIONSOURCE
195  // --------------------------------------------------------------------- //
219  USDSHADE_API
221 
227  USDSHADE_API
228  UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
229 
230 public:
231  // --------------------------------------------------------------------- //
232  // ID
233  // --------------------------------------------------------------------- //
249  USDSHADE_API
250  UsdAttribute GetIdAttr() const;
251 
257  USDSHADE_API
258  UsdAttribute CreateIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
259 
260 public:
261  // ===================================================================== //
262  // Feel free to add custom code below this line, it will be preserved by
263  // the code generator.
264  //
265  // Just remember to:
266  // - Close the class declaration with };
267  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
268  // - Close the include guard with #endif
269  // ===================================================================== //
270  // --(BEGIN CUSTOM CODE)--
271 
272 
273  // -------------------------------------------------------------------------
281 
317  USDSHADE_API
319 
323  USDSHADE_API
324  bool SetShaderId(const TfToken &id) const;
325 
333  USDSHADE_API
334  bool GetShaderId(TfToken *id) const;
335 
341  USDSHADE_API
342  bool SetSourceAsset(
343  const SdfAssetPath &sourceAsset,
344  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
345 
361  USDSHADE_API
362  bool GetSourceAsset(
363  SdfAssetPath *sourceAsset,
364  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
365 
372  USDSHADE_API
374  const TfToken &subIdentifier,
375  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
376 
391  USDSHADE_API
393  TfToken *subIdentifier,
394  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
395 
401  USDSHADE_API
402  bool SetSourceCode(
403  const std::string &sourceCode,
404  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
405 
421  USDSHADE_API
422  bool GetSourceCode(
423  std::string *sourceCode,
424  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
425 
427  // -------------------------------------------------------------------------
428 
433  USDSHADE_API
434  SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType)
435  const;
436 
437 };
438 
439 PXR_NAMESPACE_CLOSE_SCOPE
440 
441 #endif
USDSHADE_API TfToken GetImplementationSource() const
Reads the value of info:implementationSource attribute and returns a token identifying the attribute ...
USDSHADE_API UsdAttribute GetImplementationSourceAttr() const
Specifies the attribute that should be consulted to get the shader's implementation or its source cod...
static USDSHADE_API UsdShadeNodeDefAPI Apply(const UsdPrim &prim)
Applies this single-apply API schema to the given prim.
USDSHADE_API UsdAttribute GetIdAttr() const
The id is an identifier for the type or purpose of the shader.
virtual USDSHADE_API ~UsdShadeNodeDefAPI()
Destructor.
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, sourceType.
UsdShadeNodeDefAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeNodeDefAPI on UsdPrim prim .
Definition: nodeDefAPI.h:96
The base class for all API schemas.
USDSHADE_API bool SetShaderId(const TfToken &id) const
Sets the shader's ID value.
UsdShadeNodeDefAPI is an API schema that provides attributes for a prim to select a corresponding Sha...
Definition: nodeDefAPI.h:84
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
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...
UsdShadeNodeDefAPI(const UsdSchemaBase &schemaObj)
Construct a UsdShadeNodeDefAPI on the prim held by schemaObj .
Definition: nodeDefAPI.h:104
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
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...
Single Apply API schema.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
USDSHADE_API SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType) const
This method attempts to ensure that there is a ShaderNode in the shader registry (i.e.
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 GetShaderId(TfToken *id) const
Fetches the shader's ID value from the info:id attribute, if the shader's info:implementationSource i...
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
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.
USDSHADE_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
USDSHADE_API bool SetSourceCode(const std::string &sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Sets the shader&#39;s source-code value to sourceCode for the given source type, sourceType.
USDSHADE_API bool GetSourceAsset(SdfAssetPath *sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader&#39;s source asset value for the specified sourceType value from the info:sourceType:s...
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.
TfType represents a dynamic runtime type.
Definition: type.h:64
Singleton registry that provides access to schema type information and the prim definitions for regis...
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.
The base class for all schema types in Usd.
Definition: schemaBase.h:56
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: nodeDefAPI.h:90
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
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...
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.