24 #ifndef PXR_USD_SDF_CHILDREN_VIEW_H
25 #define PXR_USD_SDF_CHILDREN_VIEW_H
72 template <
typename _Owner,
typename _InnerIterator,
typename _DummyPredicate>
78 class _FilterIterator {
80 using iterator_category = std::forward_iterator_tag;
84 using difference_type =
typename _InnerIterator::difference_type;
86 _FilterIterator() =
default;
87 _FilterIterator(
const _Owner* owner,
88 const _InnerIterator& underlyingIterator,
89 const _InnerIterator&
end) :
91 _underlyingIterator(underlyingIterator),
97 return *_underlyingIterator;
101 return _underlyingIterator.operator->();
104 _FilterIterator& operator++() {
106 ++_underlyingIterator;
111 _FilterIterator operator++(
int) {
113 _FilterIterator
result(*
this);
114 ++_underlyingIterator;
119 bool operator==(
const _FilterIterator& other)
const {
120 return _underlyingIterator == other._underlyingIterator;
123 bool operator!=(
const _FilterIterator& other)
const {
124 return _underlyingIterator != other._underlyingIterator;
127 const _InnerIterator&
GetBase()
const {
return _underlyingIterator; }
133 return !_owner->GetPredicate()(
134 _Owner::Adapter::Convert(x));
139 while (_underlyingIterator != _end &&
140 _ShouldFilter(*_underlyingIterator)) {
141 ++_underlyingIterator;
145 const _Owner* _owner =
nullptr;
146 _InnerIterator _underlyingIterator;
157 const _InnerIterator& i,
160 _InnerIterator
end(owner,size);
174 template <
typename _Owner,
typename _InnerIterator>
183 const _InnerIterator& i,
size_t size)
215 template <
typename _ChildPolicy,
216 typename _Predicate =
221 typename _ChildPolicy::ValueType> >
242 class _InnerIterator {
253 using iterator_category = std::random_access_iterator_tag;
259 _InnerIterator() =
default;
260 _InnerIterator(
const This* owner,
const size_t& pos) :
261 _owner(owner), _pos(pos) { }
266 _InnerIterator advanced(*
this);
267 advanced.advance(index);
268 return advanced.dereference();
272 return -distance_to(other);
275 _InnerIterator& operator++() {
280 _InnerIterator& operator--() {
285 _InnerIterator operator++(
int) {
286 _InnerIterator
result(*
this);
291 _InnerIterator operator--(
int) {
292 _InnerIterator
result(*
this);
298 _InnerIterator
result(*
this);
299 result.advance(increment);
304 _InnerIterator
result(*
this);
305 result.advance(-decrement);
319 bool operator==(
const _InnerIterator& other)
const {
323 bool operator!=(
const _InnerIterator& other)
const {
324 return !
equal(other);
327 bool operator<(
const _InnerIterator& other)
const {
329 return _pos < other._pos;
332 bool operator<=(
const _InnerIterator& other)
const {
334 return _pos <= other._pos;
337 bool operator>(
const _InnerIterator& other)
const {
339 return _pos > other._pos;
342 bool operator>=(
const _InnerIterator& other)
const {
344 return _pos >= other._pos;
351 return _owner->_Get(_pos);
354 bool equal(
const _InnerIterator& other)
const
356 return _pos == other._pos;
372 return other._pos-_pos;
376 const This* _owner =
nullptr;
394 _children(layer, path, childrenKey, keyPolicy)
402 _children(layer, path, childrenKey, keyPolicy),
403 _predicate(predicate)
408 _children(other._children),
409 _predicate(other._predicate)
413 template <
class OtherAdapter>
415 OtherAdapter> &other) :
416 _children(other._children),
417 _predicate(other._predicate)
427 _children= other._children;
428 _predicate = other._predicate;
434 _InnerIterator i(
this,0);
440 _InnerIterator i(
this,_GetSize());
485 _InnerIterator inner(
this, _children.
Find(x));
499 return (i !=
end() && *i == x) ? i :
end();
509 return _children.
FindKey(Adapter::Convert(x));
514 return std::vector<value_type>(
begin(),
end());
518 template <
typename V>
526 std::vector<key_type>
keys()
const {
527 std::vector<key_type>
result;
528 result.reserve(
size());
530 result.push_back(
key(i));
536 template <
typename V>
538 std::vector<key_type> k =
keys();
539 return V(k.begin(), k.end());
543 template <
typename Dict>
547 result.insert(std::make_pair(
key(i), *i));
554 return (_children.
Find(x) != _GetSize());
560 return has(
key(Adapter::Convert(x)));
572 if (index == _GetSize()) {
582 if (index == _GetSize()) {
597 return _children.
IsEqualTo(other._children);
604 return !_children.
IsEqualTo(other._children);
625 return Adapter::Convert(_children.
GetChild(index));
629 size_t _GetSize()
const {
641 template <
class _View,
class _Adapter>
646 typename _View::Predicate,
656 template <
typename C,
typename P,
typename A>
660 template <
typename C,
typename P,
typename A>
667 template <
typename C,
typename P,
typename A>
677 #endif // PXR_USD_SDF_CHILDREN_VIEW_H
SDF_API bool IsEqualTo(const This &other) const
Return true if this object and other are equivalent.
Dict items_as() const
Returns the elements as a dictionary.
SDF_API size_t GetSize() const
Return the number of children that this object contains.
Sdf_Children< ChildPolicy > ChildrenType
SdfChildrenView(const SdfLayerHandle &layer, const SdfPath &path, const TfToken &childrenKey, const KeyPolicy &keyPolicy=KeyPolicy())
value_type back() const
Returns the last element.
SdfChildrenView< typename _View::ChildPolicy, typename _View::Predicate, _Adapter > AdaptedView
static IteratorType Begin(Type const &c)
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
_FilterIterator const_iterator
static const const_iterator & GetIterator(const _Owner *, const _InnerIterator &i, size_t size)
static const _InnerIterator & GetBase(const const_iterator &i)
ptrdiff_t difference_type
GLsizei const GLchar *const * path
_Traits::const_iterator const_iterator
IMATH_HOSTDEVICE constexpr Plane3< T > operator-(const Plane3< T > &plane) IMATH_NOEXCEPT
Reflect the pla.
ChildrenType & GetChildren()
static IteratorType End(Type const &c)
Type::const_reverse_iterator IteratorType
V values_as() const
Returns the elements, in order.
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
_InnerIterator const_iterator
**But if you need a result
bool empty() const
Returns true if the vector is empty.
bool has(const value_type &x) const
const_iterator begin() const
Returns an const_iterator pointing to the beginning of the vector.
SDF_API KeyType FindKey(const ValueType &value) const
Type::const_iterator IteratorType
static IteratorType End(Type const &c)
OIIO_FORCEINLINE vbool4 operator>=(const vint4 &a, const vint4 &b)
GLenum GLuint GLint GLint layer
V keys_as() const
Returns the keys for all elements, in order.
ChildPolicy::KeyType key_type
std::vector< value_type > values() const
Returns the elements, in order.
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
SdfChildrenView< C, P, A > Type
size_type size() const
Returns the size of the vector.
OIIO_FORCEINLINE vbool4 operator>(const vint4 &a, const vint4 &b)
Tf_ProxyReferenceReverseIterator< const_iterator > const_reverse_iterator
#define TF_DEV_AXIOM(cond)
OIIO_FORCEINLINE vbool4 operator<=(const vint4 &a, const vint4 &b)
SdfChildrenView(const SdfChildrenView< ChildPolicy, Predicate, OtherAdapter > &other)
size_type count(const key_type &x) const
Returns the number of elements with key x in the container.
SDF_API ValueType GetChild(size_t index) const
Return the child at the specified index.
value_type front() const
Returns the first element.
const_iterator find(const value_type &x) const
Finds element x, if present in this view.
Adapter::PublicType value_type
SdfChildrenView & operator=(const SdfChildrenView &other)
OIIO_FORCEINLINE const vint4 & operator+=(vint4 &a, const vint4 &b)
static IteratorType Begin(Type const &c)
const_reverse_iterator rend() const
SdfChildrenView< _ChildPolicy, _Predicate, _Adapter > This
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
IMATH_HOSTDEVICE constexpr Color4< T > operator*(S a, const Color4< T > &v) IMATH_NOEXCEPT
Reverse multiplication: S * Color4.
bool operator()(const T &x) const
key_type key(const value_type &x) const
Returns the key for a value.
IMATH_HOSTDEVICE constexpr Quat< T > operator+(const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
Quaterion addition.
SdfChildrenView< C, P, A > Type
value_type operator[](size_type n) const
Returns the n'th element.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
bool has(const key_type &x) const
Returns true if an element with key x is in the container.
SdfChildrenView(const SdfLayerHandle &layer, const SdfPath &path, const TfToken &childrenKey, const Predicate &predicate, const KeyPolicy &keyPolicy=KeyPolicy())
key_type key(const const_iterator &x) const
Returns the key for an element.
value_type operator[](const key_type &x) const
static const PublicType & Convert(const PrivateType &t)
const Predicate & GetPredicate() const
#define PXR_NAMESPACE_CLOSE_SCOPE
OIIO_FORCEINLINE const vint4 & operator-=(vint4 &a, const vint4 &b)
static AdaptedView Create(const OriginalView &view)
static const _InnerIterator & GetBase(const const_iterator &i)
const_iterator end() const
Returns an const_iterator pointing to the end of the vector.
std::vector< key_type > keys() const
Returns the keys for all elements, in order.
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
static const_iterator GetIterator(const _Owner *owner, const _InnerIterator &i, size_t size)
const_reverse_iterator rbegin() const
SIM_API const UT_StringHolder distance
ChildPolicy::KeyPolicy KeyPolicy
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate and *a name There is also one special expression reference
bool operator==(const This &other) const
Sdf_ChildrenViewTraits< This, _InnerIterator, Predicate > _Traits
const_iterator find(const key_type &x) const
Finds the element with key x.
SDF_API bool IsValid() const
Return whether this object is valid.
bool operator!=(const This &other) const
SdfChildrenView(const SdfChildrenView &other)
SDF_API size_t Find(const KeyType &key) const
Find the index of the specified key, or return the size if it's not found.