Loading...
Searching...
No Matches
collectionAPI.h
Go to the documentation of this file.
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_GENERATED_COLLECTIONAPI_H
25#define USD_GENERATED_COLLECTIONAPI_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usd/usd/api.h"
32#include "pxr/usd/usd/prim.h"
33#include "pxr/usd/usd/stage.h"
34#include "pxr/usd/usd/tokens.h"
35
38#include "pxr/usd/usd/tokens.h"
39#include "pxr/usd/sdf/pathExpression.h"
40
41
42#include "pxr/base/vt/value.h"
43
44#include "pxr/base/gf/vec3d.h"
45#include "pxr/base/gf/vec3f.h"
47
48#include "pxr/base/tf/token.h"
49#include "pxr/base/tf/type.h"
50
51PXR_NAMESPACE_OPEN_SCOPE
52
53class SdfAssetPath;
54
55// -------------------------------------------------------------------------- //
56// COLLECTIONAPI //
57// -------------------------------------------------------------------------- //
58
160{
161public:
165 static const UsdSchemaKind schemaKind = UsdSchemaKind::MultipleApplyAPI;
166
177 const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
178 : UsdAPISchemaBase(prim, /*instanceName*/ name)
179 { }
180
186 const UsdSchemaBase& schemaObj, const TfToken &name)
187 : UsdAPISchemaBase(schemaObj, /*instanceName*/ name)
188 { }
189
191 USD_API
193
197 USD_API
198 static const TfTokenVector &
199 GetSchemaAttributeNames(bool includeInherited=true);
200
206 USD_API
207 static TfTokenVector
208 GetSchemaAttributeNames(bool includeInherited, const TfToken &instanceName);
209
211 TfToken GetName() const {
212 return _GetInstanceName();
213 }
214
229 USD_API
230 static UsdCollectionAPI
231 Get(const UsdStagePtr &stage, const SdfPath &path);
232
235 USD_API
236 static UsdCollectionAPI
237 Get(const UsdPrim &prim, const TfToken &name);
238
241 USD_API
242 static std::vector<UsdCollectionAPI>
243 GetAll(const UsdPrim &prim);
244
247 USD_API
248 static bool
250
254 USD_API
255 static bool
257
274 USD_API
275 static bool
276 CanApply(const UsdPrim &prim, const TfToken &name,
277 std::string *whyNot=nullptr);
278
298 USD_API
299 static UsdCollectionAPI
300 Apply(const UsdPrim &prim, const TfToken &name);
301
302protected:
306 USD_API
308
309private:
310 // needs to invoke _GetStaticTfType.
311 friend class UsdSchemaRegistry;
312 USD_API
313 static const TfType &_GetStaticTfType();
314
315 static bool _IsTypedSchema();
316
317 // override SchemaBase virtuals.
318 USD_API
319 const TfType &_GetTfType() const override;
320
321public:
322 // --------------------------------------------------------------------- //
323 // EXPANSIONRULE
324 // --------------------------------------------------------------------- //
335 USD_API
337
343 USD_API
344 UsdAttribute CreateExpansionRuleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
345
346public:
347 // --------------------------------------------------------------------- //
348 // INCLUDEROOT
349 // --------------------------------------------------------------------- //
361 USD_API
363
369 USD_API
370 UsdAttribute CreateIncludeRootAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
371
372public:
373 // --------------------------------------------------------------------- //
374 // MEMBERSHIPEXPRESSION
375 // --------------------------------------------------------------------- //
385 USD_API
387
393 USD_API
394 UsdAttribute CreateMembershipExpressionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
395
396public:
397 // --------------------------------------------------------------------- //
398 // COLLECTION
399 // --------------------------------------------------------------------- //
413 USD_API
415
421 USD_API
422 UsdAttribute CreateCollectionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
423
424public:
425 // --------------------------------------------------------------------- //
426 // INCLUDES
427 // --------------------------------------------------------------------- //
434 USD_API
436
439 USD_API
441
442public:
443 // --------------------------------------------------------------------- //
444 // EXCLUDES
445 // --------------------------------------------------------------------- //
459 USD_API
461
464 USD_API
466
467public:
468 // ===================================================================== //
469 // Feel free to add custom code below this line, it will be preserved by
470 // the code generator.
471 //
472 // Just remember to:
473 // - Close the class declaration with };
474 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
475 // - Close the include guard with #endif
476 // ===================================================================== //
477 // --(BEGIN CUSTOM CODE)--
478
479public:
482 USD_API
483 static UsdCollectionAPI GetCollection(const UsdStagePtr &stage,
484 const SdfPath &collectionPath);
485
488 USD_API
490 const TfToken &name);
491
494 USD_API
495 static std::vector<UsdCollectionAPI> GetAllCollections(const UsdPrim &prim);
496
503 USD_API
505
510 USD_API
512 const UsdPrim &prim,
513 const TfToken &collectionName);
514
515 USD_API
516 static SdfPathExpression
518 UsdPrim const &prim);
519
528 USD_API
530
531 // Convenient alias for UsdCollectionMembershipQuery object
533
536 USD_API
538
541 USD_API
543
551 USD_API
552 bool HasNoIncludedPaths() const;
553
559 USD_API
560 static std::set<UsdObject> ComputeIncludedObjects(
561 const UsdCollectionMembershipQuery &query,
562 const UsdStageWeakPtr &stage,
563 const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate);
564
570 USD_API
571 static SdfPathSet ComputeIncludedPaths(
572 const UsdCollectionMembershipQuery &query,
573 const UsdStageWeakPtr &stage,
574 const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate);
575
577
585
596 USD_API
597 bool IncludePath(const SdfPath &pathToInclude) const;
598
611 USD_API
612 bool ExcludePath(const SdfPath &pathToExclude) const;
613
615
623 USD_API
624 bool Validate(std::string *reason) const;
625
631 USD_API
632 bool ResetCollection() const;
633
639 USD_API
640 bool BlockCollection() const;
641
644 USD_API
645 static bool CanContainPropertyName(const TfToken &name);
646
647private:
648
649 // Helper method for computing the UsdCollectionMembershipQuery object for
650 // a collection.
651 // This makes recursive calls if the collection includes other collections.
652 // \p chainedCollectionPaths is used to pass in the set of all seen and
653 // included collections in the dependency chain and is used to detect
654 // circular dependencies.
655 // If \p foundCircularDependency is not nullptr, it is set to true if a
656 // circular dependency is detected amongst the included collections.
657 // If it is nullptr, a warning is issued when a circular dependency is
658 // detected.
659 void _ComputeMembershipQueryImpl(
661 const SdfPathSet &chainedCollectionPaths,
662 bool *foundCircularDependency=nullptr) const;
663};
664
665PXR_NAMESPACE_CLOSE_SCOPE
666
667#endif
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
Objects of this class represent a logical expression syntax tree consisting of SdfPath matching patte...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
TfType represents a dynamic runtime type.
Definition: type.h:65
The base class for all API schemas.
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:176
This is a general purpose API schema, used to describe a collection of heterogeneous objects within t...
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:134
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
The base class for all schema types in Usd.
Definition: schemaBase.h:56
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:165
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:129
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:457