7 #ifndef PXR_USD_SDF_CHILDREN_VIEW_H
8 #define PXR_USD_SDF_CHILDREN_VIEW_H
55 template <
typename _Owner,
typename _InnerIterator,
typename _DummyPredicate>
61 class _FilterIterator {
63 using iterator_category = std::forward_iterator_tag;
67 using difference_type =
typename _InnerIterator::difference_type;
69 _FilterIterator() =
default;
70 _FilterIterator(
const _Owner* owner,
71 const _InnerIterator& underlyingIterator,
72 const _InnerIterator&
end) :
74 _underlyingIterator(underlyingIterator),
80 return *_underlyingIterator;
84 return _underlyingIterator.operator->();
87 _FilterIterator& operator++() {
89 ++_underlyingIterator;
94 _FilterIterator operator++(
int) {
96 _FilterIterator
result(*
this);
97 ++_underlyingIterator;
102 bool operator==(
const _FilterIterator& other)
const {
103 return _underlyingIterator == other._underlyingIterator;
106 bool operator!=(
const _FilterIterator& other)
const {
107 return _underlyingIterator != other._underlyingIterator;
110 const _InnerIterator&
GetBase()
const {
return _underlyingIterator; }
116 return !_owner->GetPredicate()(
117 _Owner::Adapter::Convert(x));
122 while (_underlyingIterator != _end &&
123 _ShouldFilter(*_underlyingIterator)) {
124 ++_underlyingIterator;
128 const _Owner* _owner =
nullptr;
129 _InnerIterator _underlyingIterator;
140 const _InnerIterator& i,
143 _InnerIterator
end(owner,size);
157 template <
typename _Owner,
typename _InnerIterator>
166 const _InnerIterator& i,
size_t size)
198 template <
typename _ChildPolicy,
199 typename _Predicate =
204 typename _ChildPolicy::ValueType> >
225 class _InnerIterator {
236 using iterator_category = std::random_access_iterator_tag;
242 _InnerIterator() =
default;
243 _InnerIterator(
const This* owner,
const size_t& pos) :
244 _owner(owner), _pos(pos) { }
249 _InnerIterator advanced(*
this);
250 advanced.advance(index);
251 return advanced.dereference();
255 return -distance_to(other);
258 _InnerIterator& operator++() {
263 _InnerIterator& operator--() {
268 _InnerIterator operator++(
int) {
269 _InnerIterator
result(*
this);
274 _InnerIterator operator--(
int) {
275 _InnerIterator
result(*
this);
281 _InnerIterator
result(*
this);
282 result.advance(increment);
287 _InnerIterator
result(*
this);
288 result.advance(-decrement);
302 bool operator==(
const _InnerIterator& other)
const {
306 bool operator!=(
const _InnerIterator& other)
const {
307 return !
equal(other);
310 bool operator<(
const _InnerIterator& other)
const {
312 return _pos < other._pos;
315 bool operator<=(
const _InnerIterator& other)
const {
317 return _pos <= other._pos;
320 bool operator>(
const _InnerIterator& other)
const {
322 return _pos > other._pos;
325 bool operator>=(
const _InnerIterator& other)
const {
327 return _pos >= other._pos;
334 return _owner->_Get(_pos);
337 bool equal(
const _InnerIterator& other)
const
339 return _pos == other._pos;
355 return other._pos-_pos;
359 const This* _owner =
nullptr;
377 _children(layer, path, childrenKey, keyPolicy)
385 _children(layer, path, childrenKey, keyPolicy),
386 _predicate(predicate)
391 _children(other._children),
392 _predicate(other._predicate)
396 template <
class OtherAdapter>
398 OtherAdapter> &other) :
399 _children(other._children),
400 _predicate(other._predicate)
410 _children= other._children;
411 _predicate = other._predicate;
417 _InnerIterator i(
this,0);
423 _InnerIterator i(
this,_GetSize());
468 _InnerIterator inner(
this, _children.
Find(x));
482 return (i !=
end() && *i == x) ? i :
end();
492 return _children.
FindKey(Adapter::Convert(x));
497 return std::vector<value_type>(
begin(),
end());
501 template <
typename V>
509 std::vector<key_type>
keys()
const {
510 std::vector<key_type>
result;
511 result.reserve(
size());
513 result.push_back(
key(i));
519 template <
typename V>
521 std::vector<key_type> k =
keys();
522 return V(k.begin(), k.end());
526 template <
typename Dict>
530 result.insert(std::make_pair(
key(i), *i));
537 return (_children.
Find(x) != _GetSize());
543 return has(
key(Adapter::Convert(x)));
555 if (index == _GetSize()) {
565 if (index == _GetSize()) {
580 return _children.
IsEqualTo(other._children);
587 return !_children.
IsEqualTo(other._children);
608 return Adapter::Convert(_children.
GetChild(index));
612 size_t _GetSize()
const {
624 template <
class _View,
class _Adapter>
629 typename _View::Predicate,
639 template <
typename C,
typename P,
typename A>
643 template <
typename C,
typename P,
typename A>
650 template <
typename C,
typename P,
typename A>
660 #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
GLsizei const GLfloat * value
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)
APEX_COWHandle< APEX_ParmDict > Dict
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.