All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
payload.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_SDF_PAYLOAD_H
8#define PXR_USD_SDF_PAYLOAD_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
16#include "pxr/usd/sdf/path.h"
17#include "pxr/base/tf/hash.h"
18
19#include <iosfwd>
20#include <string>
21#include <vector>
22
23PXR_NAMESPACE_OPEN_SCOPE
24
25class SdfPayload;
26
27typedef std::vector<SdfPayload> SdfPayloadVector;
28
42public:
47 SDF_API
49 const std::string &assetPath = std::string(),
50 const SdfPath &primPath = SdfPath(),
51 const SdfLayerOffset &layerOffset = SdfLayerOffset());
52
54 const std::string &GetAssetPath() const {
55 return _assetPath;
56 }
57
62 void SetAssetPath(const std::string &assetPath) {
63 // Go through SdfAssetPath() to raise an error if \p assetPath contains
64 // illegal characters (i.e. control characters).
65 _assetPath = SdfAssetPath(assetPath).GetAssetPath();
66 }
67
69 const SdfPath &GetPrimPath() const {
70 return _primPath;
71 }
72
74 void SetPrimPath(const SdfPath &primPath) {
75 _primPath = primPath;
76 }
77
80 return _layerOffset;
81 }
82
84 void SetLayerOffset(const SdfLayerOffset &layerOffset) {
85 _layerOffset = layerOffset;
86 }
87
89 SDF_API bool operator==(const SdfPayload &rhs) const;
90
92 bool operator!=(const SdfPayload& rhs) const {
93 return !(*this == rhs);
94 }
95
98 SDF_API bool operator<(const SdfPayload &rhs) const;
99
101 bool operator>(const SdfPayload& rhs) const {
102 return rhs < *this;
103 }
104
106 bool operator<=(const SdfPayload& rhs) const {
107 return !(rhs < *this);
108 }
109
111 bool operator>=(const SdfPayload& rhs) const {
112 return !(*this < rhs);
113 }
114
115private:
116 friend inline size_t hash_value(const SdfPayload &p) {
117 return TfHash::Combine(
118 p._assetPath,
119 p._primPath,
120 p._layerOffset
121 );
122 }
123
124 // The asset path to the external layer.
125 std::string _assetPath;
126
127 // The root prim path to the referenced prim in the external layer.
128 SdfPath _primPath;
129
130 // The layer offset to transform time.
131 SdfLayerOffset _layerOffset;
132};
133
135SDF_API
136std::ostream & operator<<(std::ostream &out, const SdfPayload &payload);
137
138PXR_NAMESPACE_CLOSE_SCOPE
139
140#endif
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
const std::string & GetAssetPath() const &
Return the asset path.
Definition: assetPath.h:113
Represents a time offset and scale between layers.
Definition: layerOffset.h:44
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Represents a payload and all its meta data.
Definition: payload.h:41
SDF_API SdfPayload(const std::string &assetPath=std::string(), const SdfPath &primPath=SdfPath(), const SdfLayerOffset &layerOffset=SdfLayerOffset())
Create a payload.
const SdfLayerOffset & GetLayerOffset() const
Returns the layer offset associated with the payload.
Definition: payload.h:79
bool operator!=(const SdfPayload &rhs) const
Definition: payload.h:92
void SetPrimPath(const SdfPath &primPath)
Sets a new prim path for the prim that the payload uses.
Definition: payload.h:74
void SetLayerOffset(const SdfLayerOffset &layerOffset)
Sets a new layer offset.
Definition: payload.h:84
SDF_API bool operator<(const SdfPayload &rhs) const
Returns whether this payload is less than rhs.
void SetAssetPath(const std::string &assetPath)
Sets a new asset path for the layer the payload uses.
Definition: payload.h:62
const std::string & GetAssetPath() const
Returns the asset path of the layer that the payload uses.
Definition: payload.h:54
bool operator<=(const SdfPayload &rhs) const
Definition: payload.h:106
bool operator>=(const SdfPayload &rhs) const
Definition: payload.h:111
const SdfPath & GetPrimPath() const
Returns the scene path of the prim for the payload.
Definition: payload.h:69
bool operator>(const SdfPayload &rhs) const
Definition: payload.h:101
SDF_API bool operator==(const SdfPayload &rhs) const
Returns whether this payload equals rhs.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:475
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].