Loading...
Searching...
No Matches
collectionAPI.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef USD_GENERATED_COLLECTIONAPI_H
8#define USD_GENERATED_COLLECTIONAPI_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usd/api.h"
15#include "pxr/usd/usd/prim.h"
16#include "pxr/usd/usd/stage.h"
17#include "pxr/usd/usd/tokens.h"
18
21#include "pxr/usd/usd/tokens.h"
22#include "pxr/usd/sdf/pathExpression.h"
23
24
25#include "pxr/base/vt/value.h"
26
27#include "pxr/base/gf/vec3d.h"
28#include "pxr/base/gf/vec3f.h"
30
31#include "pxr/base/tf/token.h"
32#include "pxr/base/tf/type.h"
33
34PXR_NAMESPACE_OPEN_SCOPE
35
36class SdfAssetPath;
37
38// -------------------------------------------------------------------------- //
39// COLLECTIONAPI //
40// -------------------------------------------------------------------------- //
41
185{
186public:
190 static const UsdSchemaKind schemaKind = UsdSchemaKind::MultipleApplyAPI;
191
202 const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
203 : UsdAPISchemaBase(prim, /*instanceName*/ name)
204 { }
205
211 const UsdSchemaBase& schemaObj, const TfToken &name)
212 : UsdAPISchemaBase(schemaObj, /*instanceName*/ name)
213 { }
214
216 USD_API
218
222 USD_API
223 static const TfTokenVector &
224 GetSchemaAttributeNames(bool includeInherited=true);
225
231 USD_API
232 static TfTokenVector
233 GetSchemaAttributeNames(bool includeInherited, const TfToken &instanceName);
234
236 TfToken GetName() const {
237 return _GetInstanceName();
238 }
239
254 USD_API
255 static UsdCollectionAPI
256 Get(const UsdStagePtr &stage, const SdfPath &path);
257
260 USD_API
261 static UsdCollectionAPI
262 Get(const UsdPrim &prim, const TfToken &name);
263
266 USD_API
267 static std::vector<UsdCollectionAPI>
268 GetAll(const UsdPrim &prim);
269
272 USD_API
273 static bool
275
279 USD_API
280 static bool
282
299 USD_API
300 static bool
301 CanApply(const UsdPrim &prim, const TfToken &name,
302 std::string *whyNot=nullptr);
303
323 USD_API
324 static UsdCollectionAPI
325 Apply(const UsdPrim &prim, const TfToken &name);
326
327protected:
331 USD_API
333
334private:
335 // needs to invoke _GetStaticTfType.
336 friend class UsdSchemaRegistry;
337 USD_API
338 static const TfType &_GetStaticTfType();
339
340 static bool _IsTypedSchema();
341
342 // override SchemaBase virtuals.
343 USD_API
344 const TfType &_GetTfType() const override;
345
346public:
347 // --------------------------------------------------------------------- //
348 // EXPANSIONRULE
349 // --------------------------------------------------------------------- //
360 USD_API
362
368 USD_API
369 UsdAttribute CreateExpansionRuleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
370
371public:
372 // --------------------------------------------------------------------- //
373 // INCLUDEROOT
374 // --------------------------------------------------------------------- //
386 USD_API
388
394 USD_API
395 UsdAttribute CreateIncludeRootAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
396
397public:
398 // --------------------------------------------------------------------- //
399 // MEMBERSHIPEXPRESSION
400 // --------------------------------------------------------------------- //
410 USD_API
412
418 USD_API
419 UsdAttribute CreateMembershipExpressionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
420
421public:
422 // --------------------------------------------------------------------- //
423 // COLLECTION
424 // --------------------------------------------------------------------- //
438 USD_API
440
446 USD_API
447 UsdAttribute CreateCollectionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
448
449public:
450 // --------------------------------------------------------------------- //
451 // INCLUDES
452 // --------------------------------------------------------------------- //
459 USD_API
461
464 USD_API
466
467public:
468 // --------------------------------------------------------------------- //
469 // EXCLUDES
470 // --------------------------------------------------------------------- //
484 USD_API
486
489 USD_API
491
492public:
493 // ===================================================================== //
494 // Feel free to add custom code below this line, it will be preserved by
495 // the code generator.
496 //
497 // Just remember to:
498 // - Close the class declaration with };
499 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
500 // - Close the include guard with #endif
501 // ===================================================================== //
502 // --(BEGIN CUSTOM CODE)--
503
504public:
507 USD_API
508 static UsdCollectionAPI GetCollection(const UsdStagePtr &stage,
509 const SdfPath &collectionPath);
510
513 USD_API
515 const TfToken &name);
516
519 USD_API
520 static std::vector<UsdCollectionAPI> GetAllCollections(const UsdPrim &prim);
521
528 USD_API
530
535 USD_API
537 const UsdPrim &prim,
538 const TfToken &collectionName);
539
540 USD_API
541 static SdfPathExpression
543 UsdPrim const &prim);
544
553 USD_API
555
556 // Convenient alias for UsdCollectionMembershipQuery object
558
561 USD_API
563
566 USD_API
568
576 USD_API
577 bool HasNoIncludedPaths() const;
578
584 USD_API
585 static std::set<UsdObject> ComputeIncludedObjects(
586 const UsdCollectionMembershipQuery &query,
587 const UsdStageWeakPtr &stage,
588 const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate);
589
595 USD_API
596 static SdfPathSet ComputeIncludedPaths(
597 const UsdCollectionMembershipQuery &query,
598 const UsdStageWeakPtr &stage,
599 const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate);
600
608
619 USD_API
620 bool IncludePath(const SdfPath &pathToInclude) const;
621
634 USD_API
635 bool ExcludePath(const SdfPath &pathToExclude) const;
636
638
646 USD_API
647 bool Validate(std::string *reason) const;
648
654 USD_API
655 bool ResetCollection() const;
656
662 USD_API
663 bool BlockCollection() const;
664
667 USD_API
668 static bool CanContainPropertyName(const TfToken &name);
669
670private:
671
672 // Helper method for computing the UsdCollectionMembershipQuery object for
673 // a collection.
674 // This makes recursive calls if the collection includes other collections.
675 // \p chainedCollectionPaths is used to pass in the set of all seen and
676 // included collections in the dependency chain and is used to detect
677 // circular dependencies.
678 // If \p foundCircularDependency is not nullptr, it is set to true if a
679 // circular dependency is detected amongst the included collections.
680 // If it is nullptr, a warning is issued when a circular dependency is
681 // detected.
682 void _ComputeMembershipQueryImpl(
684 const SdfPathSet &chainedCollectionPaths,
685 bool *foundCircularDependency=nullptr) const;
686};
687
688PXR_NAMESPACE_CLOSE_SCOPE
689
690#endif
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
Objects of this class represent a logical expression syntax tree consisting of SdfPathPattern s,...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfType represents a dynamic runtime type.
Definition: type.h:48
The base class for all API schemas.
Definition: apiSchemaBase.h:99
const TfToken & _GetInstanceName() const
Returns the instance name of the API schema object belonging to a multiple-apply API schema.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:159
A general purpose API schema used to describe a collection of prims and properties within a scene.
USD_API bool ResetCollection() const
Resets the collection by clearing both the includes and excludes targets of the collection in the cur...
UsdCollectionAPI(const UsdPrim &prim=UsdPrim(), const TfToken &name=TfToken())
Construct a UsdCollectionAPI on UsdPrim prim with name name .
USD_API UsdRelationship CreateExcludesRel() const
See GetExcludesRel(), and also Create vs Get Property Methods for when to use Get vs Create.
USD_API bool BlockCollection() const
Blocks the targets of the includes and excludes relationships of the collection, making it <* empty i...
USD_API UsdAttribute GetMembershipExpressionAttr() const
Specifies a path expression that determines membership in this collection.
USD_API bool IncludePath(const SdfPath &pathToInclude) const
Includes or adds the given path, pathToInclude in the collection.
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 cl...
TfToken GetName() const
Returns the name of this multiple-apply schema instance.
static USD_API UsdCollectionAPI Get(const UsdPrim &prim, const TfToken &name)
Return a UsdCollectionAPI with name name holding the prim prim.
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
static USD_API bool IsSchemaPropertyBaseName(const TfToken &baseName)
Checks if the given name baseName is the base name of a property of CollectionAPI.
USD_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
USD_API UsdAttribute CreateExpansionRuleAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetExpansionRuleAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USD_API UsdAttribute GetCollectionAttr() const
This property represents the collection for the purpose of allowing another collection to include it.
UsdCollectionAPI(const UsdSchemaBase &schemaObj, const TfToken &name)
Construct a UsdCollectionAPI on the prim held by schemaObj with name name.
static USD_API UsdCollectionAPI Apply(const UsdPrim &prim, const TfToken &name)
Applies this multiple-apply API schema to the given prim along with the given instance name,...
static USD_API UsdCollectionAPI GetCollection(const UsdStagePtr &stage, const SdfPath &collectionPath)
Returns the collection represented by the given collection path, collectionPath on the given USD stag...
USD_API UsdAttribute CreateCollectionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetCollectionAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USD_API UsdAttribute GetIncludeRootAttr() const
Boolean attribute indicating whether the pseudo-root path </> should be counted as one of the include...
USD_API SdfPathExpression ResolveCompleteMembershipExpression() const
Obtain a complete SdfPathExpression from this collection's membershipExpression.
USD_API SdfPath GetCollectionPath() const
Returns the canonical path that represents this collection.
static USD_API std::set< UsdObject > ComputeIncludedObjects(const UsdCollectionMembershipQuery &query, const UsdStageWeakPtr &stage, const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate)
Returns all the usd objects that satisfy the predicate, pred in the collection represented by the Usd...
static USD_API bool IsCollectionAPIPath(const SdfPath &path, TfToken *name)
Checks if the given path path is of an API schema of type CollectionAPI.
static USD_API UsdCollectionAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdCollectionAPI holding the prim adhering to this schema at path on stage.
USD_API bool Validate(std::string *reason) const
Validates the collection by checking the following rules:
USD_API UsdRelationship GetExcludesRel() const
Specifies a list of targets that are excluded below the included paths in this collection.
USD_API UsdAttribute CreateMembershipExpressionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetMembershipExpressionAttr(), and also Create vs Get Property Methods for when to use Get vs Cre...
static USD_API SdfPath GetNamedCollectionPath(const UsdPrim &prim, const TfToken &collectionName)
Returns the canonical path to the collection named, name on the given prim, prim.
virtual USD_API ~UsdCollectionAPI()
Destructor.
static USD_API UsdCollectionAPI GetCollection(const UsdPrim &prim, const TfToken &name)
Returns the schema object representing a collection named name on the given prim.
USD_API UsdCollectionMembershipQuery ComputeMembershipQuery() const
Computes and returns a UsdCollectionMembershipQuery object which can be used to query inclusion or ex...
USD_API UsdAttribute GetExpansionRuleAttr() const
Specifies how the paths that are included in the collection must be expanded to determine its members...
USD_API bool ExcludePath(const SdfPath &pathToExclude) const
Excludes or removes the given path, pathToExclude from the collection.
static USD_API bool CanApply(const UsdPrim &prim, const TfToken &name, std::string *whyNot=nullptr)
Returns true if this multiple-apply API schema can be applied, with the given instance name,...
static USD_API SdfPathSet ComputeIncludedPaths(const UsdCollectionMembershipQuery &query, const UsdStageWeakPtr &stage, const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate)
Returns all the paths that satisfy the predicate, pred in the collection represented by the UsdCollec...
static USD_API std::vector< UsdCollectionAPI > GetAll(const UsdPrim &prim)
Return a vector of all named instances of UsdCollectionAPI on the given prim.
static USD_API bool CanContainPropertyName(const TfToken &name)
Test whether a given name contains the "collection:" prefix.
USD_API void ComputeMembershipQuery(UsdCollectionMembershipQuery *query) const
Populates the UsdCollectionMembershipQuery object with data from this collection, so it can be used t...
USD_API UsdRelationship GetIncludesRel() const
Specifies a list of targets that are included in the collection.
static USD_API TfTokenVector GetSchemaAttributeNames(bool includeInherited, const TfToken &instanceName)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
USD_API UsdAttribute CreateIncludeRootAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetIncludeRootAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USD_API UsdRelationship CreateIncludesRel() const
See GetIncludesRel(), and also Create vs Get Property Methods for when to use Get vs Create.
USD_API bool HasNoIncludedPaths() const
Returns true if the collection has nothing included in it.
static USD_API std::vector< UsdCollectionAPI > GetAllCollections(const UsdPrim &prim)
Returns all the named collections on the given USD prim.
Represents a flattened view of a collection.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:111
The base class for all schema types in Usd.
Definition: schemaBase.h:39
Singleton registry that provides access to schema type information and the prim definitions for regis...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:112
unspecified UsdPrimDefaultPredicate
The default predicate used for prim traversals in methods like UsdPrim::GetChildren,...
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440