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 USDRENDER_GENERATED_SETTINGSAPI_H
25 #define USDRENDER_GENERATED_SETTINGSAPI_H
26 
27 /// \file usdRender/settingsAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdRender/api.h"
31 #include "pxr/usd/usd/apiSchemaBase.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 
35 #include "pxr/base/vt/value.h"
36 
37 #include "pxr/base/gf/vec3d.h"
38 #include "pxr/base/gf/vec3f.h"
39 #include "pxr/base/gf/matrix4d.h"
40 
41 #include "pxr/base/tf/token.h"
42 #include "pxr/base/tf/type.h"
43 
44 PXR_NAMESPACE_OPEN_SCOPE
45 
46 class SdfAssetPath;
47 
48 // -------------------------------------------------------------------------- //
49 // RENDERSETTINGSAPI                                                          //
50 // -------------------------------------------------------------------------- //
51 
52 /// \class UsdRenderSettingsAPI
53 ///
54 /// UsdRenderSettingsAPI is a base class for API schemas
55 /// to encode renderer-specific settings.
56 ///
57 class UsdRenderSettingsAPI : public UsdAPISchemaBase
58 {
59 public:
60     /// Compile time constant representing what kind of schema this class is.
61     ///
62     /// \sa UsdSchemaKind
63     static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
64 
65     /// Construct a UsdRenderSettingsAPI on UsdPrim \p prim .
66     /// Equivalent to UsdRenderSettingsAPI::Get(prim.GetStage(), prim.GetPath())
67     /// for a \em valid \p prim, but will not immediately throw an error for
68     /// an invalid \p prim
69     explicit UsdRenderSettingsAPI(const UsdPrim& prim=UsdPrim())
UsdAPISchemaBase(prim)70         : UsdAPISchemaBase(prim)
71     {
72     }
73 
74     /// Construct a UsdRenderSettingsAPI on the prim held by \p schemaObj .
75     /// Should be preferred over UsdRenderSettingsAPI(schemaObj.GetPrim()),
76     /// as it preserves SchemaBase state.
UsdRenderSettingsAPI(const UsdSchemaBase & schemaObj)77     explicit UsdRenderSettingsAPI(const UsdSchemaBase& schemaObj)
78         : UsdAPISchemaBase(schemaObj)
79     {
80     }
81 
82     /// Destructor.
83     USDRENDER_API
84     virtual ~UsdRenderSettingsAPI();
85 
86     /// Return a vector of names of all pre-declared attributes for this schema
87     /// class and all its ancestor classes.  Does not include attributes that
88     /// may be authored by custom/extended methods of the schemas involved.
89     USDRENDER_API
90     static const TfTokenVector &
91     GetSchemaAttributeNames(bool includeInherited=true);
92 
93     /// Return a UsdRenderSettingsAPI holding the prim adhering to this
94     /// schema at \p path on \p stage.  If no prim exists at \p path on
95     /// \p stage, or if the prim at that path does not adhere to this schema,
96     /// return an invalid schema object.  This is shorthand for the following:
97     ///
98     /// \code
99     /// UsdRenderSettingsAPI(stage->GetPrimAtPath(path));
100     /// \endcode
101     ///
102     USDRENDER_API
103     static UsdRenderSettingsAPI
104     Get(const UsdStagePtr &stage, const SdfPath &path);
105 
106 
107     /// Returns true if this <b>single-apply</b> API schema can be applied to
108     /// the given \p prim. If this schema can not be a applied to the prim,
109     /// this returns false and, if provided, populates \p whyNot with the
110     /// reason it can not be applied.
111     ///
112     /// Note that if CanApply returns false, that does not necessarily imply
113     /// that calling Apply will fail. Callers are expected to call CanApply
114     /// before calling Apply if they want to ensure that it is valid to
115     /// apply a schema.
116     ///
117     /// \sa UsdPrim::GetAppliedSchemas()
118     /// \sa UsdPrim::HasAPI()
119     /// \sa UsdPrim::CanApplyAPI()
120     /// \sa UsdPrim::ApplyAPI()
121     /// \sa UsdPrim::RemoveAPI()
122     ///
123     USDRENDER_API
124     static bool
125     CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
126 
127     /// Applies this <b>single-apply</b> API schema to the given \p prim.
128     /// This information is stored by adding "RenderSettingsAPI" to the
129     /// token-valued, listOp metadata \em apiSchemas on the prim.
130     ///
131     /// \return A valid UsdRenderSettingsAPI object is returned upon success.
132     /// An invalid (or empty) UsdRenderSettingsAPI object is returned upon
133     /// failure. See \ref UsdPrim::ApplyAPI() for conditions
134     /// resulting in failure.
135     ///
136     /// \sa UsdPrim::GetAppliedSchemas()
137     /// \sa UsdPrim::HasAPI()
138     /// \sa UsdPrim::CanApplyAPI()
139     /// \sa UsdPrim::ApplyAPI()
140     /// \sa UsdPrim::RemoveAPI()
141     ///
142     USDRENDER_API
143     static UsdRenderSettingsAPI
144     Apply(const UsdPrim &prim);
145 
146 protected:
147     /// Returns the kind of schema this class belongs to.
148     ///
149     /// \sa UsdSchemaKind
150     USDRENDER_API
151     UsdSchemaKind _GetSchemaKind() const override;
152 
153 private:
154     // needs to invoke _GetStaticTfType.
155     friend class UsdSchemaRegistry;
156     USDRENDER_API
157     static const TfType &_GetStaticTfType();
158 
159     static bool _IsTypedSchema();
160 
161     // override SchemaBase virtuals.
162     USDRENDER_API
163     const TfType &_GetTfType() const override;
164 
165 public:
166     // ===================================================================== //
167     // Feel free to add custom code below this line, it will be preserved by
168     // the code generator.
169     //
170     // Just remember to:
171     //  - Close the class declaration with };
172     //  - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
173     //  - Close the include guard with #endif
174     // ===================================================================== //
175     // --(BEGIN CUSTOM CODE)--
176 };
177 
178 PXR_NAMESPACE_CLOSE_SCOPE
179 
180 #endif
181