7 #ifndef PXR_USD_SDF_LIST_EDITOR_PROXY_H
8 #define PXR_USD_SDF_LIST_EDITOR_PROXY_H
38 template <
class _TypePolicy>
48 typedef std::function<std::optional<value_type>
52 typedef std::function<std::optional<value_type>
64 : _listEditor(listEditor)
75 return _listEditor->IsExpired();
82 return _Validate() ? _listEditor->IsExplicit() :
true;
89 return _Validate() ? _listEditor->IsOrderedOnly() :
false;
97 return _Validate() ? _listEditor->HasKeys() :
true;
130 return _Validate() && other._Validate() ?
131 _listEditor->CopyEdits(*other._listEditor) :
false;
141 return _Validate() ? _listEditor->ClearEdits() :
false;
151 return _Validate() ? _listEditor->ClearEditsAndMakeExplicit() :
false;
169 bool onlyAddOrExplicit =
false)
const
175 if (i !=
size_t(-1)) {
180 if (i !=
size_t(-1)) {
185 if (i !=
size_t(-1)) {
190 if (i !=
size_t(-1)) {
194 if (!onlyAddOrExplicit) {
196 if (i !=
size_t(-1)) {
201 if (i !=
size_t(-1)) {
296 _listEditor->ApplyEditsToList(&result);
304 if (!_listEditor->IsOrderedOnly()) {
305 if (_listEditor->IsExplicit()) {
319 if (!_listEditor->IsOrderedOnly()) {
320 if (_listEditor->IsExplicit()) {
334 if (!_listEditor->IsOrderedOnly()) {
335 if (_listEditor->IsExplicit()) {
349 if (_listEditor->IsExplicit()) {
352 else if (!_listEditor->IsOrderedOnly()) {
364 if (!_listEditor->IsOrderedOnly()) {
365 if (_listEditor->IsExplicit()) {
382 return _listEditor && _listEditor->IsValid();
399 bool _Validate()
const
415 size_t index = proxy.Find(value);
416 if (index ==
size_t(-1)) {
417 proxy.push_back(value);
424 size_t index = proxy.Find(value);
425 if (index ==
size_t(-1)) {
426 proxy.push_back(value);
428 else if (value != static_cast<value_type>(proxy[index])) {
436 size_t index = proxy.Find(value);
438 if (index !=
size_t(-1)) {
441 proxy.insert(proxy.begin(),
value);
448 size_t index = proxy.Find(value);
449 if (proxy.empty() || (index != proxy.size()-1)) {
450 if (index !=
size_t(-1)) {
453 proxy.push_back(value);
458 std::shared_ptr<Sdf_ListEditor<TypePolicy> > _listEditor;
472 #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