24 #ifndef PXR_USD_SDF_LIST_EDITOR_H
25 #define PXR_USD_SDF_LIST_EDITOR_H
49 template <
class TypePolicy>
65 return _owner ? _owner->GetLayer() : SdfLayerHandle();
70 return _owner ? _owner->GetPath() :
SdfPath();
109 if (!_owner->PermissionToEdit()) {
120 typedef std::function<
133 typedef std::function<
172 return std::count(ops.begin(), ops.end(), _typePolicy.Canonicalize(val));
180 typename value_vector_type::const_iterator findIt =
181 std::find(vec.begin(), vec.end(), _typePolicy.Canonicalize(val));
182 if (findIt != vec.end()) {
204 const TypePolicy& typePolicy)
207 _typePolicy(typePolicy)
245 typename value_vector_type::const_iterator
246 oldValuesTail = oldValues.begin(),
247 newValuesTail = newValues.begin();
248 auto oldEnd = oldValues.end(), newEnd = newValues.end();
249 while (oldValuesTail != oldEnd && newValuesTail != newEnd &&
250 *oldValuesTail == *newValuesTail) {
251 ++oldValuesTail, ++newValuesTail;
254 for (
auto i = newValuesTail; i != newEnd; ++i) {
256 for (
auto j = newValues.begin();
j != i; ++
j) {
259 "field '%s' on <%s>",
270 _owner->GetSchema().GetFieldDefinition(_field);
276 for (
auto i = newValuesTail; i != newEnd; ++i) {
297 SdfSpecHandle _owner;
299 TypePolicy _typePolicy;
303 template <
class TypePolicy>
305 operator<<(std::ostream& s, const Sdf_ListEditor<TypePolicy>&
x)
311 static void _Write(std::ostream&
s,
const value_vector_type&
v)
314 for (
size_t i = 0,
n = v.size(); i <
n; ++i) {
327 else if (
x.IsExplicit()) {
333 if (!
x.IsOrderedOnly()) {
336 s <<
"'prepended': ";
340 s <<
", 'deleted': ";
352 #endif // PXR_USD_SDF_LIST_EDITOR_H
virtual const value_vector_type & _GetOperations(SdfListOpType op) const =0
SDF_API const char * GetText() const
size_t Find(SdfListOpType op, const value_type &val) const
virtual bool IsOrderedOnly() const =0
virtual void _OnEdit(SdfListOpType op, const value_vector_type &oldValues, const value_vector_type &newValues) const
virtual bool ClearEdits()=0
TypePolicy::value_type value_type
const TypePolicy & _GetTypePolicy() const
value_type Get(SdfListOpType op, size_t i) const
Returns the i'th value in the specified list of operations.
virtual SdfAllowed PermissionToEdit(SdfListOpType op) const
const SdfSpecHandle & _GetOwner() const
virtual bool ReplaceEdits(SdfListOpType op, size_t index, size_t n, const value_vector_type &elems)=0
virtual bool IsExplicit() const =0
Sdf_ListEditor(const SdfSpecHandle &owner, const TfToken &field, const TypePolicy &typePolicy)
std::string TfStringify(const T &v)
SdfLayerHandle GetLayer() const
virtual void ModifyItemEdits(const ModifyCallback &cb)=0
virtual void ApplyList(SdfListOpType op, const Sdf_ListEditor &rhs)=0
Applies a rhs opinions about a given operation list to this one.
const TfToken & _GetField() const
std::vector< value_type > value_vector_type
char const * GetText() const
std::function< std::optional< value_type >const value_type &) > ModifyCallback
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
size_t Count(SdfListOpType op, const value_type &val) const
std::function< std::optional< value_type >SdfListOpType, const value_type &) > ApplyCallback
SdfAllowed IsValidListValue(const T &value) const
virtual bool ClearEditsAndMakeExplicit()=0
#define PXR_NAMESPACE_CLOSE_SCOPE
virtual ~Sdf_ListEditor()=default
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
SIM_API const UT_StringHolder distance
virtual void ApplyEditsToList(value_vector_type *vec, const ApplyCallback &cb=ApplyCallback())=0
size_t GetSize(SdfListOpType op) const
Returns the number of elements in the specified list of operations.
value_vector_type GetVector(SdfListOpType op) const
Returns the specified list of operations.
virtual bool _ValidateEdit(SdfListOpType op, const value_vector_type &oldValues, const value_vector_type &newValues) const
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
virtual bool CopyEdits(const Sdf_ListEditor &rhs)=0