All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdAPISchemaBase Class Referenceabstract

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

+ Inheritance diagram for UsdAPISchemaBase:

Public Member Functions

 UsdAPISchemaBase (const UsdPrim &prim=UsdPrim())
 Construct a UsdAPISchemaBase on UsdPrim prim . More...
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj)
 Construct a UsdAPISchemaBase on the prim held by schemaObj . More...
 
virtual USD_API ~UsdAPISchemaBase ()=0
 Destructor. More...
 
- 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. More...
 
bool IsTyped () const
 Returns whether or not this class inherits from UsdTyped. More...
 
bool IsAPISchema () const
 Returns whether this is an API schema or not. More...
 
bool IsAppliedAPISchema () const
 Returns whether this is an applied API schema or not. More...
 
bool IsMultipleApplyAPISchema () const
 Returns whether this is an applied API schema or not. More...
 
UsdSchemaType GetSchemaType () const
 
USD_API UsdSchemaBase (const UsdPrim &prim=UsdPrim())
 Construct and store prim as the held prim. More...
 
USD_API UsdSchemaBase (const UsdSchemaBase &otherSchema)
 Construct and store for the same prim held by otherSchema. More...
 
virtual USD_API ~UsdSchemaBase ()
 Destructor. More...
 
USD_API operator bool () const
 Return true if this schema object is compatible with its held prim, false otherwise. More...
 
UsdPrim GetPrim () const
 Return this schema object's held prim. More...
 
SdfPath GetPath () const
 Shorthand for GetPrim()->GetPath(). More...
 
USD_API SdfPrimSpecHandle GetSchemaClassPrimDefinition () const
 Return the prim definition associated with this schema instance if one exists, otherwise return null. More...
 

Static Public Member Functions

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 classes. More...
 
- Static Public Member Functions inherited from UsdSchemaBase
static const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 

Static Public Attributes

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

Protected Member Functions

USD_API UsdSchemaType _GetSchemaType () const override
 Returns the type of schema this class belongs to. More...
 
 UsdAPISchemaBase (const UsdPrim &prim, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on UsdPrim prim with the specified instanceName. More...
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on the prim held by schemaObj with the given instanceName. More...
 
const TfToken_GetInstanceName () const
 Returns the instance name of the API schema object belonging to a multiple-apply API schema. More...
 
USD_API bool _IsCompatible () const override
 Check whether this APISchema object is valid for the currently held prim. More...
 
- Protected Member Functions inherited from UsdSchemaBase
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

template<typename APISchemaType >
static APISchemaType _ApplyAPISchema (const UsdPrim &prim, const TfToken &apiSchemaName)
 Helper method to apply a single-apply API schema with the given schema name apiSchemaName' and C++ type 'APISchemaType'. More...
 
template<typename APISchemaType >
static APISchemaType _MultipleApplyAPISchema (const UsdPrim &prim, const TfToken &apiSchemaName, const TfToken &instanceName)
 Helper method to apply a multiple-apply API schema with the given schema name apiSchemaName', C++ type 'APISchemaType' and instance name instanceName. More...
 

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() (or private _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 117 of file apiSchemaBase.h.

Constructor & Destructor Documentation

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 129 of file apiSchemaBase.h.

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 137 of file apiSchemaBase.h.

virtual USD_API ~UsdAPISchemaBase ( )
pure virtual

Destructor.

UsdAPISchemaBase ( const UsdPrim prim,
const TfToken instanceName 
)
inlineexplicitprotected

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

Definition at line 188 of file apiSchemaBase.h.

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 197 of file apiSchemaBase.h.

Member Function Documentation

static APISchemaType _ApplyAPISchema ( const UsdPrim prim,
const TfToken apiSchemaName 
)
inlinestaticprotected

Helper method to apply a single-apply API schema with the given schema name apiSchemaName' and C++ type 'APISchemaType'.

The schema is applied on the given prim in the current edit target.

This information is stored by adding apiSchemaName value to the token-valued, listOp metadata apiSchemas on the prim.

A valid schema object of type APISchemaType is returned upon success.

A coding error is issued and an invalid schema object is returned if if prim is invalid or is an instance proxy prim or is contained within an instance master OR apiSchemaName cannot be added to the apiSchemas listOp metadata.

A run-time error is issued and an invalid schema object is returned if the given prim is valid, but cannot be reached or overridden in the current edit target.

Definition at line 235 of file apiSchemaBase.h.

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 209 of file apiSchemaBase.h.

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 UsdShadeConnectableAPI.

static APISchemaType _MultipleApplyAPISchema ( const UsdPrim prim,
const TfToken apiSchemaName,
const TfToken instanceName 
)
inlinestaticprotected

Helper method to apply a multiple-apply API schema with the given schema name apiSchemaName', C++ type 'APISchemaType' and instance name instanceName.

The schema is applied on the given prim in the current edit target.

This information is stored in the token-valued, listOp metadata apiSchemas on the prim. For example, if apiSchemaName is 'CollectionAPI' and instanceName is 'plasticStuff', the name 'CollectionAPI:plasticStuff' is added to 'apiSchemas' listOp metadata.

A valid schema object of type APISchemaType is returned upon success.

A coding error is issued and an invalid schema object is returned if the prim is invalid or is an instance proxy prim or is contained within an instance master OR instanceName is empty OR apiSchemaName:instanceName cannot be added to the apiSchemas listOp metadata.

A run-time error is issued and an invalid schema object is returned if the given prim is valid, but cannot be reached or overridden in the current edit target.

Definition at line 267 of file apiSchemaBase.h.

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.

Member Data Documentation

const UsdSchemaType schemaType = UsdSchemaType::AbstractBase
static

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

See Also
UsdSchemaType

Definition at line 123 of file apiSchemaBase.h.


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