Loading...
Searching...
No Matches
relationship.h
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 PXR_USD_USD_RELATIONSHIP_H
25#define PXR_USD_USD_RELATIONSHIP_H
26
27#include "pxr/pxr.h"
28#include "pxr/usd/usd/api.h"
29#include "pxr/usd/usd/common.h"
30#include "pxr/usd/usd/property.h"
31
32#include "pxr/usd/sdf/path.h"
33#include "pxr/base/vt/value.h"
34
35#include <string>
36#include <vector>
37
38PXR_NAMESPACE_OPEN_SCOPE
39
40
41class UsdRelationship;
42
44typedef std::vector<UsdRelationship> UsdRelationshipVector;
45
129public:
132
135
136 // XXX Should the mutation API be changed to take UsdObject
137 // pointers so that we can enforce (as does Mf) that you can only
138 // target extant scenegraph objects? (Note the API would still need to
139 // validate those objects since it is easy to create a UsdAttribute
140 // or UsdRelationship object not backed by scene description).
141
152 USD_API
153 bool AddTarget(const SdfPath& target,
155
161 USD_API
162 bool RemoveTarget(const SdfPath& target) const;
163
173 USD_API
174 bool SetTargets(const SdfPathVector& targets) const;
175
182 USD_API
183 bool ClearTargets(bool removeSpec) const;
184
198 USD_API
199 bool GetTargets(SdfPathVector* targets) const;
200
232 USD_API
233 bool GetForwardedTargets(SdfPathVector* targets) const;
234
238 USD_API
239 bool HasAuthoredTargets() const;
240
242
243private:
244 friend class UsdObject;
245 friend class UsdPrim;
246 friend class Usd_PrimData;
247 template <class A0, class A1>
248 friend struct UsdPrim_TargetFinder;
249
250 UsdRelationship(const Usd_PrimDataHandle &prim,
251 const SdfPath &proxyPrimPath,
252 const TfToken& relName)
253 : UsdProperty(UsdTypeRelationship, prim, proxyPrimPath, relName) {}
254
256 const Usd_PrimDataHandle &prim,
257 const SdfPath &proxyPrimPath,
258 const TfToken &propName)
259 : UsdProperty(objType, prim, proxyPrimPath, propName) {}
260
261 SdfRelationshipSpecHandle _CreateSpec(bool fallbackCustom=true) const;
262 bool _Create(bool fallbackCustom) const;
263
264 bool _GetForwardedTargets(SdfPathVector* targets,
265 bool includeForwardingRels) const;
266
267 bool _GetForwardedTargetsImpl(SdfPathSet* visited,
268 SdfPathSet* uniqueTargets,
269 SdfPathVector* targets,
270 bool *foundAnyErrors,
271 bool includeForwardingRels) const;
272
273 SdfPath _GetTargetForAuthoring(const SdfPath &targetPath,
274 std::string* whyNot = 0) const;
275};
276
277
278PXR_NAMESPACE_CLOSE_SCOPE
279
280#endif //PXR_USD_USD_RELATIONSHIP_H
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:132
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
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:131
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:88
@ UsdListPositionBackOfPrependList
The position at the back of the prepend list.
Definition: common.h:98
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:52