24 #ifndef PXR_USD_SDF_LIST_EDITOR_PROXY_H
25 #define PXR_USD_SDF_LIST_EDITOR_PROXY_H
55 template <
class _TypePolicy>
65 typedef std::function<std::optional<value_type>
69 typedef std::function<std::optional<value_type>
81 : _listEditor(listEditor)
92 return _listEditor->IsExpired();
99 return _Validate() ? _listEditor->IsExplicit() :
true;
106 return _Validate() ? _listEditor->IsOrderedOnly() :
false;
114 return _Validate() ? _listEditor->HasKeys() :
true;
147 return _Validate() && other._Validate() ?
148 _listEditor->CopyEdits(*other._listEditor) :
false;
158 return _Validate() ? _listEditor->ClearEdits() :
false;
168 return _Validate() ? _listEditor->ClearEditsAndMakeExplicit() :
false;
186 bool onlyAddOrExplicit =
false)
const
192 if (i !=
size_t(-1)) {
197 if (i !=
size_t(-1)) {
202 if (i !=
size_t(-1)) {
207 if (i !=
size_t(-1)) {
211 if (!onlyAddOrExplicit) {
213 if (i !=
size_t(-1)) {
218 if (i !=
size_t(-1)) {
313 _listEditor->ApplyEditsToList(&result);
321 if (!_listEditor->IsOrderedOnly()) {
322 if (_listEditor->IsExplicit()) {
336 if (!_listEditor->IsOrderedOnly()) {
337 if (_listEditor->IsExplicit()) {
351 if (!_listEditor->IsOrderedOnly()) {
352 if (_listEditor->IsExplicit()) {
366 if (_listEditor->IsExplicit()) {
369 else if (!_listEditor->IsOrderedOnly()) {
381 if (!_listEditor->IsOrderedOnly()) {
382 if (_listEditor->IsExplicit()) {
397 explicit operator bool()
const
399 return _listEditor && _listEditor->IsValid();
416 bool _Validate()
const
432 size_t index = proxy.Find(value);
433 if (index ==
size_t(-1)) {
434 proxy.push_back(value);
441 size_t index = proxy.Find(value);
442 if (index ==
size_t(-1)) {
443 proxy.push_back(value);
445 else if (value != static_cast<value_type>(proxy[index])) {
453 size_t index = proxy.Find(value);
455 if (index !=
size_t(-1)) {
458 proxy.insert(proxy.begin(),
value);
465 size_t index = proxy.Find(value);
466 if (proxy.empty() || (index != proxy.size()-1)) {
467 if (index !=
size_t(-1)) {
470 proxy.push_back(value);
475 std::shared_ptr<Sdf_ListEditor<TypePolicy> > _listEditor;
489 #endif // PXR_USD_SDF_LIST_EDITOR_PROXY_H
bool IsOrderedOnly() const
std::vector< value_type > value_vector_type
ListProxy GetPrependedItems() const
Returns the items prepended by this list editor.
ListProxy GetAppendedItems() const
Returns the items appended by this list editor.
GLsizei const GLfloat * value
std::function< std::optional< value_type >const value_type &)> ModifyCallback
ListProxy GetExplicitItems() const
Returns the explicitly set items.
void ApplyEditsToList(value_vector_type *vec, CB callback) const
void ModifyItemEdits(CB callback)
bool ContainsItemEdit(const value_type &item, bool onlyAddOrExplicit=false) const
void Prepend(const value_type &value)
void Add(const value_type &value)
**But if you need a result
bool ClearEditsAndMakeExplicit()
void Erase(const value_type &value)
ListProxy GetOrderedItems() const
Returns the items reordered by this list editor.
SdfListEditorProxy(const std::shared_ptr< Sdf_ListEditor< TypePolicy > > &listEditor)
Creates a new proxy object backed by the supplied list editor.
void RemoveItemEdits(const value_type &item)
friend class Sdf_ListEditorProxyAccess
ListProxy GetDeletedItems() const
Returns the items deleted by this list editor.
void ApplyEditsToList(value_vector_type *vec) const
Apply the edits to vec.
void Replace(const value_type &oldValue, const value_type &newValue)
value_vector_type GetAppliedItems() const
SdfListProxy< TypePolicy > ListProxy
std::function< std::optional< value_type >SdfListOpType, const value_type &)> ApplyCallback
bool IsExpired() const
Returns true if the list editor is expired.
TypePolicy::value_type value_type
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
void Append(const value_type &value)
ListProxy GetAddedItems() const
Returns the items added by this list editor.
#define PXR_NAMESPACE_CLOSE_SCOPE
void Remove(const value_type &value)
value_vector_type GetAddedOrExplicitItems() const
Deprecated. Please use GetAppliedItems.
bool CopyItems(const This &other)
static Vt_DefaultValueHolder Invoke()
void ReplaceItemEdits(const value_type &oldItem, const value_type &newItem)
SdfListEditorProxy< TypePolicy > This
void Remove(const value_type &value)
size_t Find(const value_type &value) const