Loading...
Searching...
No Matches
UsdAPISchemaBase Class Referenceabstract

The base class for all API schemas. More...

#include <apiSchemaBase.h>

+ Inheritance diagram for UsdAPISchemaBase:

Public Member Functions

 UsdAPISchemaBase (const UsdPrim &prim=UsdPrim())
 Construct a UsdAPISchemaBase on UsdPrim prim .
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj)
 Construct a UsdAPISchemaBase on the prim held by schemaObj .
 
virtual USD_API ~UsdAPISchemaBase ()=0
 Destructor.
 
- Public Member Functions inherited from UsdSchemaBase
bool IsConcrete () const
 Returns whether or not this class corresponds to a concrete instantiable prim type in scene description.
 
bool IsTyped () const
 Returns whether or not this class inherits from UsdTyped.
 
bool IsAPISchema () const
 Returns whether this is an API schema or not.
 
bool IsAppliedAPISchema () const
 Returns whether this is an applied API schema or not.
 
bool IsMultipleApplyAPISchema () const
 Returns whether this is an applied API schema or not.
 
UsdSchemaKind GetSchemaKind () const
 Returns the kind of schema this class is.
 
USD_API UsdSchemaBase (const UsdPrim &prim=UsdPrim())
 Construct and store prim as the held prim.
 
USD_API UsdSchemaBase (const UsdSchemaBase &otherSchema)
 Construct and store for the same prim held by otherSchema.
 
virtual USD_API ~UsdSchemaBase ()
 Destructor.
 
UsdPrim GetPrim () const
 Return this schema object's held prim.
 
SdfPath GetPath () const
 Shorthand for GetPrim()->GetPath().
 
USD_API const UsdPrimDefinitionGetSchemaClassPrimDefinition () const
 Return the prim definition associated with this schema instance if one exists, otherwise return null.
 
USD_API operator bool () const
 Return true if this schema object is compatible with its held prim, false otherwise.
 

Static Public Member Functions

static USD_API const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.
 
- Static Public Member Functions inherited from UsdSchemaBase
static const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 

Static Public Attributes

static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
 Compile time constant representing what kind of schema this class is.
 
- Static Public Attributes inherited from UsdSchemaBase
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
 Compile time constant representing what kind of schema this class is.
 

Protected Member Functions

