Loading...
Searching...
No Matches
childrenUtils.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 PXR_USD_SDF_CHILDREN_UTILS_H
25#define PXR_USD_SDF_CHILDREN_UTILS_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usd/sdf/api.h"
31#include "pxr/usd/sdf/allowed.h"
32#include "pxr/usd/sdf/types.h"
33
34PXR_NAMESPACE_OPEN_SCOPE
35
42template<class ChildPolicy>
43class Sdf_ChildrenUtils
44{
45public:
48 typedef typename ChildPolicy::KeyType KeyType;
49
52 typedef typename ChildPolicy::FieldType FieldType;
53
57 static bool CreateSpec(
58 const SdfLayerHandle &layer,
59 const SdfPath &childPath,
60 SdfSpecType specType,
61 bool inert=true) {
62 return CreateSpec(get_pointer(layer), childPath, specType, inert);
63 }
64
65 // This overload is intended primarily for internal use.
66 SDF_API
67 static bool CreateSpec(
68 SdfLayer *layer,
69 const SdfPath &childPath,
70 SdfSpecType specType,
71 bool inert=true);
72
75
77 SDF_API
78 static bool IsValidName(const FieldType &newName);
79
81 SDF_API
82 static bool IsValidName(const std::string &newName);
83
85 static SdfAllowed CanRename(
86 const SdfSpec &spec,
87 const FieldType &newName);
88
92 SDF_API
93 static bool Rename(
94 const SdfSpec &spec,
95 const FieldType &newName);
96
98
101
105 SDF_API
106 static bool SetChildren(
107 const SdfLayerHandle &layer,
108 const SdfPath &path,
109 const std::vector<typename ChildPolicy::ValueType> &values);
110
112 SDF_API
113 static bool InsertChild(
114 const SdfLayerHandle &layer,
115 const SdfPath &path,
116 const typename ChildPolicy::ValueType& value,
117 int index);
118
120 SDF_API
121 static bool RemoveChild(
122 const SdfLayerHandle &layer,
123 const SdfPath &path,
124 const typename ChildPolicy::KeyType& key);
125
129
130
133 SDF_API
134 static bool MoveChildForBatchNamespaceEdit(
135 const SdfLayerHandle &layer,
136 const SdfPath &path,
137 const typename ChildPolicy::ValueType& value,
138 const typename ChildPolicy::FieldType& newName,
139 int index);
140
142 SDF_API
143 static bool RemoveChildForBatchNamespaceEdit(
144 const SdfLayerHandle &layer,
145 const SdfPath &path,
146 const typename ChildPolicy::KeyType& key)
147 {
148 return RemoveChild(layer, path, key);
149 }
150
154 SDF_API
155 static bool CanMoveChildForBatchNamespaceEdit(
156 const SdfLayerHandle &layer,
157 const SdfPath &path,
158 const typename ChildPolicy::ValueType& value,
159 const typename ChildPolicy::FieldType& newName,
160 int index,
161 std::string* whyNot);
162
165 SDF_API
166 static bool CanRemoveChildForBatchNamespaceEdit(
167 const SdfLayerHandle &layer,
168 const SdfPath &path,
169 const typename ChildPolicy::FieldType& key,
170 std::string* whyNot);
171
173};
174
175PXR_NAMESPACE_CLOSE_SCOPE
176
177#endif // PXR_USD_SDF_CHILDREN_UTILS_H
Indicates if an operation is allowed and, if not, why not.
Definition: allowed.h:46
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:100
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
Base class for all Sdf spec classes.
Definition: spec.h:50
Basic Sdf data types.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:84