All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
37 #include "pxr/usd/usd/primFlags.h"
38 #include "pxr/usd/usd/tokens.h"
39 
40 
41 #include "pxr/base/vt/value.h"
42 
43 #include "pxr/base/gf/vec3d.h"
44 #include "pxr/base/gf/vec3f.h"
45 #include "pxr/base/gf/matrix4d.h"
46 
47 #include "pxr/base/tf/token.h"
48 #include "pxr/base/tf/type.h"
49 
50 PXR_NAMESPACE_OPEN_SCOPE
51 
52 class SdfAssetPath;
53 
54 // -------------------------------------------------------------------------- //
55 // COLLECTIONAPI //
56 // -------------------------------------------------------------------------- //
57 
153 {
154 public:
159 
170  const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
171  : UsdAPISchemaBase(prim, /*instanceName*/ name)
172  { }
173 
179  const UsdSchemaBase& schemaObj, const TfToken &name)
180  : UsdAPISchemaBase(schemaObj, /*instanceName*/ name)
181  { }
182 
184  USD_API
185  virtual ~UsdCollectionAPI();
186 
192  USD_API
193  static const TfTokenVector &
195  bool includeInherited=true, const TfToken instanceName=TfToken());
196 
198  TfToken GetName() const {
199  return _GetInstanceName();
200  }
201 
216  USD_API
217  static UsdCollectionAPI
218  Get(const UsdStagePtr &stage, const SdfPath &path);
219 
222  USD_API
223  static UsdCollectionAPI
224  Get(const UsdPrim &prim, const TfToken &name);
225 
228  USD_API
229  static bool
230  IsSchemaPropertyBaseName(const TfToken &baseName);
231 
235  USD_API
236  static bool
237  IsCollectionAPIPath(const SdfPath &path, TfToken *name);
238 
255  USD_API
256  static bool
257  CanApply(const UsdPrim &prim, const TfToken &name,
258  std::string *whyNot=nullptr);
259 
279  USD_API
280  static UsdCollectionAPI
281  Apply(const UsdPrim &prim, const TfToken &name);
282 
283 protected:
287  USD_API
288  UsdSchemaKind _GetSchemaKind() const override;
289 
290 private:
291  // needs to invoke _GetStaticTfType.
292  friend class UsdSchemaRegistry;
293  USD_API
294  static const TfType &_GetStaticTfType();
295 
296  static bool _IsTypedSchema();
297 
298  // override SchemaBase virtuals.
299  USD_API
300  const TfType &_GetTfType() const override;
301 
302 public:
303  // --------------------------------------------------------------------- //
304  // EXPANSIONRULE
305  // --------------------------------------------------------------------- //
316  USD_API
318 
324  USD_API
325  UsdAttribute CreateExpansionRuleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
326 
327 public:
328  // --------------------------------------------------------------------- //
329  // INCLUDEROOT
330  // --------------------------------------------------------------------- //
342  USD_API
344 
350  USD_API
351  UsdAttribute CreateIncludeRootAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
352 
353 public:
354  // --------------------------------------------------------------------- //
355  // INCLUDES
356  // --------------------------------------------------------------------- //
363  USD_API
365 
368  USD_API
370 
371 public:
372  // --------------------------------------------------------------------- //
373  // EXCLUDES
374  // --------------------------------------------------------------------- //
388  USD_API
390 
393  USD_API
395 
396 public:
397  // ===================================================================== //
398  // Feel free to add custom code below this line, it will be preserved by
399  // the code generator.
400  //
401  // Just remember to:
402  // - Close the class declaration with };
403  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
404  // - Close the include guard with #endif
405  // ===================================================================== //
406  // --(BEGIN CUSTOM CODE)--
407 
408 public:
411  USD_API
412  static UsdCollectionAPI GetCollection(const UsdStagePtr &stage,
413  const SdfPath &collectionPath);
414 
417  USD_API
418  static UsdCollectionAPI GetCollection(const UsdPrim &prim,
419  const TfToken &name);
420 
422  USD_API
423  static std::vector<UsdCollectionAPI> GetAllCollections(const UsdPrim &prim);
424 
431  USD_API
432  SdfPath GetCollectionPath() const;
433 
438  USD_API
440  const UsdPrim &prim,
441  const TfToken &collectionName);
442 
443  // Convenient alias for UsdCollectionMembershipQuery object
444  using MembershipQuery = UsdCollectionMembershipQuery;
445 
448  USD_API
450 
453  USD_API
455 
463  USD_API
464  bool HasNoIncludedPaths() const;
465 
471  USD_API
472  static std::set<UsdObject> ComputeIncludedObjects(
473  const UsdCollectionMembershipQuery &query,
474  const UsdStageWeakPtr &stage,
475  const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate);
476 
482  USD_API
483  static SdfPathSet ComputeIncludedPaths(
484  const UsdCollectionMembershipQuery &query,
485  const UsdStageWeakPtr &stage,
486  const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate);
487 
489 
497 
508  USD_API
509  bool IncludePath(const SdfPath &pathToInclude) const;
510 
523  USD_API
524  bool ExcludePath(const SdfPath &pathToExclude) const;
525 
527 
535  USD_API
536  bool Validate(std::string *reason) const;
537 
543  USD_API
544  bool ResetCollection() const;
545 
551  USD_API
552  bool BlockCollection() const;
553 
556  USD_API
557  static bool CanContainPropertyName(const TfToken &name);
558 
559 private:
560 
561  // Returns the name of the property belonging to this collection, given the
562  // base name of the attribute. Eg, if baseName is 'includes', this
563  // returns 'collection:<name>:includes'.
564  TfToken _GetCollectionPropertyName(const TfToken &baseName=TfToken()) const;
565 
566  // Helper method for computing the UsdCollectionMembershipQuery object for
567  // a collection.
568  // This makes recursive calls if the collection includes other collections.
569  // \p chainedCollectionPaths is used to pass in the set of all seen and
570  // included collections in the dependency chain and is used to detect
571  // circular dependencies.
572  // If \p foundCircularDependency is not nullptr, it is set to true if a
573  // circular dependency is detected amongst the included collections.
574  // If it is nullptr, a warning is issued when a circular dependency is
575  // detected.
576  void _ComputeMembershipQueryImpl(
578  const SdfPathSet &chainedCollectionPaths,
579  bool *foundCircularDependency=nullptr) const;
580 };
581 
582 PXR_NAMESPACE_CLOSE_SCOPE
583 
584 #endif
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 bool Validate(std::string *reason) const
Validates the collection by checking the following rules:
USD_API bool IncludePath(const SdfPath &pathToInclude) const
Includes or adds the given path, pathToInclude in the collection.
unspecified UsdPrimDefaultPredicate
The default predicate used for prim traversals in methods like UsdPrim::GetChildren, UsdStage::Traverse, and by UsdPrimRange.
TfToken GetName() const
Returns the name of this multiple-apply schema instance.
Represents a flattened view of a collection.
USD_API UsdAttribute GetExpansionRuleAttr() const
Specifies how the paths that are included in the collection must be expanded to determine its members...
The base class for all API schemas.
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
USD_API UsdRelationship GetExcludesRel() const
Specifies a list of targets that are excluded below the included paths in this collection.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
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...
UsdCollectionAPI(const UsdPrim &prim=UsdPrim(), const TfToken &name=TfToken())
Construct a UsdCollectionAPI on UsdPrim prim 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...
This is a general purpose API schema, used to describe a collection of heterogeneous objects within t...
USD_API bool BlockCollection() const
Blocks the targets of the includes and excludes relationships of the collection, making it &lt;* empty i...
static USD_API std::vector< UsdCollectionAPI > GetAllCollections(const UsdPrim &prim)
Returns all the named collections on the given USD prim.
USD_API UsdRelationship CreateIncludesRel() const
See GetIncludesRel(), and also Create vs Get Property Methods for when to use Get vs Create...
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.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
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. ...
static USD_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true, const TfToken instanceName=TfToken())
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
static USD_API bool IsSchemaPropertyBaseName(const TfToken &baseName)
Checks if the given name baseName is the base name of a property of CollectionAPI.
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
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...
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
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...
USD_API UsdCollectionMembershipQuery ComputeMembershipQuery() const
Computes and returns a UsdCollectionMembershipQuery object which can be used to query inclusion or ex...
Multiple Apply API Schema.
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...
USD_API bool ExcludePath(const SdfPath &pathToExclude) const
Excludes or removes the given path, pathToExclude from the collection.
UsdCollectionAPI(const UsdSchemaBase &schemaObj, const TfToken &name)
Construct a UsdCollectionAPI on the prim held by schemaObj with name name.
USD_API bool ResetCollection() const
Resets the collection by clearing both the includes and excludes targets of the collection in the cur...
USD_API UsdRelationship CreateExcludesRel() const
See GetExcludesRel(), and also Create vs Get Property Methods for when to use Get vs Create...
TfType represents a dynamic runtime type.
Definition: type.h:64
Singleton registry that provides access to schema type information and the prim definitions for regis...
virtual USD_API ~UsdCollectionAPI()
Destructor.
USD_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
USD_API SdfPath GetCollectionPath() const
Returns the canonical path that represents this collection.
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
USD_API UsdRelationship GetIncludesRel() const
Specifies a list of targets that are included in the collection.
The base class for all schema types in Usd.
Definition: schemaBase.h:56
static USD_API bool IsCollectionAPIPath(const SdfPath &path, TfToken *name)
Checks if the given path path is of an API schema of type CollectionAPI.
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 bool HasNoIncludedPaths() const
Returns true if the collection has nothing included in it.
USD_API UsdAttribute GetIncludeRootAttr() const
Boolean attribute indicating whether the pseudo-root path &lt;/&gt; should be counted as one of the include...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
const TfToken & _GetInstanceName() const
Returns the instance name of the API schema object belonging to a multiple-apply API schema...
static USD_API bool CanContainPropertyName(const TfToken &name)
Test whether a given name contains the &quot;collection:&quot; prefix.