7#ifndef PXR_IMAGING_HD_DATASOURCELOCATOR_H
8#define PXR_IMAGING_HD_DATASOURCELOCATOR_H
15#include "pxr/imaging/hd/api.h"
19PXR_NAMESPACE_OPEN_SCOPE
161 return _tokens == rhs._tokens;
165 return _tokens != rhs._tokens;
172 inline bool IsEmpty()
const {
173 return _tokens.
empty();
180 std::string
GetString(
const char *delimiter =
"/")
const;
182 template <
class HashState>
184 h.AppendContiguous(myObj._tokens.
data(), myObj._tokens.
size());
187 inline size_t Hash()
const;
191 _TokenVector _tokens;
195HdDataSourceLocator::Hash()
const
200HD_API std::ostream&
operator<<(std::ostream& out,
239 const std::initializer_list<const HdDataSourceLocator> &l);
271 return _locators == rhs._locators;
275 return !(*
this == rhs);
283 const_iterator end()
const;
324 class IntersectionIterator;
325 class IntersectionView;
355class HdDataSourceLocatorSet::IntersectionIterator
358 using iterator_category = std::forward_iterator_tag;
360 using reference = value_type&;
361 using pointer = value_type*;
362 using difference_type = std::ptrdiff_t;
364 IntersectionIterator()
369 IntersectionIterator(
const bool isFirst,
370 const const_iterator &iterator,
371 const const_iterator &end,
374 , _iterator(iterator)
385 return std::addressof(**
this);
389 IntersectionIterator& operator++();
392 IntersectionIterator operator++(
int);
394 bool operator==(
const IntersectionIterator &other)
const noexcept
396 return _iterator == other._iterator;
399 bool operator!=(
const IntersectionIterator &other)
const noexcept
401 return _iterator != other._iterator;
406 const_iterator _iterator;
411class HdDataSourceLocatorSet::IntersectionView
414 IntersectionView(
const IntersectionIterator &begin,
415 const IntersectionIterator &end)
421 const IntersectionIterator &begin()
const {
return _begin; }
423 const IntersectionIterator &end()
const {
return _end; }
426 const IntersectionIterator _begin;
427 const IntersectionIterator _end;
430HD_API std::ostream&
operator<<(std::ostream& out,
433PXR_NAMESPACE_CLOSE_SCOPE
Represents an object that can identify the location of a data source.
HD_API HdDataSourceLocator(const TfToken &t1)
The following constructors take a number of tokens and build a locator with the apporpriate number of...
HD_API HdDataSourceLocator Append(const TfToken &name) const
Appends name to this data source locator.
HD_API const TfToken & GetFirstElement() const
Returns the first element, or empty token if none.
HD_API HdDataSourceLocator Prepend(const TfToken &name) const
Prepends name to this data source locator.
HD_API bool Intersects(const HdDataSourceLocator &other) const
Returns true if and only if either of the two locators is a prefix of the other one - in the sense of...
HD_API HdDataSourceLocator()
Creates an empty locator.
HD_API size_t GetElementCount() const
Returns the number of elements (tokens) in this data source.
HD_API HdDataSourceLocator Append(const HdDataSourceLocator &locator) const
Appends all of the elements in locator to this data source locator.
HD_API bool HasPrefix(const HdDataSourceLocator &prefix) const
Returns true if and only if this data source locator has prefix as a prefix.
HD_API HdDataSourceLocator RemoveLastElement() const
Returns a copy of this data source locator with the last element removed.
HD_API HdDataSourceLocator ReplacePrefix(const HdDataSourceLocator &oldPrefix, const HdDataSourceLocator &newPrefix) const
Returns a copy of this data source locator with oldPrefix replaced by newPrefix.
HD_API HdDataSourceLocator GetCommonPrefix(const HdDataSourceLocator &other) const
Returns a data source locator that represents the common prefix between this data source and other.
HdDataSourceLocator(const HdDataSourceLocator &rhs)=default
Copy constructor.
HD_API const TfToken & GetElement(size_t i) const
Returns the element (token) at index i.
HD_API HdDataSourceLocator RemoveFirstElement() const
Returns a copy of this data source locator with the first element removed.
HD_API std::string GetString(const char *delimiter="/") const
Returns a string representation of this data source locator with the given delimiter inserted between...
HD_API HdDataSourceLocator ReplaceLastElement(const TfToken &name) const
Returns a copy of this data source locator with the last element replaced by the one given by name.
HD_API HdDataSourceLocator(size_t count, const TfToken *tokens)
Builds a data source locator from the tokens array of the given count.
HD_API HdDataSourceLocator Prepend(const HdDataSourceLocator &locator) const
Prepends all of the elements in locator to this data source locator.
static HD_API const HdDataSourceLocator & EmptyLocator()
Returns a common empty locator.
HD_API bool operator<(const HdDataSourceLocator &rhs) const
Lexicographic order. If y has x as prefix, x < y.
HD_API const TfToken & GetLastElement() const
Returns the last element, or empty token if none.
Represents a set of data source locators closed under descendancy.
HD_API void insert(HdDataSourceLocatorSet &&locatorSet)
Changes this set to be the union of this set and the given set.
static HD_API const HdDataSourceLocatorSet & UniversalSet()
The set containing everything.
HdDataSourceLocatorSet & operator=(HdDataSourceLocatorSet &&rhs)=default
Move assignment operator.
HdDataSourceLocatorSet()
The empty set.
HD_API const_iterator begin() const
Iterates through minimal, lexicographically sorted list of data source locators generating this set.
HD_API HdDataSourceLocatorSet ReplacePrefix(const HdDataSourceLocator &oldPrefix, const HdDataSourceLocator &newPrefix) const
Returns a lexicographically sorted locator set wherein locators in this set that have oldPrefix as a ...
HD_API void insert(const HdDataSourceLocatorSet &locatorSet)
Changes this set to be the union of this set and the given set.
HD_API bool IsEmpty() const
True if and only if this set contains no data source locator.
HD_API bool Intersects(const HdDataSourceLocator &locator) const
True if and only if locator or any of its descendants is in the set (closed under descendancy).
HdDataSourceLocatorSet(HdDataSourceLocatorSet &&rhs)=default
Move Ctor.
HdDataSourceLocatorSet & operator=(const HdDataSourceLocatorSet &rhs)=default
Copy assignment operator.
HdDataSourceLocatorSet(const HdDataSourceLocatorSet &rhs)=default
Copy Ctor.
HD_API IntersectionView Intersection(const HdDataSourceLocator &locator) const
Returns intersection with a locator as a range-like object so that it can be used in a for-loop.
HD_API void append(const HdDataSourceLocator &locator)
append() is semantically equivalent to insert(), but works much faster if locator would be added to t...
HD_API bool Contains(const HdDataSourceLocator &locator) const
True if the set (closed under descendancy) contains the given locator.
HD_API bool Intersects(const HdDataSourceLocatorSet &locatorSet) const
True if and only if the two sets (closed under descendancy) intersect.
A user-extensible hashing mechanism for use with runtime hash tables.
This is a small-vector class with local storage optimization, the local storage can be specified via ...
size_type size() const
Returns the current size of the vector.
bool empty() const
Returns true if this vector is empty.
value_type * data()
Direct access to the underlying array.
Token for efficient comparison, assignment, and hashing of known strings.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...