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 
118 {
119 public:
124 
129  explicit UsdAPISchemaBase(const UsdPrim& prim=UsdPrim())
130  : UsdSchemaBase(prim)
131  {
132  }
133 
137  explicit UsdAPISchemaBase(const UsdSchemaBase& schemaObj)
138  : UsdSchemaBase(schemaObj)
139  {
140  }
141 
143  USD_API
144  virtual ~UsdAPISchemaBase() = 0;
145 
149  USD_API
150  static const TfTokenVector &
151  GetSchemaAttributeNames(bool includeInherited=true);
152 
153 
154 protected:
158  USD_API
159  UsdSchemaType _GetSchemaType() const override;
160 
161 private:
162  // needs to invoke _GetStaticTfType.
163  friend class UsdSchemaRegistry;
164  USD_API
165  static const TfType &_GetStaticTfType();
166 
167  static bool _IsTypedSchema();
168 
169  // override SchemaBase virtuals.
170  USD_API
171  const TfType &_GetTfType() const override;
172 
173 public:
174  // ===================================================================== //
175  // Feel free to add custom code below this line, it will be preserved by
176  // the code generator.
177  //
178  // Just remember to:
179  // - Close the class declaration with };
180  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
181  // - Close the include guard with #endif
182  // ===================================================================== //
183  // --(BEGIN CUSTOM CODE)--
184 
185 protected:
188  explicit UsdAPISchemaBase(const UsdPrim& prim,
189  const TfToken &instanceName)
190  : UsdSchemaBase(prim)
191  , _instanceName(instanceName)
192  {
193  }
194 
197  explicit UsdAPISchemaBase(const UsdSchemaBase& schemaObj,
198  const TfToken &instanceName)
199  : UsdSchemaBase(schemaObj)
200  , _instanceName(instanceName)
201  {
202  }
203 
209  const TfToken &_GetInstanceName() const {
210  return _instanceName;
211  }
212 
213 protected:
234  template <typename APISchemaType>
235  static APISchemaType _ApplyAPISchema(
236  const UsdPrim &prim,
237  const TfToken &apiSchemaName)
238  {
239  return APISchemaType(_ApplyAPISchemaImpl(prim, apiSchemaName));
240  }
241 
266  template <typename APISchemaType>
267  static APISchemaType _MultipleApplyAPISchema(
268  const UsdPrim &prim,
269  const TfToken &apiSchemaName,
270  const TfToken &instanceName)
271  {
272  if (instanceName.IsEmpty()) {
273  TF_CODING_ERROR("Instance name is empty!");
274  return APISchemaType();
275  }
276 
277  TfToken apiName(SdfPath::JoinIdentifier(apiSchemaName, instanceName));
278  return APISchemaType(_ApplyAPISchemaImpl(prim, apiName), instanceName);
279  }
280 
293  USD_API
294  bool _IsCompatible() const override;
295 
296 private:
297  // Helper method for adding 'apiName' to the apiSchemas metadata on the
298  // prim at 'path' on the given 'stage'.
299  USD_API
300  static UsdPrim _ApplyAPISchemaImpl(
301  const UsdPrim &prim,
302  const TfToken &apiName);
303 
304  // The instance name associated with this schema object, if it is a
305  // multiple-apply API schema. For example, in the case of UsdCollectionAPI,
306  // this will hold the name of the collection.
307  TfToken _instanceName;
308 };
309 
310 PXR_NAMESPACE_CLOSE_SCOPE
311 
312 #endif
virtual USD_API ~UsdAPISchemaBase()=0
Destructor.
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
UsdAPISchemaBase(const UsdSchemaBase &schemaObj, const TfToken &instanceName)
Construct a multiple-apply UsdAPISchemaBase on the prim held by schemaObj with the given instanceName...
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:87
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.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:149
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
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 SDF_API std::string JoinIdentifier(const std::vector< std::string > &names)
Join names into a single identifier using the namespace delimiter.
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:43
bool IsEmpty() const
Returns true iff this token contains the empty string &quot;&quot;.
Definition: token.h:311
TfType represents a dynamic runtime type.
Definition: type.h:70
Singleton registry that provides access to prim and property definition information for registered Us...
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
Represents abstract or base schema types that are interface-only and cannot be instantiated.
USD_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
const TfToken & _GetInstanceName() const
Returns the instance name of the API schema object belonging to a multiple-apply API schema...