All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
modelAPI.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_MODELAPI_H
25 #define USD_GENERATED_MODELAPI_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usd/api.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 // MODELAPI //
50 // -------------------------------------------------------------------------- //
51 
73 {
74 public:
79 
84  explicit UsdModelAPI(const UsdPrim& prim=UsdPrim())
85  : UsdAPISchemaBase(prim)
86  {
87  }
88 
92  explicit UsdModelAPI(const UsdSchemaBase& schemaObj)
93  : UsdAPISchemaBase(schemaObj)
94  {
95  }
96 
98  USD_API
99  virtual ~UsdModelAPI();
100 
104  USD_API
105  static const TfTokenVector &
106  GetSchemaAttributeNames(bool includeInherited=true);
107 
117  USD_API
118  static UsdModelAPI
119  Get(const UsdStagePtr &stage, const SdfPath &path);
120 
121 
122 protected:
126  USD_API
127  UsdSchemaKind _GetSchemaKind() const override;
128 
129 private:
130  // needs to invoke _GetStaticTfType.
131  friend class UsdSchemaRegistry;
132  USD_API
133  static const TfType &_GetStaticTfType();
134 
135  static bool _IsTypedSchema();
136 
137  // override SchemaBase virtuals.
138  USD_API
139  const TfType &_GetTfType() const override;
140 
141 public:
142  // ===================================================================== //
143  // Feel free to add custom code below this line, it will be preserved by
144  // the code generator.
145  //
146  // Just remember to:
147  // - Close the class declaration with };
148  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
149  // - Close the include guard with #endif
150  // ===================================================================== //
151  // --(BEGIN CUSTOM CODE)--
152 
156 
162  KindValidationNone,
163  KindValidationModelHierarchy
164  };
165 
182  USD_API
183  bool GetKind(TfToken* kind) const;
184 
187  USD_API
188  bool SetKind(const TfToken& kind) const;
189 
205  USD_API
206  bool IsKind(const TfToken& baseKind,
207  KindValidation validation=KindValidationModelHierarchy) const;
208 
211  USD_API
212  bool IsModel() const;
213 
216  USD_API
217  bool IsGroup() const;
218 
220 
224 
231  USD_API
232  bool GetAssetIdentifier(SdfAssetPath *identifier) const;
233 
238  USD_API
239  void SetAssetIdentifier(const SdfAssetPath &identifier) const;
240 
246  USD_API
247  bool GetAssetName(std::string *assetName) const;
248 
253  USD_API
254  void SetAssetName(const std::string &assetName) const;
255 
267  USD_API
268  bool GetAssetVersion(std::string *version) const;
269 
274  USD_API
275  void SetAssetVersion(const std::string &version) const;
276 
286  USD_API
288  const;
289 
295  USD_API
296  void SetPayloadAssetDependencies(const VtArray<SdfAssetPath> &assetDeps)
297  const;
298 
308  USD_API
309  bool GetAssetInfo(VtDictionary *info) const;
310 
314  USD_API
315  void SetAssetInfo(const VtDictionary &info) const;
316 
318 
319 protected:
320 
321  template<typename T>
322  bool _GetAssetInfoByKey(const TfToken &key, T *val) const {
323  VtValue vtVal = GetPrim().GetAssetInfoByKey(key);
324  if (!vtVal.IsEmpty() && vtVal.IsHolding<T>()) {
325  *val = vtVal.UncheckedGet<T>();
326  return true;
327  }
328  return false;
329  }
330 };
331 
346 #define USDMODEL_ASSET_INFO_KEYS \
347  (identifier) \
348  (name) \
349  (version) \
350  (payloadAssetDependencies)
351 
352 TF_DECLARE_PUBLIC_TOKENS(UsdModelAPIAssetInfoKeys, USD_API, USDMODEL_ASSET_INFO_KEYS);
353 
354 PXR_NAMESPACE_CLOSE_SCOPE
355 
356 #endif
UsdModelAPI(const UsdSchemaBase &schemaObj)
Construct a UsdModelAPI on the prim held by schemaObj .
Definition: modelAPI.h:92
T const & UncheckedGet() const
Returns a const reference to the held object if the held object is of type T.
Definition: value.h:1090
USD_API void SetAssetVersion(const std::string &version) const
Sets the model&#39;s asset version string.
virtual USD_API ~UsdModelAPI()
Destructor.
#define USDMODEL_ASSET_INFO_KEYS
Definition: modelAPI.h:346
A map with string keys and VtValue values.
Definition: dictionary.h:63
bool IsHolding() const
Return true if this value is holding an object of type T, false otherwise.
Definition: value.h:1062
USD_API void SetAssetName(const std::string &assetName) const
Sets the model&#39;s asset name to assetName.
USD_API void SetAssetInfo(const VtDictionary &info) const
Sets the model&#39;s assetInfo dictionary to info in the current edit target.
USD_API bool IsModel() const
Return true if this prim represents a model, based on its kind metadata.
The base class for all API schemas.
KindValidation
Option for validating queries to a prim&#39;s kind metadata.
Definition: modelAPI.h:161
USD_API bool GetKind(TfToken *kind) const
Retrieve the authored kind for this prim.
Non-applied API schema.
USD_API bool GetAssetName(std::string *assetName) const
Returns the model&#39;s asset name from the composed assetInfo dictionary.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
static USD_API UsdModelAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdModelAPI holding the prim adhering to this schema at path on stage.
USD_API VtValue GetAssetInfoByKey(const TfToken &keyPath) const
Return the element identified by keyPath in this object&#39;s composed assetInfo dictionary.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
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
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:229
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
USD_API bool GetPayloadAssetDependencies(VtArray< SdfAssetPath > *assetDeps) const
Returns the list of asset dependencies referenced inside the payload of the model.
USD_API void SetPayloadAssetDependencies(const VtArray< SdfAssetPath > &assetDeps) const
Sets the list of external asset dependencies referenced inside the payload of a model.
USD_API bool IsKind(const TfToken &baseKind, KindValidation validation=KindValidationModelHierarchy) const
Return true if the prim&#39;s kind metadata is or inherits from baseKind as defined by the Kind Registry...
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
USD_API bool SetKind(const TfToken &kind) const
Author a kind for this prim, at the current UsdEditTarget.
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...
USD_API bool GetAssetInfo(VtDictionary *info) const
Returns the model&#39;s composed assetInfo dictionary.
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...
USD_API bool GetAssetIdentifier(SdfAssetPath *identifier) const
Returns the model&#39;s asset identifier as authored in the composed assetInfo dictionary.
UsdModelAPI is an API schema that provides an interface to a prim&#39;s model qualities, if it does, in fact, represent the root prim of a model.
Definition: modelAPI.h:72
USD_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
USD_API void SetAssetIdentifier(const SdfAssetPath &identifier) const
Sets the model&#39;s asset identifier to the given asset path, identifier.
The base class for all schema types in Usd.
Definition: schemaBase.h:56
USD_API bool GetAssetVersion(std::string *version) const
Returns the model&#39;s resolved asset version.
bool IsEmpty() const
Returns true iff this value is empty.
Definition: value.h:1244
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
UsdModelAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdModelAPI on UsdPrim prim .
Definition: modelAPI.h:84
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: modelAPI.h:78
USD_API bool IsGroup() const
Return true if this prim represents a model group, based on its kind metadata.
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:120