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 USDCONTRIVED_GENERATED_MULTIPLEAPPLYAPI_H
25 #define USDCONTRIVED_GENERATED_MULTIPLEAPPLYAPI_H
26 
27 /// \file usdContrived/multipleApplyAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdContrived/api.h"
31 #include "pxr/usd/usd/aPISchemaBase.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdContrived/tokens.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
45 namespace foo { namespace bar { namespace baz {
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // MULTIPLEAPPLYAPI                                                           //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdContrivedMultipleApplyAPI
54 ///
55 ///
56 class UsdContrivedMultipleApplyAPI : public UsdAPISchemaBase
57 {
58 public:
59     /// Compile time constant representing what kind of schema this class is.
60     ///
61     /// \sa UsdSchemaKind
62     static const UsdSchemaKind schemaKind = UsdSchemaKind::MultipleApplyAPI;
63 
64     /// Construct a UsdContrivedMultipleApplyAPI on UsdPrim \p prim with
65     /// name \p name . Equivalent to
66     /// UsdContrivedMultipleApplyAPI::Get(
67     ///    prim.GetStage(),
68     ///    prim.GetPath().AppendProperty(
69     ///        "test:name"));
70     ///
71     /// for a \em valid \p prim, but will not immediately throw an error for
72     /// an invalid \p prim
73     explicit UsdContrivedMultipleApplyAPI(
74         const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
UsdAPISchemaBase(prim,name)75         : UsdAPISchemaBase(prim, /*instanceName*/ name)
76     { }
77 
78     /// Construct a UsdContrivedMultipleApplyAPI on the prim held by \p schemaObj with
79     /// name \p name.  Should be preferred over
80     /// UsdContrivedMultipleApplyAPI(schemaObj.GetPrim(), name), as it preserves
81     /// SchemaBase state.
UsdContrivedMultipleApplyAPI(const UsdSchemaBase & schemaObj,const TfToken & name)82     explicit UsdContrivedMultipleApplyAPI(
83         const UsdSchemaBase& schemaObj, const TfToken &name)
84         : UsdAPISchemaBase(schemaObj, /*instanceName*/ name)
85     { }
86 
87     /// Destructor.
88     USDCONTRIVED_API
89     virtual ~UsdContrivedMultipleApplyAPI();
90 
91     /// Return a vector of names of all pre-declared attributes for this schema
92     /// class and all its ancestor classes for a given instance name.  Does not
93     /// include attributes that may be authored by custom/extended methods of
94     /// the schemas involved. The names returned will have the proper namespace
95     /// prefix.
96     USDCONTRIVED_API
97     static const TfTokenVector &
98     GetSchemaAttributeNames(
99         bool includeInherited=true, const TfToken instanceName=TfToken());
100 
101     /// Returns the name of this multiple-apply schema instance
GetName()102     TfToken GetName() const {
103         return _GetInstanceName();
104     }
105 
106     /// Return a UsdContrivedMultipleApplyAPI holding the prim adhering to this
107     /// schema at \p path on \p stage.  If no prim exists at \p path on
108     /// \p stage, or if the prim at that path does not adhere to this schema,
109     /// return an invalid schema object.  \p path must be of the format
110     /// <path>.test:name .
111     ///
112     /// This is shorthand for the following:
113     ///
114     /// \code
115     /// TfToken name = SdfPath::StripNamespace(path.GetToken());
116     /// UsdContrivedMultipleApplyAPI(
117     ///     stage->GetPrimAtPath(path.GetPrimPath()), name);
118     /// \endcode
119     ///
120     USDCONTRIVED_API
121     static UsdContrivedMultipleApplyAPI
122     Get(const UsdStagePtr &stage, const SdfPath &path);
123 
124     /// Return a UsdContrivedMultipleApplyAPI with name \p name holding the
125     /// prim \p prim. Shorthand for UsdContrivedMultipleApplyAPI(prim, name);
126     USDCONTRIVED_API
127     static UsdContrivedMultipleApplyAPI
128     Get(const UsdPrim &prim, const TfToken &name);
129 
130     /// Checks if the given name \p baseName is the base name of a property
131     /// of MultipleApplyAPI.
132     USDCONTRIVED_API
133     static bool
134     IsSchemaPropertyBaseName(const TfToken &baseName);
135 
136     /// Checks if the given path \p path is of an API schema of type
137     /// MultipleApplyAPI. If so, it stores the instance name of
138     /// the schema in \p name and returns true. Otherwise, it returns false.
139     USDCONTRIVED_API
140     static bool
141     IsMultipleApplyAPIPath(const SdfPath &path, TfToken *name);
142 
143     /// Returns true if this <b>multiple-apply</b> API schema can be applied,
144     /// with the given instance name, \p name, to the given \p prim. If this
145     /// schema can not be a applied the prim, this returns false and, if
146     /// provided, populates \p whyNot with the reason it can not be applied.
147     ///
148     /// Note that if CanApply returns false, that does not necessarily imply
149     /// that calling Apply will fail. Callers are expected to call CanApply
150     /// before calling Apply if they want to ensure that it is valid to
151     /// apply a schema.
152     ///
153     /// \sa UsdPrim::GetAppliedSchemas()
154     /// \sa UsdPrim::HasAPI()
155     /// \sa UsdPrim::CanApplyAPI()
156     /// \sa UsdPrim::ApplyAPI()
157     /// \sa UsdPrim::RemoveAPI()
158     ///
159     USDCONTRIVED_API
160     static bool
161     CanApply(const UsdPrim &prim, const TfToken &name,
162              std::string *whyNot=nullptr);
163 
164     /// Applies this <b>multiple-apply</b> API schema to the given \p prim
165     /// along with the given instance name, \p name.
166     ///
167     /// This information is stored by adding "MultipleApplyAPI:<i>name</i>"
168     /// to the token-valued, listOp metadata \em apiSchemas on the prim.
169     /// For example, if \p name is 'instance1', the token
170     /// 'MultipleApplyAPI:instance1' is added to 'apiSchemas'.
171     ///
172     /// \return A valid UsdContrivedMultipleApplyAPI object is returned upon success.
173     /// An invalid (or empty) UsdContrivedMultipleApplyAPI object is returned upon
174     /// failure. See \ref UsdPrim::ApplyAPI() for
175     /// conditions resulting in failure.
176     ///
177     /// \sa UsdPrim::GetAppliedSchemas()
178     /// \sa UsdPrim::HasAPI()
179     /// \sa UsdPrim::CanApplyAPI()
180     /// \sa UsdPrim::ApplyAPI()
181     /// \sa UsdPrim::RemoveAPI()
182     ///
183     USDCONTRIVED_API
184     static UsdContrivedMultipleApplyAPI
185     Apply(const UsdPrim &prim, const TfToken &name);
186 
187 protected:
188     /// Returns the kind of schema this class belongs to.
189     ///
190     /// \sa UsdSchemaKind
191     USDCONTRIVED_API
192     UsdSchemaKind _GetSchemaKind() const override;
193 
194 private:
195     // needs to invoke _GetStaticTfType.
196     friend class UsdSchemaRegistry;
197     USDCONTRIVED_API
198     static const TfType &_GetStaticTfType();
199 
200     static bool _IsTypedSchema();
201 
202     // override SchemaBase virtuals.
203     USDCONTRIVED_API
204     const TfType &_GetTfType() const override;
205 
206 public:
207     // --------------------------------------------------------------------- //
208     // TESTATTRONE
209     // --------------------------------------------------------------------- //
210     ///
211     ///
212     /// | ||
213     /// | -- | -- |
214     /// | Declaration | `int testAttrOne` |
215     /// | C++ Type | int |
216     /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
217     USDCONTRIVED_API
218     UsdAttribute GetTestAttrOneAttr() const;
219 
220     /// See GetTestAttrOneAttr(), and also
221     /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
222     /// If specified, author \p defaultValue as the attribute's default,
223     /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
224     /// the default for \p writeSparsely is \c false.
225     USDCONTRIVED_API
226     UsdAttribute CreateTestAttrOneAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
227 
228 public:
229     // --------------------------------------------------------------------- //
230     // TESTATTRTWO
231     // --------------------------------------------------------------------- //
232     ///
233     ///
234     /// | ||
235     /// | -- | -- |
236     /// | Declaration | `double testAttrTwo` |
237     /// | C++ Type | double |
238     /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
239     USDCONTRIVED_API
240     UsdAttribute GetTestAttrTwoAttr() const;
241 
242     /// See GetTestAttrTwoAttr(), and also
243     /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
244     /// If specified, author \p defaultValue as the attribute's default,
245     /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
246     /// the default for \p writeSparsely is \c false.
247     USDCONTRIVED_API
248     UsdAttribute CreateTestAttrTwoAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
249 
250 public:
251     // ===================================================================== //
252     // Feel free to add custom code below this line, it will be preserved by
253     // the code generator.
254     //
255     // Just remember to:
256     //  - Close the class declaration with };
257     //  - Close the namespace with }}}
258     //  - Close the include guard with #endif
259     // ===================================================================== //
260     // --(BEGIN CUSTOM CODE)--
261 };
262 
263 }}}
264 
265 #endif
266