All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
apiSchemaBase.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 USD_GENERATED_APISCHEMABASE_H
25 #define USD_GENERATED_APISCHEMABASE_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usd/api.h"
31 #include "pxr/usd/usd/schemaBase.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 // APISCHEMABASE //
50 // -------------------------------------------------------------------------- //
51 
117 {
118 public:
123 
128  explicit UsdAPISchemaBase(const UsdPrim& prim=UsdPrim())
129  : UsdSchemaBase(prim)
130  {
131  }
132 
136  explicit UsdAPISchemaBase(const UsdSchemaBase& schemaObj)
137  : UsdSchemaBase(schemaObj)
138  {
139  }
140 
142  USD_API
143  virtual ~UsdAPISchemaBase() = 0;
144 
148  USD_API
149  static const TfTokenVector &
150  GetSchemaAttributeNames(bool includeInherited=true);
151 
152 
153 protected:
157  USD_API
158  UsdSchemaKind _GetSchemaKind() const override;
159 
160 private:
161  // needs to invoke _GetStaticTfType.
162  friend class UsdSchemaRegistry;
163  USD_API
164  static const TfType &_GetStaticTfType();
165 
166  static bool _IsTypedSchema();
167 
168  // override SchemaBase virtuals.
169  USD_API
170  const TfType &_GetTfType() const override;
171 
172 public:
173  // ===================================================================== //
174  // Feel free to add custom code below this line, it will be preserved by
175  // the code generator.
176  //
177  // Just remember to:
178  // - Close the class declaration with };
179  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
180  // - Close the include guard with #endif
181  // ===================================================================== //
182  // --(BEGIN CUSTOM CODE)--
183 
184 protected:
187  explicit UsdAPISchemaBase(const UsdPrim& prim,
188  const TfToken &instanceName)
189  : UsdSchemaBase(prim)
190  , _instanceName(instanceName)
191  {
192  }
193 
196  explicit UsdAPISchemaBase(const UsdSchemaBase& schemaObj,
197  const TfToken &instanceName)
198  : UsdSchemaBase(schemaObj)
199  , _instanceName(instanceName)
200  {
201  }
202 
208  const TfToken &_GetInstanceName() const {
209  return _instanceName;
210  }
211 
212 protected:
233  template <typename APISchemaType>
234  static APISchemaType _ApplyAPISchema(
235  const UsdPrim &prim,
236  const TfToken &apiSchemaName)
237  {
238  if (prim.ApplyAPI<APISchemaType>()) {
239  return APISchemaType(prim);
240  }
241  return APISchemaType();
242  }
243 
268  template <typename APISchemaType>
269  static APISchemaType _MultipleApplyAPISchema(
270  const UsdPrim &prim,
271  const TfToken &apiSchemaName,
272  const TfToken &instanceName)
273  {
274  if (prim.ApplyAPI<APISchemaType>(instanceName)) {
275  return APISchemaType(prim, instanceName);
276  }
277  return APISchemaType();
278  }
279 
292  USD_API
293  bool _IsCompatible() const override;
294 
295 private:
296  // The instance name associated with this schema object, if it is a
297  // multiple-apply API schema. For example, in the case of UsdCollectionAPI,
298  // this will hold the name of the collection.
299  TfToken _instanceName;
300 };
301 
302 PXR_NAMESPACE_CLOSE_SCOPE
303 
304 #endif
virtual USD_API ~UsdAPISchemaBase()=0
Destructor.
UsdAPISchemaBase(const UsdSchemaBase &schemaObj, const TfToken &instanceName)
Construct a multiple-apply UsdAPISchemaBase on the prim held by schemaObj with the given instanceName...
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
bool ApplyAPI() const
Applies a single-apply API schema with the given C++ type &#39;SchemaType&#39; to this prim in the current ed...
Definition: prim.h:700
UsdAPISchemaBase(const UsdPrim &prim=UsdPrim())
Construct a UsdAPISchemaBase on UsdPrim prim .
static APISchemaType _ApplyAPISchema(const UsdPrim &prim, const TfToken &apiSchemaName)
Helper method to apply a single-apply API schema with the given schema name apiSchemaName&#39; and C++ ty...
The base class for all API schemas.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
USD_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
USD_API bool _IsCompatible() const override
Check whether this APISchema object is valid for the currently held prim.
UsdAPISchemaBase(const UsdPrim &prim, const TfToken &instanceName)
Construct a multiple-apply UsdAPISchemaBase on UsdPrim prim with the specified instanceName.
static USD_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...
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
Represents abstract or base schema types that are interface-only and cannot be instantiated.
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...
UsdAPISchemaBase(const UsdSchemaBase &schemaObj)
Construct a UsdAPISchemaBase on the prim held by schemaObj .
static APISchemaType _MultipleApplyAPISchema(const UsdPrim &prim, const TfToken &apiSchemaName, const TfToken &instanceName)
Helper method to apply a multiple-apply API schema with the given schema name apiSchemaName&#39;, C++ type &#39;APISchemaType&#39; and instance name instanceName.
The base class for all schema types in Usd.
Definition: schemaBase.h:56
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
const TfToken & _GetInstanceName() const
Returns the instance name of the API schema object belonging to a multiple-apply API schema...