USD_API UsdSchemaKind _GetSchemaKind () const override
 Returns the kind of schema this class belongs to.
 
 UsdAPISchemaBase (const UsdPrim &prim, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on UsdPrim prim with the specified instanceName.
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on the prim held by schemaObj with the given instanceName.
 
const TfToken_GetInstanceName () const
 Returns the instance name of the API schema object belonging to a multiple-apply API schema.
 
USD_API bool _IsCompatible () const override
 Check whether this APISchema object is valid for the currently held
prim.
 
- Protected Member Functions inherited from UsdSchemaBase
virtual UsdSchemaKind _GetSchemaType () const
 
const TfType_GetType () const
 
USD_API UsdAttribute _CreateAttr (TfToken const &attrName, SdfValueTypeName const &typeName, bool custom, SdfVariability variability, VtValue const &defaultValue, bool writeSparsely) const
 

Static Protected Member Functions

static USD_API TfTokenVector _GetMultipleApplyInstanceNames (const UsdPrim &prim, const TfType &schemaType)
 Returns a vector of names of API schema objects belonging to a multiple-apply API schema applied to a given prim.
 

Friends

class UsdSchemaRegistry
 

Detailed Description

The base class for all API schemas.

An API schema provides an interface to a prim's qualities, but does not specify a typeName for the underlying prim. The prim's qualities include its inheritance structure, attributes, relationships etc. Since it cannot provide a typeName, an API schema is considered to be non-concrete.

To auto-generate an API schema using usdGenSchema, simply leave the typeName empty and make it inherit from "/APISchemaBase" or from another API schema. See UsdModelAPI, UsdClipsAPI and UsdCollectionAPI for examples.

API schemas are classified into applied and non-applied API schemas. The author of an API schema has to decide on the type of API schema at the time of its creation by setting customData['apiSchemaType'] in the schema definition (i.e. in the associated primSpec inside the schema.usda file). UsdAPISchemaBase implements methods that are used to record the application of an API schema on a USD prim.

If an API schema only provides an interface to set certain core bits of metadata (like UsdModelAPI, which sets model kind and UsdClipsAPI, which sets clips-related metadata) OR if the API schema can apply to any type of prim or only to a known fixed set of prim types OR if there is no use of recording the application of the API schema, in such cases, it would be better to make it a non-applied API schema. Examples of non-applied API schemas include UsdModelAPI, UsdClipsAPI, UsdShadeConnectableAPI and UsdGeomPrimvarsAPI.

If there is a need to discover (or record) whether a prim contains or subscribes to a given API schema, it would be advantageous to make the API schema be "applied". In general, API schemas that add one or more properties to a prim should be tagged as applied API schemas. A public Apply() method is generated for applied API schemas by usdGenSchema. An applied API schema must be applied to a prim via a call to the generated Apply() method, for the schema object to evaluate to true when converted to a bool using the explicit bool conversion operator. Examples of applied API schemas include UsdCollectionAPI, UsdGeomModelAPI and UsdGeomMotionAPI

Definition at line 116 of file apiSchemaBase.h.

Constructor & Destructor Documentation

◆ UsdAPISchemaBase() [1/4]

UsdAPISchemaBase ( const UsdPrim prim = UsdPrim())
inlineexplicit

Construct a UsdAPISchemaBase on UsdPrim prim .

Equivalent to UsdAPISchemaBase::Get(prim.GetStage(), prim.GetPath()) for a valid prim, but will not immediately throw an error for an invalid prim

Definition at line 128 of file apiSchemaBase.h.

◆ UsdAPISchemaBase() [2/4]

UsdAPISchemaBase ( const UsdSchemaBase schemaObj)
inlineexplicit

Construct a UsdAPISchemaBase on the prim held by schemaObj .

Should be preferred over UsdAPISchemaBase(schemaObj.GetPrim()), as it preserves SchemaBase state.

Definition at line 136 of file apiSchemaBase.h.

◆ ~UsdAPISchemaBase()

virtual USD_API ~UsdAPISchemaBase ( )
pure virtual

Destructor.

◆ UsdAPISchemaBase() [3/4]

UsdAPISchemaBase ( const UsdPrim prim,
const TfToken instanceName 
)
inlineexplicitprotected

Construct a multiple-apply UsdAPISchemaBase on UsdPrim prim with the specified instanceName.

Definition at line 187 of file apiSchemaBase.h.

◆ UsdAPISchemaBase() [4/4]

UsdAPISchemaBase ( const UsdSchemaBase schemaObj,
const TfToken instanceName 
)
inlineexplicitprotected

Construct a multiple-apply UsdAPISchemaBase on the prim held by schemaObj with the given instanceName.

Definition at line 196 of file apiSchemaBase.h.

Member Function Documentation

◆ _GetInstanceName()

const TfToken & _GetInstanceName ( ) const
inlineprotected

Returns the instance name of the API schema object belonging to a multiple-apply API schema.

The returned instance name will be empty for non-applied and single-apply API schemas.

Definition at line 208 of file apiSchemaBase.h.

◆ _GetMultipleApplyInstanceNames()

static USD_API TfTokenVector _GetMultipleApplyInstanceNames ( const UsdPrim prim,
const TfType schemaType 
)
staticprotected

Returns a vector of names of API schema objects belonging to a multiple-apply API schema applied to a given prim.

◆ _GetSchemaKind()

◆ _IsCompatible()

USD_API bool _IsCompatible ( ) const
overrideprotectedvirtual

Check whether this APISchema object is valid for the currently held
prim.

If this is an applied API schema, this returns true if the held prim is valid and already has the API schema applied to it, along with the instanceName (in the case of multiple-apply). The instanceName should not be empty in the case of a multiple-apply API schema.

This check is performed when clients invoke the explicit bool conversion operator, implemented in UsdSchemaBase.

See also
UsdPrim::HasAPI()

Reimplemented from UsdSchemaBase.

Reimplemented in UsdGeomXformCommonAPI, and UsdShadeConnectableAPI.

◆ GetSchemaAttributeNames()

static USD_API const TfTokenVector & GetSchemaAttributeNames ( bool  includeInherited = true)
static

Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.

Does not include attributes that may be authored by custom/extended methods of the schemas involved.

Friends And Related Function Documentation

◆ UsdSchemaRegistry

friend class UsdSchemaRegistry
friend

Definition at line 162 of file apiSchemaBase.h.

Member Data Documentation

◆ schemaKind

const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
static

Compile time constant representing what kind of schema this class is.

See also
UsdSchemaKind

Definition at line 122 of file apiSchemaBase.h.


The documentation for this class was generated from the following file: