Loading...
Searching...
No Matches
childrenUtils.h
Go to the documentation of this file.
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_SDF_CHILDREN_UTILS_H
8#define PXR_USD_SDF_CHILDREN_UTILS_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
14#include "pxr/usd/sdf/allowed.h"
15#include "pxr/usd/sdf/types.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
25template<class ChildPolicy>
26class Sdf_ChildrenUtils
27{
28public:
31 typedef typename ChildPolicy::KeyType KeyType;
32
35 typedef typename ChildPolicy::FieldType FieldType;
36
40 static bool CreateSpec(
41 const SdfLayerHandle &layer,
42 const SdfPath &childPath,
43 SdfSpecType specType,
44 bool inert=true) {
45 return CreateSpec(get_pointer(layer), childPath, specType, inert);
46 }
47
48 // This overload is intended primarily for internal use.
49 SDF_API
50 static bool CreateSpec(
51 SdfLayer *layer,
52 const SdfPath &childPath,
53 SdfSpecType specType,
54 bool inert=true);
55
58
60 SDF_API
61 static bool IsValidName(const FieldType &newName);
62
64 SDF_API
65 static bool IsValidName(const std::string &newName);
66
68 static SdfAllowed CanRename(
69 const SdfSpec &spec,
70 const FieldType &newName);
71
75 SDF_API
76 static bool Rename(
77 const SdfSpec &spec,
78 const FieldType &newName);
79
81
84
88 SDF_API
89 static bool SetChildren(
90 const SdfLayerHandle &layer,
91 const SdfPath &path,
92 const std::vector<typename ChildPolicy::ValueType> &values);
93
95 SDF_API
96 static bool InsertChild(
97 const SdfLayerHandle &layer,
98 const SdfPath &path,
99 const typename ChildPolicy::ValueType& value,
100 int index);
101
103 SDF_API
104 static bool RemoveChild(
105 const SdfLayerHandle &layer,
106 const SdfPath &path,
107 const typename ChildPolicy::KeyType& key);
108
112
113
116 SDF_API
117 static bool MoveChildForBatchNamespaceEdit(
118 const SdfLayerHandle &layer,
119 const SdfPath &path,
120 const typename ChildPolicy::ValueType& value,
121 const typename ChildPolicy::FieldType& newName,
122 int index);
123
125 SDF_API
126 static bool RemoveChildForBatchNamespaceEdit(
127 const SdfLayerHandle &layer,
128 const SdfPath &path,
129 const typename ChildPolicy::KeyType& key)
130 {
131 return RemoveChild(layer, path, key);
132 }
133
137 SDF_API
138 static bool CanMoveChildForBatchNamespaceEdit(
139 const SdfLayerHandle &layer,
140 const SdfPath &path,
141 const typename ChildPolicy::ValueType& value,
142 const typename ChildPolicy::FieldType& newName,
143 int index,
144 std::string* whyNot);
145
148 SDF_API
149 static bool CanRemoveChildForBatchNamespaceEdit(
150 const SdfLayerHandle &layer,
151 const SdfPath &path,
152 const typename ChildPolicy::FieldType& key,
153 std::string* whyNot);
154
156};
157
158PXR_NAMESPACE_CLOSE_SCOPE
159
160#endif // PXR_USD_SDF_CHILDREN_UTILS_H
Indicates if an operation is allowed and, if not, why not.
Definition: allowed.h:29
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:84
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Base class for all Sdf spec classes.
Definition: spec.h:33
Basic Sdf data types.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:68