24 #ifndef PXR_USD_PCP_MAP_FUNCTION_H
25 #define PXR_USD_PCP_MAP_FUNCTION_H
85 typedef std::map<SdfPath, SdfPath, SdfPath::FastLessThan>
PathMap;
171 std::vector<SdfPathExpression::PathPattern>
172 *unmappedPatterns =
nullptr,
173 std::vector<SdfPathExpression::ExpressionReference>
174 *unmappedRefs =
nullptr
194 std::vector<SdfPathExpression::PathPattern>
195 *unmappedPatterns =
nullptr,
196 std::vector<SdfPathExpression::ExpressionReference>
197 *unmappedRefs =
nullptr
240 bool hasRootIdentity);
244 _MapPathExpressionImpl(
247 std::vector<SdfPathExpression::PathPattern> *unmappedPatterns,
248 std::vector<SdfPathExpression::ExpressionReference> *unmappedRefs
254 static const int _MaxLocalPairs = 2;
259 : numPairs(end-begin)
260 , hasRootIdentity(hasRootIdentity) {
263 if (numPairs <= _MaxLocalPairs) {
264 std::uninitialized_copy(begin, end, localPairs);
267 new (&remotePairs) std::shared_ptr<PathPair>(
269 std::copy(begin, end, remotePairs.get());
273 _Data(_Data
const &other)
274 : numPairs(other.numPairs)
275 , hasRootIdentity(other.hasRootIdentity) {
276 if (numPairs <= _MaxLocalPairs) {
277 std::uninitialized_copy(
279 other.localPairs + other.numPairs, localPairs);
282 new (&remotePairs) std::shared_ptr<PathPair>(other.remotePairs);
286 : numPairs(other.numPairs)
287 , hasRootIdentity(other.hasRootIdentity) {
288 if (numPairs <= _MaxLocalPairs) {
291 PathPair *srcEnd = other.localPairs + other.numPairs;
292 for (; src != srcEnd; ++
src, ++
dst) {
293 ::new (static_cast<void*>(std::addressof(*dst)))
299 std::shared_ptr<PathPair>(std::move(other.remotePairs));
303 if (
this != &other) {
305 new (
this) _Data(other);
310 if (
this != &other) {
312 new (
this) _Data(std::move(other));
317 if (numPairs <= _MaxLocalPairs) {
318 for (
PathPair *p = localPairs; numPairs--; ++p) {
323 remotePairs.~shared_ptr<
PathPair>();
328 return numPairs == 0 && !hasRootIdentity;
332 return numPairs <= _MaxLocalPairs ? localPairs : remotePairs.get();
336 return begin() + numPairs;
340 return numPairs == other.numPairs &&
341 hasRootIdentity == other.hasRootIdentity &&
346 return !(*
this == other);
349 template <
class HashState>
351 h.Append(data.hasRootIdentity);
352 h.Append(data.numPairs);
357 PathPair localPairs[_MaxLocalPairs > 0 ? _MaxLocalPairs : 1];
358 std::shared_ptr<PathPair> remotePairs;
360 typedef int PairCount;
361 PairCount numPairs = 0;
362 bool hasRootIdentity =
false;
366 template <
typename HashState>
386 #endif // PXR_USD_PCP_MAP_FUNCTION_H
PCP_API size_t Hash() const
Return a size_t hash for this map function.
PCP_API bool IsIdentityPathMapping() const
PCP_API PathMap GetSourceToTargetMap() const
The set of path mappings, from source to target.
static PCP_API const PcpMapFunction & Identity()
Construct an identity map function.
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
PCP_API bool IsIdentity() const
GLsizei const GLchar *const * string
static PCP_API const PathMap & IdentityPathMap()
Returns an identity path mapping.
GLsizei const GLchar *const * path
PCP_API bool operator!=(const PcpMapFunction &map) const
Inequality.
PCP_API SdfPath MapSourceToTarget(const SdfPath &path) const
static PCP_API PcpMapFunction Create(const PathMap &sourceToTargetMap, const SdfLayerOffset &offset)
friend PcpMapFunction * Pcp_MakeIdentity()
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
PCP_API bool operator==(const PcpMapFunction &map) const
Equality.
const SdfLayerOffset & GetTimeOffset() const
The time offset of the mapping.
friend void TfHashAppend(HashState &h, const PcpMapFunction &x)
std::map< SdfPath, SdfPath, SdfPath::FastLessThan > PathMap
A mapping from path to path.
std::pair< SdfPath, SdfPath > PathPair
void swap(PcpMapFunction &map)
std::vector< PathPair > PathPairVector
PCP_API PcpMapFunction Compose(const PcpMapFunction &f) const
PCP_API void Swap(PcpMapFunction &map)
Swap the contents of this map function with map.
GLfloat GLfloat GLfloat GLfloat h
PCP_API PcpMapFunction GetInverse() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
PcpMapFunction()=default
Construct a null function.
LeafData & operator=(const LeafData &)=delete
#define PXR_NAMESPACE_CLOSE_SCOPE
bool HasRootIdentity() const
size_t hash_value(const PcpMapFunction &x)
PCP_API std::string GetString() const
PCP_API SdfPath MapTargetToSource(const SdfPath &path) const
PCP_API bool IsNull() const
PCP_API PcpMapFunction ComposeOffset(const SdfLayerOffset &newOffset) const
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.