24 #ifndef PXR_USD_SDF_LIST_EDITOR_H
25 #define PXR_USD_SDF_LIST_EDITOR_H
36 #include <hboost/optional.hpp>
50 template <
class TypePolicy>
66 return _owner ? _owner->GetLayer() : SdfLayerHandle();
71 return _owner ? _owner->GetPath() :
SdfPath();
110 if (!_owner->PermissionToEdit()) {
121 typedef std::function<
122 hboost::optional<value_type>(
const value_type&)
134 typedef std::function<
173 return std::count(ops.begin(), ops.end(), _typePolicy.Canonicalize(val));
181 typename value_vector_type::const_iterator findIt =
182 std::find(vec.begin(), vec.end(), _typePolicy.Canonicalize(val));
183 if (findIt != vec.end()) {
205 const TypePolicy& typePolicy)
208 _typePolicy(typePolicy)
246 typename value_vector_type::const_iterator
247 oldValuesTail = oldValues.begin(),
248 newValuesTail = newValues.begin();
249 auto oldEnd = oldValues.end(), newEnd = newValues.end();
250 while (oldValuesTail != oldEnd && newValuesTail != newEnd &&
251 *oldValuesTail == *newValuesTail) {
252 ++oldValuesTail, ++newValuesTail;
255 for (
auto i = newValuesTail; i != newEnd; ++i) {
257 for (
auto j = newValues.begin();
j != i; ++
j) {
260 "field '%s' on <%s>",
271 _owner->GetSchema().GetFieldDefinition(_field);
277 for (
auto i = newValuesTail; i != newEnd; ++i) {
298 SdfSpecHandle _owner;
300 TypePolicy _typePolicy;
304 template <
class TypePolicy>
306 operator<<(std::ostream& s, const Sdf_ListEditor<TypePolicy>&
x)
312 static void _Write(std::ostream&
s,
const value_vector_type&
v)
315 for (
size_t i = 0,
n = v.size(); i <
n; ++i) {
328 else if (
x.IsExplicit()) {
334 if (!
x.IsOrderedOnly()) {
337 s <<
"'prepended': ";
341 s <<
", 'deleted': ";
353 #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)
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< hboost::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
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)
std::enable_if<!std::is_enum< T >::value, std::string >::type TfStringify(const T &v)
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.
std::function< hboost::optional< value_type >SdfListOpType, const value_type &) > ApplyCallback
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