All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 SDF_CHILDRENUTILS_H
25 #define SDF_CHILDRENUTILS_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 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
42 template<class ChildPolicy>
43 class Sdf_ChildrenUtils
44 {
45 public:
48  typedef typename ChildPolicy::KeyType KeyType;
49 
52  typedef typename ChildPolicy::FieldType FieldType;
53 
57  SDF_API
58  static bool CreateSpec(
59  const SdfLayerHandle &layer,
60  const SdfPath &childPath,
61  SdfSpecType specType,
62  bool inert=true);
63 
66 
68  SDF_API
69  static bool IsValidName(const FieldType &newName);
70 
72  SDF_API
73  static bool IsValidName(const std::string &newName);
74 
76  static SdfAllowed CanRename(
77  const SdfSpec &spec,
78  const FieldType &newName);
79 
83  SDF_API
84  static bool Rename(
85  const SdfSpec &spec,
86  const FieldType &newName);
87 
89 
92 
96  SDF_API
97  static bool SetChildren(
98  const SdfLayerHandle &layer,
99  const SdfPath &path,
100  const std::vector<typename ChildPolicy::ValueType> &values);
101 
103  SDF_API
104  static bool InsertChild(
105  const SdfLayerHandle &layer,
106  const SdfPath &path,
107  const typename ChildPolicy::ValueType& value,
108  int index);
109 
111  SDF_API
112  static bool RemoveChild(
113  const SdfLayerHandle &layer,
114  const SdfPath &path,
115  const typename ChildPolicy::KeyType& key);
116 
120 
121 
124  SDF_API
125  static bool MoveChildForBatchNamespaceEdit(
126  const SdfLayerHandle &layer,
127  const SdfPath &path,
128  const typename ChildPolicy::ValueType& value,
129  const typename ChildPolicy::FieldType& newName,
130  int index);
131 
133  SDF_API
134  static bool RemoveChildForBatchNamespaceEdit(
135  const SdfLayerHandle &layer,
136  const SdfPath &path,
137  const typename ChildPolicy::KeyType& key)
138  {
139  return RemoveChild(layer, path, key);
140  }
141 
145  SDF_API
146  static bool CanMoveChildForBatchNamespaceEdit(
147  const SdfLayerHandle &layer,
148  const SdfPath &path,
149  const typename ChildPolicy::ValueType& value,
150  const typename ChildPolicy::FieldType& newName,
151  int index,
152  std::string* whyNot);
153 
156  SDF_API
157  static bool CanRemoveChildForBatchNamespaceEdit(
158  const SdfLayerHandle &layer,
159  const SdfPath &path,
160  const typename ChildPolicy::FieldType& key,
161  std::string* whyNot);
162 
164 };
165 
166 PXR_NAMESPACE_CLOSE_SCOPE
167 
168 #endif // SDF_CHILDRENUTILS_H
Base class for all Sdf spec classes.
Definition: spec.h:51
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:91
Indicates if an operation is allowed and, if not, why not.
Definition: allowed.h:47
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287