HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialXConfigAPI.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 USDMTLX_GENERATED_MATERIALXCONFIGAPI_H
8 #define USDMTLX_GENERATED_MATERIALXCONFIGAPI_H
9 
10 /// \file usdMtlx/materialXConfigAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdMtlx/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "pxr/usd/usdMtlx/tokens.h"
18 
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/gf/vec3d.h"
22 #include "pxr/base/gf/vec3f.h"
23 #include "pxr/base/gf/matrix4d.h"
24 
25 #include "pxr/base/tf/token.h"
26 #include "pxr/base/tf/type.h"
27 
29 
30 class SdfAssetPath;
31 
32 // -------------------------------------------------------------------------- //
33 // MATERIALXCONFIGAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdMtlxMaterialXConfigAPI
37 ///
38 /// MaterialXConfigAPI is an API schema that provides an interface for
39 /// storing information about the MaterialX environment.
40 ///
41 /// Initially, it only exposes an interface to record the MaterialX library
42 /// version that data was authored against. The intention is to use this
43 /// information to allow the MaterialX library to perform upgrades on data
44 /// from prior MaterialX versions.
45 ///
46 ///
48 {
49 public:
50  /// Compile time constant representing what kind of schema this class is.
51  ///
52  /// \sa UsdSchemaKind
54 
55  /// Construct a UsdMtlxMaterialXConfigAPI on UsdPrim \p prim .
56  /// Equivalent to UsdMtlxMaterialXConfigAPI::Get(prim.GetStage(), prim.GetPath())
57  /// for a \em valid \p prim, but will not immediately throw an error for
58  /// an invalid \p prim
59  explicit UsdMtlxMaterialXConfigAPI(const UsdPrim& prim=UsdPrim())
60  : UsdAPISchemaBase(prim)
61  {
62  }
63 
64  /// Construct a UsdMtlxMaterialXConfigAPI on the prim held by \p schemaObj .
65  /// Should be preferred over UsdMtlxMaterialXConfigAPI(schemaObj.GetPrim()),
66  /// as it preserves SchemaBase state.
67  explicit UsdMtlxMaterialXConfigAPI(const UsdSchemaBase& schemaObj)
68  : UsdAPISchemaBase(schemaObj)
69  {
70  }
71 
72  /// Destructor.
75 
76  /// Return a vector of names of all pre-declared attributes for this schema
77  /// class and all its ancestor classes. Does not include attributes that
78  /// may be authored by custom/extended methods of the schemas involved.
80  static const TfTokenVector &
81  GetSchemaAttributeNames(bool includeInherited=true);
82 
83  /// Return a UsdMtlxMaterialXConfigAPI holding the prim adhering to this
84  /// schema at \p path on \p stage. If no prim exists at \p path on
85  /// \p stage, or if the prim at that path does not adhere to this schema,
86  /// return an invalid schema object. This is shorthand for the following:
87  ///
88  /// \code
89  /// UsdMtlxMaterialXConfigAPI(stage->GetPrimAtPath(path));
90  /// \endcode
91  ///
94  Get(const UsdStagePtr &stage, const SdfPath &path);
95 
96 
97  /// Returns true if this <b>single-apply</b> API schema can be applied to
98  /// the given \p prim. If this schema can not be a applied to the prim,
99  /// this returns false and, if provided, populates \p whyNot with the
100  /// reason it can not be applied.
101  ///
102  /// Note that if CanApply returns false, that does not necessarily imply
103  /// that calling Apply will fail. Callers are expected to call CanApply
104  /// before calling Apply if they want to ensure that it is valid to
105  /// apply a schema.
106  ///
107  /// \sa UsdPrim::GetAppliedSchemas()
108  /// \sa UsdPrim::HasAPI()
109  /// \sa UsdPrim::CanApplyAPI()
110  /// \sa UsdPrim::ApplyAPI()
111  /// \sa UsdPrim::RemoveAPI()
112  ///
114  static bool
115  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
116 
117  /// Applies this <b>single-apply</b> API schema to the given \p prim.
118  /// This information is stored by adding "MaterialXConfigAPI" to the
119  /// token-valued, listOp metadata \em apiSchemas on the prim.
120  ///
121  /// \return A valid UsdMtlxMaterialXConfigAPI object is returned upon success.
122  /// An invalid (or empty) UsdMtlxMaterialXConfigAPI object is returned upon
123  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
124  /// resulting in failure.
125  ///
126  /// \sa UsdPrim::GetAppliedSchemas()
127  /// \sa UsdPrim::HasAPI()
128  /// \sa UsdPrim::CanApplyAPI()
129  /// \sa UsdPrim::ApplyAPI()
130  /// \sa UsdPrim::RemoveAPI()
131  ///
134  Apply(const UsdPrim &prim);
135 
136 protected:
137  /// Returns the kind of schema this class belongs to.
138  ///
139  /// \sa UsdSchemaKind
141  UsdSchemaKind _GetSchemaKind() const override;
142 
143 private:
144  // needs to invoke _GetStaticTfType.
145  friend class UsdSchemaRegistry;
147  static const TfType &_GetStaticTfType();
148 
149  static bool _IsTypedSchema();
150 
151  // override SchemaBase virtuals.
153  const TfType &_GetTfType() const override;
154 
155 public:
156  // --------------------------------------------------------------------- //
157  // CONFIGMTLXVERSION
158  // --------------------------------------------------------------------- //
159  /// MaterialX library version that the data has been authored
160  /// against. Defaults to 1.38 to allow correct verisoning of old files.
161  ///
162  /// | ||
163  /// | -- | -- |
164  /// | Declaration | `string config:mtlx:version = "1.38"` |
165  /// | C++ Type | std::string |
166  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String |
169 
170  /// See GetConfigMtlxVersionAttr(), and also
171  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
172  /// If specified, author \p defaultValue as the attribute's default,
173  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
174  /// the default for \p writeSparsely is \c false.
176  UsdAttribute CreateConfigMtlxVersionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
177 
178 public:
179  // ===================================================================== //
180  // Feel free to add custom code below this line, it will be preserved by
181  // the code generator.
182  //
183  // Just remember to:
184  // - Close the class declaration with };
185  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
186  // - Close the include guard with #endif
187  // ===================================================================== //
188  // --(BEGIN CUSTOM CODE)--
189 };
190 
192 
193 #endif
static USDMTLX_API UsdMtlxMaterialXConfigAPI Apply(const UsdPrim &prim)
static USDMTLX_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDMTLX_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDMTLX_API UsdAttribute CreateConfigMtlxVersionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
UsdMtlxMaterialXConfigAPI(const UsdPrim &prim=UsdPrim())
Definition: path.h:273
UsdSchemaKind
Definition: common.h:112
virtual USDMTLX_API ~UsdMtlxMaterialXConfigAPI()
Destructor.
static USDMTLX_API UsdMtlxMaterialXConfigAPI Get(const UsdStagePtr &stage, const SdfPath &path)
static const UsdSchemaKind schemaKind
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
USDMTLX_API UsdSchemaKind _GetSchemaKind() const override
UsdMtlxMaterialXConfigAPI(const UsdSchemaBase &schemaObj)
#define USDMTLX_API
Definition: api.h:23
Definition: value.h:146
USDMTLX_API UsdAttribute GetConfigMtlxVersionAttr() const