HDK
 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 
27 /// \file usd/collectionAPI.h
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"
40 
41 
42 #include "pxr/base/vt/value.h"
43 
44 #include "pxr/base/gf/vec3d.h"
45 #include "pxr/base/gf/vec3f.h"
46 #include "pxr/base/gf/matrix4d.h"
47 
48 #include "pxr/base/tf/token.h"
49 #include "pxr/base/tf/type.h"
50 
52 
53 class SdfAssetPath;
54 
55 // -------------------------------------------------------------------------- //
56 // COLLECTIONAPI //
57 // -------------------------------------------------------------------------- //
58 
59 /// \class UsdCollectionAPI
60 ///
61 /// This is a general purpose API schema, used to describe a
62 /// collection of heterogeneous objects within the scene. "Objects" here may be
63 /// prims or properties belonging to prims or other collections. It's an add-on
64 /// schema that can be applied many times to a prim with different collection
65 /// names.
66 ///
67 /// A collection allows an enumeration of a set of paths to include and a
68 /// set of paths to exclude. Whether the descendants of an included
69 /// path are members of a collection are decided by its expansion rule
70 /// (see below). If the collection excludes paths that are not descendents
71 /// of included paths, the collection implicitly includes the root path
72 /// </>. If such a collection also includes paths that are not
73 /// descendants of the excluded paths, it is considered invalid, since
74 /// the intention is ambiguous.
75 ///
76 /// All the properties authored by the schema are namespaced under
77 /// "collection:". The given name of the collection provides additional
78 /// namespacing for the various per-collection properties, which include the
79 /// following:
80 ///
81 /// <ul><li><b>uniform token collection:<i>collectionName</i>:expansionRule</b> -
82 /// specified how the paths that are included in the collection must be expanded
83 /// to determine its members. Possible values include:
84 /// <ul>
85 /// <li><b>explicitOnly</b> - only paths in the includes rel targets and not
86 /// in the excludes rel targets belong to the collection.
87 /// </li>
88 /// <li><b>expandPrims</b> - all the prims at or below the includes rel-
89 /// targets (and not under the excludes rel-targets) belong to the
90 /// collection. Any property paths included in the collection would, of
91 /// course, also be honored. This is the default behavior as it satisfies
92 /// most use cases.
93 /// </li>
94 /// <li><b>expandPrimsAndProperties</b> - like expandPrims, but also
95 /// includes all properties on all matched prims. We're still not quite
96 /// sure what the use cases are for this, but you can use it to capture a
97 /// whole lot of UsdObjects very concisely.
98 /// </li>
99 /// </ul>
100 /// </li>
101 /// <li><b>bool collection:<i>collectionName</i>:includeRoot</b> - boolean
102 /// attribute indicating whether the pseudo-root path &lt;/&gt; should
103 /// be counted as one of the included target paths. The fallback is false.
104 /// This separate attribute is required because relationships cannot
105 /// directly target the root. When expansionRule is explicitOnly, this
106 /// attribute is ignored.
107 /// <li><b>rel collection:<i>collectionName</i>:includes</b> - specifies a list
108 /// of targets that are included in the collection. This can target prims or
109 /// properties directly. A collection can insert the rules of another
110 /// collection by making its <i>includes</i> relationship target the
111 /// <b>collection:{collectionName}</b> property on the owning prim of the
112 /// collection to be included (see UsdCollectionAPI::GetCollectionAttr).
113 /// It is important to note that including another collection does not
114 /// guarantee the contents of that collection will be in the final collection;
115 /// instead, the rules are merged. This means, for example, an exclude
116 /// entry may exclude a portion of the included collection.
117 /// When a collection includes one or more collections, the order in which
118 /// targets are added to the includes relationship may become significant, if
119 /// there are conflicting opinions about the same path. Targets that are added
120 /// later are considered to be stronger than earlier targets for the same path.
121 /// </li>
122 /// <li><b>rel collection:<i>collectionName</i>:excludes</b> - specifies a list
123 /// of targets that are excluded below the <b>included</b> paths in this
124 /// collection. This can target prims or properties directly, but <b>cannot
125 /// target another collection</b>. This is to keep the membership determining
126 /// logic simple, efficient and easier to reason about. Finally, it is invalid
127 /// for a collection to exclude paths that are not included in it. The presence
128 /// of such "orphaned" excluded paths will not affect the set of paths included
129 /// in the collection, but may affect the performance of querying membership of
130 /// a path in the collection (see UsdCollectionAPI::MembershipQuery::IsPathIncluded)
131 /// or of enumerating the objects belonging to the collection (see
132 /// UsdCollectionAPI::GetIncludedObjects).
133 /// </li>
134 /// <li><b>uniform opaque collection:<i>collectionName</i></b> - opaque
135 /// attribute (meaning it can never have a value) that represents the collection
136 /// for the purpose of allowing another collection to include it. When this
137 /// property is targeted by another collection's <i>includes</i> relationship,
138 /// the rules of this collection will be inserted into the rules of the collection
139 /// that includes it.
140 /// </li></ul>
141 ///
142 /// <b>Implicit inclusion</b>
143 ///
144 /// In some scenarios it is useful to express a collection that includes
145 /// everything except certain paths. To support this, a collection
146 /// that has an exclude that is not a descendent of any include
147 /// will include the root path &lt;/&gt;.
148 ///
149 /// <b>Creating collections in C++</b>
150 ///
151 /// \snippet examples_usd.cpp ApplyCollections
152 ///
153 ///
154 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
155 /// that are text/tokens, the actual token is published and defined in \ref UsdTokens.
156 /// So to set an attribute to the value "rightHanded", use UsdTokens->rightHanded
157 /// as the value.
158 ///
160 {
161 public:
162  /// Compile time constant representing what kind of schema this class is.
163  ///
164  /// \sa UsdSchemaKind
166 
167  /// Construct a UsdCollectionAPI on UsdPrim \p prim with
168  /// name \p name . Equivalent to
169  /// UsdCollectionAPI::Get(
170  /// prim.GetStage(),
171  /// prim.GetPath().AppendProperty(
172  /// "collection:name"));
173  ///
174  /// for a \em valid \p prim, but will not immediately throw an error for
175  /// an invalid \p prim
177  const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
178  : UsdAPISchemaBase(prim, /*instanceName*/ name)
179  { }
180 
181  /// Construct a UsdCollectionAPI on the prim held by \p schemaObj with
182  /// name \p name. Should be preferred over
183  /// UsdCollectionAPI(schemaObj.GetPrim(), name), as it preserves
184  /// SchemaBase state.
186  const UsdSchemaBase& schemaObj, const TfToken &name)
187  : UsdAPISchemaBase(schemaObj, /*instanceName*/ name)
188  { }
189 
190  /// Destructor.
191  USD_API
192  virtual ~UsdCollectionAPI();
193 
194  /// Return a vector of names of all pre-declared attributes for this schema
195  /// class and all its ancestor classes. Does not include attributes that
196  /// may be authored by custom/extended methods of the schemas involved.
197  USD_API
198  static const TfTokenVector &
199  GetSchemaAttributeNames(bool includeInherited=true);
200 
201  /// Return a vector of names of all pre-declared attributes for this schema
202  /// class and all its ancestor classes for a given instance name. Does not
203  /// include attributes that may be authored by custom/extended methods of
204  /// the schemas involved. The names returned will have the proper namespace
205  /// prefix.
206  USD_API
207  static TfTokenVector
208  GetSchemaAttributeNames(bool includeInherited, const TfToken &instanceName);
209 
210  /// Returns the name of this multiple-apply schema instance
211  TfToken GetName() const {
212  return _GetInstanceName();
213  }
214 
215  /// Return a UsdCollectionAPI holding the prim adhering to this
216  /// schema at \p path on \p stage. If no prim exists at \p path on
217  /// \p stage, or if the prim at that path does not adhere to this schema,
218  /// return an invalid schema object. \p path must be of the format
219  /// <path>.collection:name .
220  ///
221  /// This is shorthand for the following:
222  ///
223  /// \code
224  /// TfToken name = SdfPath::StripNamespace(path.GetToken());
225  /// UsdCollectionAPI(
226  /// stage->GetPrimAtPath(path.GetPrimPath()), name);
227  /// \endcode
228  ///
229  USD_API
230  static UsdCollectionAPI
231  Get(const UsdStagePtr &stage, const SdfPath &path);
232 
233  /// Return a UsdCollectionAPI with name \p name holding the
234  /// prim \p prim. Shorthand for UsdCollectionAPI(prim, name);
235  USD_API
236  static UsdCollectionAPI
237  Get(const UsdPrim &prim, const TfToken &name);
238 
239  /// Return a vector of all named instances of UsdCollectionAPI on the
240  /// given \p prim.
241  USD_API
242  static std::vector<UsdCollectionAPI>
243  GetAll(const UsdPrim &prim);
244 
245  /// Checks if the given name \p baseName is the base name of a property
246  /// of CollectionAPI.
247  USD_API
248  static bool
249  IsSchemaPropertyBaseName(const TfToken &baseName);
250 
251  /// Checks if the given path \p path is of an API schema of type
252  /// CollectionAPI. If so, it stores the instance name of
253  /// the schema in \p name and returns true. Otherwise, it returns false.
254  USD_API
255  static bool
257 
258  /// Returns true if this <b>multiple-apply</b> API schema can be applied,
259  /// with the given instance name, \p name, to the given \p prim. If this
260  /// schema can not be a applied the prim, this returns false and, if
261  /// provided, populates \p whyNot with the reason it can not be applied.
262  ///
263  /// Note that if CanApply returns false, that does not necessarily imply
264  /// that calling Apply will fail. Callers are expected to call CanApply
265  /// before calling Apply if they want to ensure that it is valid to
266  /// apply a schema.
267  ///
268  /// \sa UsdPrim::GetAppliedSchemas()
269  /// \sa UsdPrim::HasAPI()
270  /// \sa UsdPrim::CanApplyAPI()
271  /// \sa UsdPrim::ApplyAPI()
272  /// \sa UsdPrim::RemoveAPI()
273  ///
274  USD_API
275  static bool
276  CanApply(const UsdPrim &prim, const TfToken &name,
277  std::string *whyNot=nullptr);
278 
279  /// Applies this <b>multiple-apply</b> API schema to the given \p prim
280  /// along with the given instance name, \p name.
281  ///
282  /// This information is stored by adding "CollectionAPI:<i>name</i>"
283  /// to the token-valued, listOp metadata \em apiSchemas on the prim.
284  /// For example, if \p name is 'instance1', the token
285  /// 'CollectionAPI:instance1' is added to 'apiSchemas'.
286  ///
287  /// \return A valid UsdCollectionAPI object is returned upon success.
288  /// An invalid (or empty) UsdCollectionAPI object is returned upon
289  /// failure. See \ref UsdPrim::ApplyAPI() for
290  /// conditions resulting in failure.
291  ///
292  /// \sa UsdPrim::GetAppliedSchemas()
293  /// \sa UsdPrim::HasAPI()
294  /// \sa UsdPrim::CanApplyAPI()
295  /// \sa UsdPrim::ApplyAPI()
296  /// \sa UsdPrim::RemoveAPI()
297  ///
298  USD_API
299  static UsdCollectionAPI
300  Apply(const UsdPrim &prim, const TfToken &name);
301 
302 protected:
303  /// Returns the kind of schema this class belongs to.
304  ///
305  /// \sa UsdSchemaKind
306  USD_API
307  UsdSchemaKind _GetSchemaKind() const override;
308 
309 private:
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 
321 public:
322  // --------------------------------------------------------------------- //
323  // EXPANSIONRULE
324  // --------------------------------------------------------------------- //
325  /// Specifies how the paths that are included in
326  /// the collection must be expanded to determine its members.
327  ///
328  /// | ||
329  /// | -- | -- |
330  /// | Declaration | `uniform token expansionRule = "expandPrims"` |
331  /// | C++ Type | TfToken |
332  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
333  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
334  /// | \ref UsdTokens "Allowed Values" | explicitOnly, expandPrims, expandPrimsAndProperties |
335  USD_API
337 
338  /// See GetExpansionRuleAttr(), and also
339  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
340  /// If specified, author \p defaultValue as the attribute's default,
341  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
342  /// the default for \p writeSparsely is \c false.
343  USD_API
344  UsdAttribute CreateExpansionRuleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
345 
346 public:
347  // --------------------------------------------------------------------- //
348  // INCLUDEROOT
349  // --------------------------------------------------------------------- //
350  /// Boolean attribute indicating whether the pseudo-root
351  /// path &lt;/&gt; should be counted as one of the included target
352  /// paths. The fallback is false. This separate attribute is
353  /// required because relationships cannot directly target the root.
354  ///
355  /// | ||
356  /// | -- | -- |
357  /// | Declaration | `uniform bool includeRoot` |
358  /// | C++ Type | bool |
359  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
360  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
361  USD_API
363 
364  /// See GetIncludeRootAttr(), and also
365  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
366  /// If specified, author \p defaultValue as the attribute's default,
367  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
368  /// the default for \p writeSparsely is \c false.
369  USD_API
370  UsdAttribute CreateIncludeRootAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
371 
372 public:
373  // --------------------------------------------------------------------- //
374  // MEMBERSHIPEXPRESSION
375  // --------------------------------------------------------------------- //
376  /// Specifies a path expression that determines membership in this
377  /// collection.
378  ///
379  /// | ||
380  /// | -- | -- |
381  /// | Declaration | `uniform pathExpression membershipExpression` |
382  /// | C++ Type | SdfPathExpression |
383  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->PathExpression |
384  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
385  USD_API
387 
388  /// See GetMembershipExpressionAttr(), and also
389  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
390  /// If specified, author \p defaultValue as the attribute's default,
391  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
392  /// the default for \p writeSparsely is \c false.
393  USD_API
394  UsdAttribute CreateMembershipExpressionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
395 
396 public:
397  // --------------------------------------------------------------------- //
398  // COLLECTION
399  // --------------------------------------------------------------------- //
400  /// This property represents the collection for the purpose of
401  /// allowing another collection to include it. When this property is
402  /// targeted by another collection's <i>includes</i> relationship, the rules
403  /// of this collection will be inserted into the rules of the collection
404  /// that includes it.
405  ///
406  ///
407  /// | ||
408  /// | -- | -- |
409  /// | Declaration | `uniform opaque __INSTANCE_NAME__` |
410  /// | C++ Type | SdfOpaqueValue |
411  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Opaque |
412  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
413  USD_API
415 
416  /// See GetCollectionAttr(), and also
417  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
418  /// If specified, author \p defaultValue as the attribute's default,
419  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
420  /// the default for \p writeSparsely is \c false.
421  USD_API
422  UsdAttribute CreateCollectionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
423 
424 public:
425  // --------------------------------------------------------------------- //
426  // INCLUDES
427  // --------------------------------------------------------------------- //
428  /// Specifies a list of targets that are included in the collection.
429  /// This can target prims or properties directly. A collection can insert
430  /// the rules of another collection by making its <i>includes</i>
431  /// relationship target the <b>collection:{collectionName}</b> property on
432  /// the owning prim of the collection to be included
433  ///
434  USD_API
436 
437  /// See GetIncludesRel(), and also
438  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
439  USD_API
441 
442 public:
443  // --------------------------------------------------------------------- //
444  // EXCLUDES
445  // --------------------------------------------------------------------- //
446  /// Specifies a list of targets that are excluded below
447  /// the included paths in this collection. This can target prims or
448  /// properties directly, but cannot target another collection. This is to
449  /// keep the membership determining logic simple, efficient and easier to
450  /// reason about. Finally, it is invalid for a collection to exclude
451  /// paths that are not included in it. The presence of such "orphaned"
452  /// excluded paths will not affect the set of paths included in the
453  /// collection, but may affect the performance of querying membership of
454  /// a path in the collection (see
455  /// UsdCollectionAPI::MembershipQuery::IsPathIncluded)
456  /// or of enumerating the objects belonging to the collection (see
457  /// UsdCollectionAPI::GetIncludedObjects).
458  ///
459  USD_API
461 
462  /// See GetExcludesRel(), and also
463  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
464  USD_API
466 
467 public:
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 
479 public:
480  /// Returns the collection represented by the given collection path,
481  /// \p collectionPath on the given USD stage.
482  USD_API
483  static UsdCollectionAPI GetCollection(const UsdStagePtr &stage,
484  const SdfPath &collectionPath);
485 
486  /// Returns the schema object representing a collection named \p name on
487  /// the given \p prim.
488  USD_API
489  static UsdCollectionAPI GetCollection(const UsdPrim &prim,
490  const TfToken &name);
491 
492  /// Returns all the named collections on the given USD prim.
493  /// \deprecated Use GetAll(prim) instead.
494  USD_API
495  static std::vector<UsdCollectionAPI> GetAllCollections(const UsdPrim &prim);
496 
497  /// Returns the canonical path that represents this collection.
498  /// This points to the property named "collection:{collectionName}" on the
499  /// prim defining the collection. This is the path to be used to "include"
500  /// this collection in another collection.
501  ///
502  /// \sa GetCollectionAttr()
503  USD_API
504  SdfPath GetCollectionPath() const;
505 
506  /// Returns the canonical path to the collection named, \p name on the given
507  /// prim, \p prim.
508  ///
509  /// \sa GetCollectionPath()
510  USD_API
512  const UsdPrim &prim,
513  const TfToken &collectionName);
514 
515  USD_API
516  static SdfPathExpression
518  UsdPrim const &prim);
519 
520  /// Obtain a complete SdfPathExpression from this collection's
521  /// membershipExpression. First, UsdAttribute::Get() the value of
522  /// GetMembershipExpressionAttr(), then resolve any contained references.
523  /// Replace any remaining "weaker" references (%_) with
524  /// SdfPathExpression::Nothing(). Replace other references by recursively
525  /// resolving the expressions from the collections on the referenced prims.
526  /// If no such prims or no such collections exist, replace those references
527  /// with SdfPathExpression::Nothing() as well.
528  USD_API
530 
531  // Convenient alias for UsdCollectionMembershipQuery object
533 
534  /// Computes and returns a UsdCollectionMembershipQuery object which can
535  /// be used to query inclusion or exclusion of paths in the collection.
536  USD_API
538 
539  /// Populates the UsdCollectionMembershipQuery object with data from this
540  /// collection, so it can be used to query inclusion or exclusion of paths.
541  USD_API
543 
544  /// Returns true if the collection has nothing included in it.
545  /// This requires both that the includes relationship have no
546  /// target paths, and that the includeRoot attribute be false.
547  /// Note that there may be cases where the collection has no objects
548  /// included in it even when HasNoIncludedPaths() returns false.
549  /// For example, if the included objects are unloaded or if the
550  /// included objects are also excluded.
551  USD_API
552  bool HasNoIncludedPaths() const;
553 
554  /// Returns all the usd objects that satisfy the predicate, \p pred in the
555  /// collection represented by the UsdCollectionMembershipQuery object, \p
556  /// query.
557  ///
558  /// The results depends on the load state of the UsdStage, \p stage.
559  USD_API
560  static std::set<UsdObject> ComputeIncludedObjects(
562  const UsdStageWeakPtr &stage,
564 
565  /// Returns all the paths that satisfy the predicate, \p pred in the
566  /// collection represented by the UsdCollectionMembershipQuery object, \p
567  /// query.
568  ///
569  /// The result depends on the load state of the UsdStage, \p stage.
570  USD_API
573  const UsdStageWeakPtr &stage,
575 
576  /// @}
577 
578  /// \anchor UsdCollectionAPI_AuthoringAPI
579  /// \name Collection Authoring API
580  ///
581  /// Convenience API for adding or removing prims and properties to (or
582  /// from) a collection..
583  ///
584  /// @{
585 
586  /// Includes or adds the given path, \p pathToInclude in the collection.
587  ///
588  /// This does nothing if the path is already included in the collection.
589  ///
590  /// This does not modify the expansion-rule of the collection. Hence, if the
591  /// expansionRule is <i>expandPrims</i> or <i>expandPrimsAndProperties</i>,
592  /// then the descendants of \p pathToInclude will be also included in the
593  /// collection unless explicitly excluded.
594  ///
595  /// \sa UsdCollectionAPI::ExcludePath()
596  USD_API
597  bool IncludePath(const SdfPath &pathToInclude) const;
598 
599  /// Excludes or removes the given path, \p pathToExclude from the collection.
600  ///
601  /// If the collection is empty, the collection becomes one that
602  /// includes all paths except the givne path. Otherwise, this does
603  /// nothing if the path is not included in the collection.
604  ///
605  /// This does not modify the expansion-rule of the collection. Hence, if the
606  /// expansionRule is <i>expandPrims</i> or <i>expandPrimsAndProperties</i>,
607  /// then the descendants of \p pathToExclude will also be excluded from the
608  /// collection, unless explicitly included.
609  ///
610  /// \sa UsdCollectionAPI::IncludePath()
611  USD_API
612  bool ExcludePath(const SdfPath &pathToExclude) const;
613 
614  /// @}
615 
616  /// Validates the collection by checking the following rules:
617  /// * a collection's expansionRule should be one of "explicitOnly",
618  /// "expandPrims" or "expandPrimsAndProperties".
619  /// * a collection should not have have a circular dependency on
620  /// another collection.
621  /// * a collection should not have both includes and excludes
622  /// among its top-level rules
623  USD_API
624  bool Validate(std::string *reason) const;
625 
626  /// Resets the collection by clearing both the includes and excludes
627  /// targets of the collection in the current UsdEditTarget.
628  ///
629  /// \note This does not modify the "includeRoot" attribute which is used
630  /// to include or exclude everything (i.e. the pseudoRoot) in the USD stage.
631  USD_API
632  bool ResetCollection() const;
633 
634  /// Blocks the targets of the includes and excludes relationships of the
635  /// collection, making it
636  /// <* <i>empty</i> if "includeRoot" is false (or unset) or
637  /// * <i>include everything</i> if "includeRoot" is true.
638  /// (assuming there are no opinions in stronger edit targets).
639  USD_API
640  bool BlockCollection() const;
641 
642  /// Test whether a given \p name contains the "collection:" prefix
643  ///
644  USD_API
645  static bool CanContainPropertyName(const TfToken &name);
646 
647 private:
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 
666 
667 #endif
static USD_API UsdCollectionAPI Apply(const UsdPrim &prim, const TfToken &name)
USD_API UsdCollectionMembershipQuery ComputeMembershipQuery() const
GLenum query
Definition: glad.h:2772
USD_API bool BlockCollection() const
static USD_API SdfPath GetNamedCollectionPath(const UsdPrim &prim, const TfToken &collectionName)
static USD_API std::vector< UsdCollectionAPI > GetAllCollections(const UsdPrim &prim)
#define USD_API
Definition: api.h:40
USD_API UsdRelationship GetExcludesRel() const
USD_API bool HasNoIncludedPaths() const
USD_API UsdAttribute GetIncludeRootAttr() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
USD_API bool IncludePath(const SdfPath &pathToInclude) const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USD_API UsdRelationship CreateExcludesRel() const
Represents a flattened view of a collection. For more information about collections, please see UsdCollectionAPI as a way to encode and retrieve a collection from scene description. A UsdCollectionMembershipQuery object can be used to answer queries about membership of paths in the collection efficiently.
static USD_API bool CanApply(const UsdPrim &prim, const TfToken &name, std::string *whyNot=nullptr)
UsdStagePtr UsdStageWeakPtr
Definition: common.h:55
USD_API bool ResetCollection() const
USD_API SdfPathExpression ResolveCompleteMembershipExpression() const
USD_API UsdRelationship CreateIncludesRel() const
static USD_API UsdCollectionAPI Get(const UsdStagePtr &stage, const SdfPath &path)
USD_API UsdAttribute CreateExpansionRuleAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
const TfToken & _GetInstanceName() const
TfToken GetName() const
Returns the name of this multiple-apply schema instance.
Definition: token.h:87
static USD_API bool IsCollectionAPIPath(const SdfPath &path, TfToken *name)
USD_API SdfPath GetCollectionPath() const
static USD_API UsdCollectionAPI GetCollection(const UsdStagePtr &stage, const SdfPath &collectionPath)
USD_API UsdAttribute CreateMembershipExpressionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USD_API bool Validate(std::string *reason) const
USD_API UsdAttribute GetMembershipExpressionAttr() const
USD_API UsdAttribute GetExpansionRuleAttr() const
Definition: prim.h:133
static USD_API bool IsSchemaPropertyBaseName(const TfToken &baseName)
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:290
USD_API UsdAttribute GetCollectionAttr() const
std::set< class SdfPath > SdfPathSet
A set of SdfPaths.
Definition: path.h:209
UsdSchemaKind
Definition: common.h:129
USD_API UsdAttribute CreateCollectionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USD_API const Usd_PrimFlagsConjunction UsdPrimDefaultPredicate
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
static const UsdSchemaKind schemaKind
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USD_API UsdAttribute CreateIncludeRootAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: type.h:64
virtual USD_API ~UsdCollectionAPI()
Destructor.
static USD_API SdfPathSet ComputeIncludedPaths(const UsdCollectionMembershipQuery &query, const UsdStageWeakPtr &stage, const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate)
Usd_CollectionMembershipQuery< UsdObjectCollectionExpressionEvaluator > UsdCollectionMembershipQuery
static USD_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USD_API UsdSchemaKind _GetSchemaKind() const override
UsdCollectionAPI(const UsdPrim &prim=UsdPrim(), const TfToken &name=TfToken())
static USD_API std::vector< UsdCollectionAPI > GetAll(const UsdPrim &prim)
Definition: value.h:164
Multiple Apply API Schema.
static USD_API std::set< UsdObject > ComputeIncludedObjects(const UsdCollectionMembershipQuery &query, const UsdStageWeakPtr &stage, const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate)
USD_API UsdRelationship GetIncludesRel() const
USD_API bool ExcludePath(const SdfPath &pathToExclude) const
UsdCollectionAPI(const UsdSchemaBase &schemaObj, const TfToken &name)
static USD_API bool CanContainPropertyName(const TfToken &name)