HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
payloads.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 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_PAYLOADS_H
8 #define PXR_USD_USD_PAYLOADS_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 #include "pxr/usd/sdf/payload.h"
18 
20 
21 /// \class UsdPayloads
22 ///
23 /// UsdPayloads provides an interface to authoring and introspecting payloads.
24 /// Payloads behave the same as Usd references except that payloads can be
25 /// optionally loaded.
26 class UsdPayloads {
27  friend class UsdPrim;
28 
29  explicit UsdPayloads(const UsdPrim& prim) : _prim(prim) {}
30 
31 public:
32  /// Adds a payload to the payload listOp at the current EditTarget, in the
33  /// position specified by \p position.
34  /// \sa \ref Usd_Failing_References "Why adding references may fail" for
35  /// explanation of expectations on \p payload and what return values and
36  /// errors to expect, and \ref Usd_OM_ListOps for details on list editing
37  /// and composition of listOps.
38  USD_API
39  bool AddPayload(const SdfPayload& payload,
41 
42  /// \overload
43  USD_API
44  bool AddPayload(const std::string &identifier,
45  const SdfPath &primPath,
46  const SdfLayerOffset &layerOffset = SdfLayerOffset(),
48 
49  /// \overload
50  /// \sa \ref Usd_DefaultPrim_References "Payloads Without Prim Paths"
51  USD_API
52  bool AddPayload(const std::string &identifier,
53  const SdfLayerOffset &layerOffset = SdfLayerOffset(),
55 
56  /// Add an internal payload to the specified prim.
57  /// \sa \ref Usd_Internal_References "Internal Payloads"
58  USD_API
59  bool AddInternalPayload(const SdfPath &primPath,
60  const SdfLayerOffset &layerOffset = SdfLayerOffset(),
62 
63  /// Removes the specified payload from the payloads listOp at the
64  /// current EditTarget. This does not necessarily eliminate the payload
65  /// completely, as it may be added or set in another layer in the same
66  /// LayerStack as the current EditTarget.
67  /// \sa \ref Usd_OM_ListOps
68  USD_API
69  bool RemovePayload(const SdfPayload& ref);
70 
71  /// Removes the authored payload listOp edits at the current EditTarget.
72  /// The same caveats for Remove() apply to Clear(). In fact, Clear() may
73  /// actually increase the number of composed payloads, if the listOp being
74  /// cleared contained the "remove" operator.
75  /// \sa \ref Usd_OM_ListOps
76  USD_API
77  bool ClearPayloads();
78 
79  /// Explicitly set the payloads, potentially blocking weaker opinions that
80  /// add or remove items.
81  /// \sa \ref Usd_Failing_References "Why adding payloads may fail" for
82  /// explanation of expectations on \p items and what return values and
83  /// errors to expect, and \ref Usd_OM_ListOps for details on list editing
84  /// and composition of listOps.
85  USD_API
86  bool SetPayloads(const SdfPayloadVector& items);
87 
88  /// Return the prim this object is bound to.
89  const UsdPrim &GetPrim() const { return _prim; }
90 
91  /// \overload
92  UsdPrim GetPrim() { return _prim; }
93 
94  explicit operator bool() { return bool(_prim); }
95 
96 private:
97  UsdPrim _prim;
98 };
99 
101 
102 #endif // PXR_USD_USD_PAYLOADS_H
const UsdPrim & GetPrim() const
Return the prim this object is bound to.
Definition: payloads.h:89
#define USD_API
Definition: api.h:23
std::vector< SdfPayload > SdfPayloadVector
Definition: payload.h:25
USD_API bool ClearPayloads()
UsdPrim GetPrim()
Definition: payloads.h:92
USD_API bool AddInternalPayload(const SdfPath &primPath, const SdfLayerOffset &layerOffset=SdfLayerOffset(), UsdListPosition position=UsdListPositionBackOfPrependList)
OutGridT const XformOp bool bool
GLint ref
Definition: glcorearb.h:124
Definition: prim.h:116
Definition: path.h:273
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USD_API bool RemovePayload(const SdfPayload &ref)
SIM_API const UT_StringHolder position
USD_API bool SetPayloads(const SdfPayloadVector &items)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
UsdListPosition
Definition: common.h:71
USD_API bool AddPayload(const SdfPayload &payload, UsdListPosition position=UsdListPositionBackOfPrependList)