7 #ifndef PXR_USD_PCP_MAP_FUNCTION_H
8 #define PXR_USD_PCP_MAP_FUNCTION_H
68 typedef std::map<SdfPath, SdfPath, SdfPath::FastLessThan>
PathMap;
164 std::vector<SdfPathExpression::PathPattern>
165 *unmappedPatterns =
nullptr,
166 std::vector<SdfPathExpression::ExpressionReference>
167 *unmappedRefs =
nullptr
187 std::vector<SdfPathExpression::PathPattern>
188 *unmappedPatterns =
nullptr,
189 std::vector<SdfPathExpression::ExpressionReference>
190 *unmappedRefs =
nullptr
233 bool hasRootIdentity);
237 _MapPathExpressionImpl(
240 std::vector<SdfPathExpression::PathPattern> *unmappedPatterns,
241 std::vector<SdfPathExpression::ExpressionReference> *unmappedRefs
247 static const int _MaxLocalPairs = 2;
252 : numPairs(end-begin)
253 , hasRootIdentity(hasRootIdentity) {
256 if (numPairs <= _MaxLocalPairs) {
257 std::uninitialized_copy(begin, end, localPairs);
260 new (&remotePairs) std::shared_ptr<PathPair>(
262 std::copy(begin, end, remotePairs.get());
266 _Data(_Data
const &other)
267 : numPairs(other.numPairs)
268 , hasRootIdentity(other.hasRootIdentity) {
269 if (numPairs <= _MaxLocalPairs) {
270 std::uninitialized_copy(
272 other.localPairs + other.numPairs, localPairs);
275 new (&remotePairs) std::shared_ptr<PathPair>(other.remotePairs);
279 : numPairs(other.numPairs)
280 , hasRootIdentity(other.hasRootIdentity) {
281 if (numPairs <= _MaxLocalPairs) {
284 PathPair *srcEnd = other.localPairs + other.numPairs;
285 for (; src != srcEnd; ++
src, ++
dst) {
286 ::new (static_cast<void*>(std::addressof(*dst)))
292 std::shared_ptr<PathPair>(std::move(other.remotePairs));
296 if (
this != &other) {
298 new (
this) _Data(other);
303 if (
this != &other) {
305 new (
this) _Data(std::move(other));
310 if (numPairs <= _MaxLocalPairs) {
311 for (
PathPair *p = localPairs; numPairs--; ++p) {
316 remotePairs.~shared_ptr<
PathPair>();
321 return numPairs == 0 && !hasRootIdentity;
325 return numPairs <= _MaxLocalPairs ? localPairs : remotePairs.get();
329 return begin() + numPairs;
333 return numPairs == other.numPairs &&
334 hasRootIdentity == other.hasRootIdentity &&
339 return !(*
this == other);
342 template <
class HashState>
344 h.Append(data.hasRootIdentity);
345 h.Append(data.numPairs);
350 PathPair localPairs[_MaxLocalPairs > 0 ? _MaxLocalPairs : 1];
351 std::shared_ptr<PathPair> remotePairs;
353 typedef int PairCount;
354 PairCount numPairs = 0;
355 bool hasRootIdentity =
false;
359 template <
typename HashState>
379 #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.
PCP_API bool IsIdentity() const
#define PXR_NAMESPACE_OPEN_SCOPE
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
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
PcpMapFunction()=default
Construct a null function.
LeafData & operator=(const LeafData &)=delete
#define PXR_NAMESPACE_CLOSE_SCOPE
bool HasRootIdentity() const
static PCP_API PcpMapFunction ImpliedClass(const PcpMapFunction &transferFunc, const PcpMapFunction &classArc)
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