All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
schemaBase.h
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 PXR_USD_USD_SCHEMA_BASE_H
25 #define PXR_USD_USD_SCHEMA_BASE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usd/api.h"
29 #include "pxr/usd/usd/prim.h"
30 #include "pxr/usd/usd/attribute.h"
31 #include "pxr/usd/usd/relationship.h"
32 #include "pxr/usd/usd/references.h"
33 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
36 
57 public:
62 
67  bool IsConcrete() const {
69  }
70 
73  bool IsTyped() const {
76  }
77 
79  bool IsAPISchema() const {
83  }
84 
87  bool IsAppliedAPISchema() const {
90  }
91 
95  bool IsMultipleApplyAPISchema() const {
97  }
98 
101  return _GetSchemaKind();
102  }
103 
105  USD_API
106  explicit UsdSchemaBase(const UsdPrim& prim = UsdPrim());
107 
109  USD_API
110  explicit UsdSchemaBase(const UsdSchemaBase& otherSchema);
111 
113  USD_API
114  virtual ~UsdSchemaBase();
115 
117 
118 
120  UsdPrim GetPrim() const { return UsdPrim(_primData, _proxyPrimPath); }
121 
123  SdfPath GetPath() const {
124  if (!_proxyPrimPath.IsEmpty()) {
125  return _proxyPrimPath;
126  }
127  else if (Usd_PrimDataConstPtr p = get_pointer(_primData)) {
128  return p->GetPath();
129  }
130  return SdfPath::EmptyPath();
131  }
132 
134 
136 
137 
142  USD_API
144 
146 
147  static const TfTokenVector &
148  GetSchemaAttributeNames(bool includeInherited=true)
149  {
150  /* This only exists for consistency */
151  static TfTokenVector names;
152  return names;
153  }
154 
164  USD_API
165  explicit operator bool() const {
166  return _primData && _IsCompatible();
167  }
168 
169 protected:
173  virtual UsdSchemaKind _GetSchemaKind() const {
174  return schemaKind;
175  }
176 
185  virtual UsdSchemaKind _GetSchemaType() const {
186  return schemaKind;
187  }
188 
189  // Helper for subclasses to get the TfType for this schema object's dynamic
190  // C++ type.
191  const TfType &_GetType() const {
192  return _GetTfType();
193  }
194 
195  USD_API
196  UsdAttribute _CreateAttr(TfToken const &attrName,
197  SdfValueTypeName const & typeName,
198  bool custom, SdfVariability variability,
199  VtValue const &defaultValue,
200  bool writeSparsely) const;
201 
206  USD_API
207  virtual bool _IsCompatible() const;
208 
209 private:
210  // Subclasses should not override _GetTfType. It is implemented by the
211  // schema class code generator.
212  USD_API
213  virtual const TfType &_GetTfType() const;
214 
215  // The held prim and proxy prim path.
216  Usd_PrimDataHandle _primData;
217  SdfPath _proxyPrimPath;
218 };
219 
220 
221 PXR_NAMESPACE_CLOSE_SCOPE
222 
223 #endif //PXR_USD_USD_SCHEMA_BASE_H
virtual USD_API bool _IsCompatible() const
Subclasses may override _IsCompatible to do specific compatibility checking with the given prim...
bool IsTyped() const
Returns whether or not this class inherits from UsdTyped.
Definition: schemaBase.h:73
bool IsAppliedAPISchema() const
Returns whether this is an applied API schema or not.
Definition: schemaBase.h:87
Represents a value type name, i.e.
Definition: valueTypeName.h:87
USD_API const UsdPrimDefinition * GetSchemaClassPrimDefinition() const
Return the prim definition associated with this schema instance if one exists, otherwise return null...
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
UsdSchemaKind GetSchemaKind() const
Returns the kind of schema this class is.
Definition: schemaBase.h:100
virtual USD_API ~UsdSchemaBase()
Destructor.
Non-applied API schema.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
Single Apply API schema.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: schemaBase.h:61
SdfPath GetPath() const
Shorthand for GetPrim()->GetPath().
Definition: schemaBase.h:123
Represents a concrete typed schema.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
bool IsConcrete() const
Returns whether or not this class corresponds to a concrete instantiable prim type in scene descripti...
Definition: schemaBase.h:67
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
virtual UsdSchemaKind _GetSchemaKind() const
Returns the kind of schema this class is.
Definition: schemaBase.h:173
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:179
Multiple Apply API Schema.
Represents abstract or base schema types that are interface-only and cannot be instantiated.
Class representing the builtin definition of a prim given the schemas registered in the schema regist...
bool IsMultipleApplyAPISchema() const
Returns whether this is an applied API schema or not.
Definition: schemaBase.h:95
Represents a non-concrete typed schema.
TfType represents a dynamic runtime type.
Definition: type.h:64
bool IsAPISchema() const
Returns whether this is an API schema or not.
Definition: schemaBase.h:79
USD_API UsdSchemaBase(const UsdPrim &prim=UsdPrim())
Construct and store prim as the held prim.
The base class for all schema types in Usd.
Definition: schemaBase.h:56
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Definition: path.h:417
static SDF_API const SdfPath & EmptyPath()
The empty path value, equivalent to SdfPath().
virtual UsdSchemaKind _GetSchemaType() const
Definition: schemaBase.h:185
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:120