All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
relationship.h
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_RELATIONSHIP_H
8#define PXR_USD_USD_RELATIONSHIP_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/property.h"
14
15#include "pxr/usd/sdf/path.h"
16#include "pxr/base/vt/value.h"
17
18#include <string>
19#include <vector>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
23
24class UsdRelationship;
25
27typedef std::vector<UsdRelationship> UsdRelationshipVector;
28
112public:
115
118
119 // XXX Should the mutation API be changed to take UsdObject
120 // pointers so that we can enforce (as does Mf) that you can only
121 // target extant scenegraph objects? (Note the API would still need to
122 // validate those objects since it is easy to create a UsdAttribute
123 // or UsdRelationship object not backed by scene description).
124
135 USD_API
136 bool AddTarget(const SdfPath& target,
138
144 USD_API
145 bool RemoveTarget(const SdfPath& target) const;
146
156 USD_API
157 bool SetTargets(const SdfPathVector& targets) const;
158
165 USD_API
166 bool ClearTargets(bool removeSpec) const;
167
181 USD_API
182 bool GetTargets(SdfPathVector* targets) const;
183
215 USD_API
216 bool GetForwardedTargets(SdfPathVector* targets) const;
217
221 USD_API
222 bool HasAuthoredTargets() const;
223
225
226private:
227 friend class UsdObject;
228 friend class UsdPrim;
229 friend class Usd_PrimData;
230 template <class A0, class A1>
231 friend struct UsdPrim_TargetFinder;
232
233 UsdRelationship(const Usd_PrimDataHandle &prim,
234 const SdfPath &proxyPrimPath,
235 const TfToken& relName)
236 : UsdProperty(UsdTypeRelationship, prim, proxyPrimPath, relName) {}
237
239 const Usd_PrimDataHandle &prim,
240 const SdfPath &proxyPrimPath,
241 const TfToken &propName)
242 : UsdProperty(objType, prim, proxyPrimPath, propName) {}
243
244 SdfRelationshipSpecHandle _CreateSpec(bool fallbackCustom=true) const;
245 bool _Create(bool fallbackCustom) const;
246
247 bool _GetForwardedTargets(SdfPathVector* targets,
248 bool includeForwardingRels) const;
249
250 bool _GetForwardedTargetsImpl(SdfPathSet* visited,
251 SdfPathSet* uniqueTargets,
252 SdfPathVector* targets,
253 bool *foundAnyErrors,
254 bool includeForwardingRels) const;
255
256 SdfPath _GetTargetForAuthoring(const SdfPath &targetPath,
257 std::string* whyNot = 0) const;
258};
259
260
261PXR_NAMESPACE_CLOSE_SCOPE
262
263#endif //PXR_USD_USD_RELATIONSHIP_H
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:115
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:38
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:111
USD_API bool AddTarget(const SdfPath &target, UsdListPosition position=UsdListPositionBackOfPrependList) const
Adds target to the list of targets, in the position specified by position.
USD_API bool RemoveTarget(const SdfPath &target) const
Removes target from the list of targets.
USD_API bool SetTargets(const SdfPathVector &targets) const
Make the authoring layer's opinion of the targets list explicit, and set exactly to targets.
USD_API bool GetForwardedTargets(SdfPathVector *targets) const
Compose this relationship's ultimate targets, taking into account "relationship forwarding",...
USD_API bool ClearTargets(bool removeSpec) const
Remove all opinions about the target list from the current edit target.
USD_API bool GetTargets(SdfPathVector *targets) const
Compose this relationship's targets and fill targets with the result.
UsdRelationship()
Construct an invalid relationship.
Definition: relationship.h:114
USD_API bool HasAuthoredTargets() const
Returns true if any target path opinions have been authored.
UsdListPosition
Specifies a position to add items to lists.
Definition: common.h:71
@ UsdListPositionBackOfPrependList
The position at the back of the prepend list.
Definition: common.h:81
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:35