All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
payload.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 SDF_PAYLOAD_H
25 #define SDF_PAYLOAD_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 #include "pxr/usd/sdf/layerOffset.h"
32 #include "pxr/usd/sdf/path.h"
33 
34 #include <boost/functional/hash.hpp>
35 #include <boost/operators.hpp>
36 
37 #include <iosfwd>
38 #include <string>
39 #include <vector>
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
43 class SdfPayload;
44 
45 typedef std::vector<SdfPayload> SdfPayloadVector;
46 
59 class SdfPayload : boost::totally_ordered<SdfPayload> {
60 public:
63  SDF_API
64  SdfPayload(
65  const std::string &assetPath = std::string(),
66  const SdfPath &primPath = SdfPath(),
67  const SdfLayerOffset &layerOffset = SdfLayerOffset());
68 
70  const std::string &GetAssetPath() const {
71  return _assetPath;
72  }
73 
75  void SetAssetPath(const std::string &assetPath) {
76  _assetPath = assetPath;
77  }
78 
80  const SdfPath &GetPrimPath() const {
81  return _primPath;
82  }
83 
85  void SetPrimPath(const SdfPath &primPath) {
86  _primPath = primPath;
87  }
88 
90  const SdfLayerOffset &GetLayerOffset() const {
91  return _layerOffset;
92  }
93 
95  void SetLayerOffset(const SdfLayerOffset &layerOffset) {
96  _layerOffset = layerOffset;
97  }
98 
100  SDF_API bool operator==(const SdfPayload &rhs) const;
101 
104  SDF_API bool operator<(const SdfPayload &rhs) const;
105 
106 private:
107  friend inline size_t hash_value(const SdfPayload &p) {
108  size_t h = 0;
109  boost::hash_combine(h, p._assetPath);
110  boost::hash_combine(h, p._primPath);
111  boost::hash_combine(h, p._layerOffset);
112  return h;
113  }
114 
115  // The asset path to the external layer.
116  std::string _assetPath;
117 
118  // The root prim path to the referenced prim in the external layer.
119  SdfPath _primPath;
120 
121  // The layer offset to transform time.
122  SdfLayerOffset _layerOffset;
123 };
124 
126 SDF_API
127 std::ostream & operator<<(std::ostream &out, const SdfPayload &payload);
128 
129 PXR_NAMESPACE_CLOSE_SCOPE
130 
131 #endif
const SdfPath & GetPrimPath() const
Returns the scene path of the prim for the payload.
Definition: payload.h:80
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:75
const std::string & GetAssetPath() const
Returns the asset path of the layer that the payload uses.
Definition: payload.h:70
void SetLayerOffset(const SdfLayerOffset &layerOffset)
Sets a new layer offset.
Definition: payload.h:95
Represents a payload and all its meta data.
Definition: payload.h:59
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
SDF_API SdfPayload(const std::string &assetPath=std::string(), const SdfPath &primPath=SdfPath(), const SdfLayerOffset &layerOffset=SdfLayerOffset())
Creates a payload.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
const SdfLayerOffset & GetLayerOffset() const
Returns the layer offset associated with the payload.
Definition: payload.h:90
SDF_API bool operator==(const SdfPayload &rhs) const
Returns whether this payload equals rhs.
Represents a time offset and scale between layers.
Definition: layerOffset.h:61
void SetPrimPath(const SdfPath &primPath)
Sets a new prim path for the prim that the payload uses.
Definition: payload.h:85