24 #ifndef PXR_USD_SDF_LIST_PROXY_H
25 #define PXR_USD_SDF_LIST_PROXY_H
41 #include <type_traits>
53 template <
class _TypePolicy>
66 _owner(owner), _index(index)
82 return _owner->_Get(_index);
88 return _owner->_Get(_index) ==
x;
96 return _owner->_Get(_index) <
x;
121 result_type operator()(
This* owner,
size_t index)
const {
129 result_type operator()(
const This* owner,
size_t index)
const {
130 return owner->_Get(index);
136 template <
class Owner,
class GetItem>
140 std::add_pointer_t<typename GetItem::result_type> operator->() {
141 return std::addressof(_result);
144 friend class _Iterator;
147 std::add_lvalue_reference_t<
148 typename GetItem::result_type>
150 typename GetItem::result_type _result;
153 using This = _Iterator<Owner, GetItem>;
154 using iterator_category = std::random_access_iterator_tag;
157 typename GetItem::result_type
160 using reference =
typename GetItem::result_type;
162 using difference_type = std::ptrdiff_t;
165 "reference is an lvalue_reference and usage of "
166 "this class unnecessarily instantiates a _PtrProxy.");
168 _Iterator() =
default;
170 _Iterator(Owner owner,
size_t index) : _owner(owner), _index(index)
178 This advanced(*
this);
179 advanced.advance(index);
180 return advanced.dereference();
184 return -distance_to(other);
197 This operator++(
int) {
203 This operator--(
int) {
211 result.advance(increment);
217 result.advance(-decrement);
236 return !
equal(other);
241 return _index < other._index;
246 return _index <= other._index;
251 return _index > other._index;
256 return _index >= other._index;
262 return _getItem(_owner, _index);
266 if (_owner != other._owner) {
268 "different proxies!");
271 return _index == other._index;
282 void advance(difference_type
n) {
286 difference_type distance_to(
const This& other)
const {
287 return other._index - _index;
292 Owner _owner =
nullptr;
326 return iterator(_GetThis(), _GetSize());
359 return _Validate() ? _GetSize() : 0;
384 return reference(_GetThis(), _GetSize() - 1);
394 return _Get(_GetSize() - 1);
415 template <
class InputIterator>
440 size_t s = _GetSize();
458 _Edit(0, _GetSize(), static_cast<value_vector_type>(other));
464 _Edit(0, _GetSize(), other);
484 return !(*
this ==
y);
489 bool operator<(const SdfListProxy<T2>&
y)
const {
495 bool operator<=(const SdfListProxy<T2>&
y)
const {
502 return !(*
this <=
y);
523 return !(*
this ==
y);
573 explicit operator bool()
const
575 return _listEditor && _listEditor->IsValid() && _IsRelevant();
583 return _listEditor ? _listEditor->GetLayer() : SdfLayerHandle();
589 return _listEditor ? _listEditor->GetPath() :
SdfPath();
595 return _listEditor && _listEditor->IsExpired();
600 return (_Validate() ? _listEditor->Count(_op, value) : 0);
605 return (_Validate() ? _listEditor->Find(_op, value) : size_t(-1));
611 index =
static_cast<int>(_GetSize());
618 size_t index =
Find(value);
619 if (index !=
size_t(-1)) {
631 size_t index =
Find(oldValue);
632 if (index !=
size_t(-1)) {
650 if (_Validate() && list._Validate()) {
651 _listEditor->ApplyList(_op, *list._listEditor);
659 _listEditor->ApplyEditsToList(vec);
677 _listEditor->ModifyItemEdits(std::forward<CB>(callback));
695 bool _Validate()
const
710 return _Validate() ?
this : NULL;
713 const This* _GetThis()
const
715 return _Validate() ?
this : NULL;
718 bool _IsRelevant()
const
720 if (_listEditor->IsExplicit()) {
723 else if (_listEditor->IsOrderedOnly()) {
731 size_t _GetSize()
const
733 return _listEditor ? _listEditor->GetSize(_op) : 0;
738 return _Validate() ? _listEditor->Get(_op, n) :
value_type();
746 if (n == 0 && elems.empty()) {
747 SdfAllowed canEdit = _listEditor->PermissionToEdit(_op);
756 _listEditor->ReplaceEdits(_op, index, n, elems);
764 std::shared_ptr<Sdf_ListEditor<TypePolicy> > _listEditor;
771 template <
typename T>
778 #endif // PXR_USD_SDF_LIST_PROXY_H
reverse_iterator rend()
Return a reverse iterator past the start item of the sequence.
void resize(size_t n, const value_type &t=value_type())
SdfLayerHandle GetLayer() const
Returns the layer that this list editor belongs to.
bool operator==(const value_vector_type &y) const
Equality comparison.
This & operator=(const value_vector_type &other)
Replace all elements in this sequence with the given vector.
size_t size() const
Return the size of the sequence.
_Iterator< This *, _GetHelper > iterator
GLsizei const GLfloat * value
std::vector< value_type > value_vector_type
Tf_ProxyReferenceReverseIterator< const_iterator > const_reverse_iterator
IMATH_HOSTDEVICE constexpr Plane3< T > operator-(const Plane3< T > &plane) IMATH_NOEXCEPT
Reflect the pla.
_Iterator< const This *, _ConstGetHelper > const_iterator
This & operator=(const std::vector< Y > &v)
Replace all elements in this sequence with the given vector.
bool operator!=(const value_vector_type &y) const
Inequality comparison.
value_type front() const
Return a copy of the item at the front of the sequence.
SdfListProxy(SdfListOpType op)
bool empty() const
Return true if size() == 0.
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
value_type operator[](size_t n) const
Return a copy of the item at index n.
void ApplyList(const SdfListProxy &list)
Applies the edits in the given list to this one.
**But if you need a result
bool operator!=(const SdfListProxy< T2 > &y) const
Inequality comparison.
void erase(iterator f, iterator l)
Erase all the elements in the range [f, l).
void pop_back()
Remove the last element from this sequence.
friend bool operator==(const value_vector_type &x, const SdfListProxy &y)
Equality comparision.
friend class _ConstGetHelper
This & operator=(const SdfListProxy< T2 > &other)
SdfPath GetPath() const
Returns the path to this list editor's value.
reference operator[](size_t n)
Return a reference to the item at index n.
void push_back(const value_type &elem)
Append elem to this sequence.
#define TF_DEV_AXIOM(cond)
SDF_API const std::string & GetWhyNot() const
bool operator<(const SdfListProxy< T2 > &y) const
Less-than comparison.
OIIO_FORCEINLINE const vint4 & operator+=(vint4 &a, const vint4 &b)
const_reverse_iterator rend() const
iterator insert(iterator pos, const value_type &x)
Insert x into this sequence at position pos.
const_reverse_iterator rbegin() const
Return a const reverse iterator to the last item of the sequence.
void Insert(int index, const value_type &value)
typename std::remove_reference< T >::type remove_reference_t
reference front()
Return a reference to the item at the front of the sequence.
value_type back() const
Return a copy of the item at the back of the sequence.
void Replace(const value_type &oldValue, const value_type &newValue)
IMATH_HOSTDEVICE constexpr Color4< T > operator*(S a, const Color4< T > &v) IMATH_NOEXCEPT
Reverse multiplication: S * Color4.
bool operator>(const value_vector_type &y) const
Greater-than comparison.
friend bool operator>=(const value_vector_type &x, const SdfListProxy &y)
Greater-than or equal to comparison.
SdfListProxy(const std::shared_ptr< Sdf_ListEditor< TypePolicy > > &editor, SdfListOpType op)
bool operator>=(const value_vector_type &y) const
Greater-than or equal to comparison.
IMATH_HOSTDEVICE constexpr Quat< T > operator+(const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
Quaterion addition.
void ApplyEditsToList(value_vector_type *vec)
Apply the edits in this list to the given vec.
iterator begin()
Return an iterator to the start of the sequence.
size_t Count(const value_type &value) const
const_iterator begin() const
Return a const iterator to the start of the sequence.
friend bool operator<=(const value_vector_type &x, const SdfListProxy &y)
Less-than or equal to comparison.
friend bool operator>(const value_vector_type &x, const SdfListProxy &y)
Greater-than comparison.
Tf_ProxyReferenceReverseIterator< iterator > reverse_iterator
friend bool operator<(const value_vector_type &x, const SdfListProxy &y)
Less-than comparison.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
bool operator<(const value_vector_type &y) const
Less-than comparison.
void ModifyItemEdits(CB callback)
reverse_iterator rbegin()
Return a reverse iterator to the last item of the sequence.
reference back()
Return a reference to the item at the back of the sequence.
bool operator<=(const value_vector_type &y) const
Less-than or equal to comparison.
SdfListProxy< TypePolicy > This
#define PXR_NAMESPACE_CLOSE_SCOPE
friend bool operator!=(const value_vector_type &x, const SdfListProxy &y)
Inequality comparision.
OIIO_FORCEINLINE const vint4 & operator-=(vint4 &a, const vint4 &b)
TypePolicy::value_type value_type
bool operator>=(const SdfListProxy< T2 > &y) const
Greater-than-or-equal comparison.
const_iterator end() const
Return a const iterator to the end of the sequence.
void erase(iterator pos)
Erase the element at pos.
void clear()
Clear the contents of the sequence.
bool IsExpired() const
Returns true if the list editor is expired.
iterator end()
Return an iterator to the end of the sequence.
bool operator<=(const SdfListProxy< T2 > &y) const
Less-than-or-equal comparison.
bool operator==(const SdfListProxy< T2 > &y) const
Equality comparison.
void insert(iterator pos, InputIterator f, InputIterator l)
void Remove(const value_type &value)
size_t Find(const value_type &value) const
bool operator>(const SdfListProxy< T2 > &y) const
Greater-than comparison.