HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
specializes.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 PXR_USD_USD_SPECIALIZES_H
8 #define PXR_USD_USD_SPECIALIZES_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/usd/api.h"
12 #include "pxr/usd/usd/common.h"
13 #include "pxr/usd/usd/prim.h"
14 
16 #include "pxr/usd/sdf/path.h"
17 
19 
21 
22 /// \class UsdSpecializes
23 ///
24 /// A proxy class for applying listOp edits to the specializes list for a
25 /// prim.
26 ///
27 /// All paths passed to the UsdSpecializes API are expected to be in the
28 /// namespace of the owning prim's stage. Subroot prim specializes paths
29 /// will be translated from this namespace to the namespace of the current
30 /// edit target, if necessary. If a path cannot be translated, a coding error
31 /// will be issued and no changes will be made. Root prim specializes paths
32 /// will not be translated.
33 ///
35  friend class UsdPrim;
36 
37  explicit UsdSpecializes(const UsdPrim& prim) : _prim(prim) {}
38 
39 public:
40 
41  /// Adds a path to the specializes listOp at the current EditTarget,
42  /// in the position specified by \p position.
43  USD_API
44  bool AddSpecialize(const SdfPath &primPath,
46 
47  /// Removes the specified path from the specializes listOp at the
48  /// current EditTarget.
49  USD_API
50  bool RemoveSpecialize(const SdfPath &primPath);
51 
52  /// Removes the authored specializes listOp edits at the current edit
53  /// target.
54  USD_API
55  bool ClearSpecializes();
56 
57  /// Explicitly set specializes paths, potentially blocking weaker opinions
58  /// that add or remove items, returning true on success, false if the edit
59  /// could not be performed.
60  USD_API
61  bool SetSpecializes(const SdfPathVector& items);
62 
63  /// Return the prim this object is bound to.
64  const UsdPrim &GetPrim() const { return _prim; }
65  UsdPrim GetPrim() { return _prim; }
66 
67  explicit operator bool() { return bool(_prim); }
68 
69  // ---------------------------------------------------------------------- //
70  // Private Methods and Members
71  // ---------------------------------------------------------------------- //
72 private:
73 
74  UsdPrim _prim;
75 };
76 
78 
79 #endif //PXR_USD_USD_SPECIALIZES_H
USD_API bool AddSpecialize(const SdfPath &primPath, UsdListPosition position=UsdListPositionBackOfPrependList)
#define USD_API
Definition: api.h:23
OutGridT const XformOp bool bool
UsdPrim GetPrim()
Definition: specializes.h:65
std::vector< class SdfPath > SdfPathVector
Definition: prim.h:116
Definition: path.h:273
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
SIM_API const UT_StringHolder position
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USD_API bool ClearSpecializes()
USD_API bool SetSpecializes(const SdfPathVector &items)
UsdListPosition
Definition: common.h:71
const UsdPrim & GetPrim() const
Return the prim this object is bound to.
Definition: specializes.h:64
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfPrimSpec)
USD_API bool RemoveSpecialize(const SdfPath &primPath)