HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
typed.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_TYPED_H
25 #define USD_GENERATED_TYPED_H
26 
27 /// \file usd/typed.h
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 
45 
46 class SdfAssetPath;
47 
48 // -------------------------------------------------------------------------- //
49 // TYPED //
50 // -------------------------------------------------------------------------- //
51 
52 /// \class UsdTyped
53 ///
54 /// The base class for all \em typed schemas (those that can impart a
55 /// typeName to a UsdPrim), and therefore the base class for all
56 /// concrete, instantiable "IsA" schemas.
57 ///
58 /// UsdTyped implements a typeName-based query for its override of
59 /// UsdSchemaBase::_IsCompatible(). It provides no other behavior.
60 ///
61 class UsdTyped : public UsdSchemaBase
62 {
63 public:
64  /// Compile time constant representing what kind of schema this class is.
65  ///
66  /// \sa UsdSchemaKind
68 
69  /// Construct a UsdTyped on UsdPrim \p prim .
70  /// Equivalent to UsdTyped::Get(prim.GetStage(), prim.GetPath())
71  /// for a \em valid \p prim, but will not immediately throw an error for
72  /// an invalid \p prim
73  explicit UsdTyped(const UsdPrim& prim=UsdPrim())
74  : UsdSchemaBase(prim)
75  {
76  }
77 
78  /// Construct a UsdTyped on the prim held by \p schemaObj .
79  /// Should be preferred over UsdTyped(schemaObj.GetPrim()),
80  /// as it preserves SchemaBase state.
81  explicit UsdTyped(const UsdSchemaBase& schemaObj)
82  : UsdSchemaBase(schemaObj)
83  {
84  }
85 
86  /// Destructor.
87  USD_API
88  virtual ~UsdTyped();
89 
90  /// Return a vector of names of all pre-declared attributes for this schema
91  /// class and all its ancestor classes. Does not include attributes that
92  /// may be authored by custom/extended methods of the schemas involved.
93  USD_API
94  static const TfTokenVector &
95  GetSchemaAttributeNames(bool includeInherited=true);
96 
97  /// Return a UsdTyped holding the prim adhering to this
98  /// schema at \p path on \p stage. If no prim exists at \p path on
99  /// \p stage, or if the prim at that path does not adhere to this schema,
100  /// return an invalid schema object. This is shorthand for the following:
101  ///
102  /// \code
103  /// UsdTyped(stage->GetPrimAtPath(path));
104  /// \endcode
105  ///
106  USD_API
107  static UsdTyped
108  Get(const UsdStagePtr &stage, const SdfPath &path);
109 
110 
111 protected:
112  /// Returns the kind of schema this class belongs to.
113  ///
114  /// \sa UsdSchemaKind
115  USD_API
116  UsdSchemaKind _GetSchemaKind() const override;
117 
118 private:
119  // needs to invoke _GetStaticTfType.
120  friend class UsdSchemaRegistry;
121  USD_API
122  static const TfType &_GetStaticTfType();
123 
124  static bool _IsTypedSchema();
125 
126  // override SchemaBase virtuals.
127  USD_API
128  const TfType &_GetTfType() const override;
129 
130 public:
131  // ===================================================================== //
132  // Feel free to add custom code below this line, it will be preserved by
133  // the code generator.
134  //
135  // Just remember to:
136  // - Close the class declaration with };
137  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
138  // - Close the include guard with #endif
139  // ===================================================================== //
140  // --(BEGIN CUSTOM CODE)--
141 
142 protected:
143  USD_API
144  bool _IsCompatible() const override;
145 };
146 
148 
149 #endif
UsdTyped(const UsdPrim &prim=UsdPrim())
Definition: typed.h:73
#define USD_API
Definition: api.h:40
static const UsdSchemaKind schemaKind
Definition: typed.h:67
UsdTyped(const UsdSchemaBase &schemaObj)
Definition: typed.h:81
USD_API UsdSchemaKind _GetSchemaKind() const override
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
Definition: prim.h:135
Definition: typed.h:61
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
static USD_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: path.h:291
virtual USD_API ~UsdTyped()
Destructor.
UsdSchemaKind
Definition: common.h:127
static USD_API UsdTyped Get(const UsdStagePtr &stage, const SdfPath &path)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USD_API bool _IsCompatible() const override
Definition: type.h:64