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 USD_SCHEMABASE_H
25 #define USD_SCHEMABASE_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 
99  UsdSchemaType GetSchemaType() const {
100  return _GetSchemaType();
101  }
102 
104  USD_API
105  explicit UsdSchemaBase(const UsdPrim& prim = UsdPrim());
106 
108  USD_API
109  explicit UsdSchemaBase(const UsdSchemaBase& otherSchema);
110 
112  USD_API
113  virtual ~UsdSchemaBase();
114 
116 
117 
119  UsdPrim GetPrim() const { return UsdPrim(_primData, _proxyPrimPath); }
120 
122  SdfPath GetPath() const {
123  if (!_proxyPrimPath.IsEmpty()) {
124  return _proxyPrimPath;
125  }
126  else if (Usd_PrimDataConstPtr p = get_pointer(_primData)) {
127  return p->GetPath();
128  }
129  return SdfPath::EmptyPath();
130  }
131 
133 
135 
136 
141  USD_API
142  SdfPrimSpecHandle GetSchemaClassPrimDefinition() const;
143 
145 
146  static const TfTokenVector &
147  GetSchemaAttributeNames(bool includeInherited=true)
148  {
149  /* This only exists for consistency */
150  static TfTokenVector names;
151  return names;
152  }
153 
162  USD_API
163  explicit operator bool() const {
164  return _primData && _IsCompatible();
165  }
166 
167 protected:
171  virtual UsdSchemaType _GetSchemaType() const {
172  return schemaType;
173  }
174  // Helper for subclasses to get the TfType for this schema object's dynamic
175  // C++ type.
176  const TfType &_GetType() const {
177  return _GetTfType();
178  }
179 
180  USD_API
181  UsdAttribute _CreateAttr(TfToken const &attrName,
182  SdfValueTypeName const & typeName,
183  bool custom, SdfVariability variability,
184  VtValue const &defaultValue,
185  bool writeSparsely) const;
186 
191  USD_API
192  virtual bool _IsCompatible() const;
193 
194 private:
195  // Subclasses should not override _GetTfType. It is implemented by the
196  // schema class code generator.
197  USD_API
198  virtual const TfType &_GetTfType() const;
199 
200  // The held prim and proxy prim path.
201  Usd_PrimDataHandle _primData;
202  SdfPath _proxyPrimPath;
203 };
204 
205 
206 PXR_NAMESPACE_CLOSE_SCOPE
207 
208 #endif //USD_SCHEMABASE_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
virtual UsdSchemaType _GetSchemaType() const
Returns the type of schema this class is.
Definition: schemaBase.h:171
Represents a value type name, i.e.
Definition: valueTypeName.h:83
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
Represents a concrete typed schema.
virtual USD_API ~UsdSchemaBase()
Destructor.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
USD_API SdfPrimSpecHandle GetSchemaClassPrimDefinition() const
Return the prim definition associated with this schema instance if one exists, otherwise return null...
SdfPath GetPath() const
Shorthand for GetPrim()->GetPath().
Definition: schemaBase.h:122
Multiple Apply API Schema.
Non-applied API schema.
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:149
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:182
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:131
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
Single Apply API schema.
Represents a non-concrete typed schema.
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:287
bool IsMultipleApplyAPISchema() const
Returns whether this is an applied API schema or not.
Definition: schemaBase.h:95
TfType represents a dynamic runtime type.
Definition: type.h:70
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
Definition: schemaBase.h:61
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:409
static SDF_API const SdfPath & EmptyPath()
The empty path value, equivalent to SdfPath().
Represents abstract or base schema types that are interface-only and cannot be instantiated.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:119