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;
154 std::vector<SdfPathExpression::PathPattern>
155 *unmappedPatterns =
nullptr,
156 std::vector<SdfPathExpression::ExpressionReference>
157 *unmappedRefs =
nullptr
177 std::vector<SdfPathExpression::PathPattern>
178 *unmappedPatterns =
nullptr,
179 std::vector<SdfPathExpression::ExpressionReference>
180 *unmappedRefs =
nullptr
223 bool hasRootIdentity);
227 _MapPathExpressionImpl(
230 std::vector<SdfPathExpression::PathPattern> *unmappedPatterns,
231 std::vector<SdfPathExpression::ExpressionReference> *unmappedRefs
237 static const int _MaxLocalPairs = 2;
242 : numPairs(end-begin)
243 , hasRootIdentity(hasRootIdentity) {
246 if (numPairs <= _MaxLocalPairs) {
247 std::uninitialized_copy(begin, end, localPairs);
250 new (&remotePairs) std::shared_ptr<PathPair>(
252 std::copy(begin, end, remotePairs.get());
256 _Data(_Data
const &other)
257 : numPairs(other.numPairs)
258 , hasRootIdentity(other.hasRootIdentity) {
259 if (numPairs <= _MaxLocalPairs) {
260 std::uninitialized_copy(
262 other.localPairs + other.numPairs, localPairs);
265 new (&remotePairs) std::shared_ptr<PathPair>(other.remotePairs);
269 : numPairs(other.numPairs)
270 , hasRootIdentity(other.hasRootIdentity) {
271 if (numPairs <= _MaxLocalPairs) {
274 PathPair *srcEnd = other.localPairs + other.numPairs;
275 for (; src != srcEnd; ++
src, ++
dst) {
276 ::new (static_cast<void*>(std::addressof(*dst)))
282 std::shared_ptr<PathPair>(std::move(other.remotePairs));
286 if (
this != &other) {
288 new (
this) _Data(other);
293 if (
this != &other) {
295 new (
this) _Data(std::move(other));
300 if (numPairs <= _MaxLocalPairs) {
301 for (
PathPair *p = localPairs; numPairs--; ++p) {
306 remotePairs.~shared_ptr<
PathPair>();
311 return numPairs == 0 && !hasRootIdentity;
315 return numPairs <= _MaxLocalPairs ? localPairs : remotePairs.get();
319 return begin() + numPairs;
323 return numPairs == other.numPairs &&
324 hasRootIdentity == other.hasRootIdentity &&
329 return !(*
this == other);
332 template <
class HashState>
334 h.Append(data.hasRootIdentity);
335 h.Append(data.numPairs);
340 PathPair localPairs[_MaxLocalPairs > 0 ? _MaxLocalPairs : 1];
341 std::shared_ptr<PathPair> remotePairs;
343 typedef int PairCount;
344 PairCount numPairs = 0;
345 bool hasRootIdentity =
false;
349 template <
typename HashState>
369 #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
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.