24 #ifndef PXR_USD_PCP_MAP_FUNCTION_H
25 #define PXR_USD_PCP_MAP_FUNCTION_H
84 typedef std::map<SdfPath, SdfPath, SdfPath::FastLessThan>
PathMap;
193 bool hasRootIdentity);
198 static const int _MaxLocalPairs = 2;
203 : numPairs(end-begin)
204 , hasRootIdentity(hasRootIdentity) {
207 if (numPairs <= _MaxLocalPairs) {
208 std::uninitialized_copy(begin, end, localPairs);
211 new (&remotePairs) std::shared_ptr<PathPair>(
213 std::copy(begin, end, remotePairs.get());
217 _Data(_Data
const &other)
218 : numPairs(other.numPairs)
219 , hasRootIdentity(other.hasRootIdentity) {
220 if (numPairs <= _MaxLocalPairs) {
221 std::uninitialized_copy(
223 other.localPairs + other.numPairs, localPairs);
226 new (&remotePairs) std::shared_ptr<PathPair>(other.remotePairs);
230 : numPairs(other.numPairs)
231 , hasRootIdentity(other.hasRootIdentity) {
232 if (numPairs <= _MaxLocalPairs) {
235 PathPair *srcEnd = other.localPairs + other.numPairs;
236 for (; src != srcEnd; ++
src, ++
dst) {
237 ::new (static_cast<void*>(std::addressof(*dst)))
243 std::shared_ptr<PathPair>(std::move(other.remotePairs));
246 _Data &operator=(_Data
const &other) {
247 if (
this != &other) {
249 new (
this) _Data(other);
253 _Data &operator=(_Data &&other) {
254 if (
this != &other) {
256 new (
this) _Data(std::move(other));
261 if (numPairs <= _MaxLocalPairs) {
262 for (
PathPair *p = localPairs; numPairs--; ++p) {
267 remotePairs.~shared_ptr<
PathPair>();
272 return numPairs == 0 && !hasRootIdentity;
276 return numPairs <= _MaxLocalPairs ? localPairs : remotePairs.get();
280 return begin() + numPairs;
284 return numPairs == other.numPairs &&
285 hasRootIdentity == other.hasRootIdentity &&
290 return !(*
this == other);
293 template <
class HashState>
295 h.Append(data.hasRootIdentity);
296 h.Append(data.numPairs);
301 PathPair localPairs[_MaxLocalPairs > 0 ? _MaxLocalPairs : 1];
302 std::shared_ptr<PathPair> remotePairs;
304 typedef int PairCount;
305 PairCount numPairs = 0;
306 bool hasRootIdentity =
false;
310 template <
typename HashState>
330 #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.
#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.