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;
187 bool hasRootIdentity);
192 static const int _MaxLocalPairs = 2;
197 : numPairs(end-begin)
198 , hasRootIdentity(hasRootIdentity) {
201 if (numPairs <= _MaxLocalPairs) {
202 std::uninitialized_copy(begin, end, localPairs);
205 new (&remotePairs) std::shared_ptr<PathPair>(
207 std::copy(begin, end, remotePairs.get());
211 _Data(_Data
const &other)
212 : numPairs(other.numPairs)
213 , hasRootIdentity(other.hasRootIdentity) {
214 if (numPairs <= _MaxLocalPairs) {
215 std::uninitialized_copy(
217 other.localPairs + other.numPairs, localPairs);
220 new (&remotePairs) std::shared_ptr<PathPair>(other.remotePairs);
224 : numPairs(other.numPairs)
225 , hasRootIdentity(other.hasRootIdentity) {
226 if (numPairs <= _MaxLocalPairs) {
229 PathPair *srcEnd = other.localPairs + other.numPairs;
230 for (; src != srcEnd; ++
src, ++
dst) {
231 ::new (static_cast<void*>(std::addressof(*dst)))
237 std::shared_ptr<PathPair>(std::move(other.remotePairs));
240 _Data &operator=(_Data
const &other) {
241 if (
this != &other) {
243 new (
this) _Data(other);
247 _Data &operator=(_Data &&other) {
248 if (
this != &other) {
250 new (
this) _Data(std::move(other));
255 if (numPairs <= _MaxLocalPairs) {
256 for (
PathPair *
p = localPairs; numPairs--; ++
p) {
261 remotePairs.~shared_ptr<
PathPair>();
266 return numPairs == 0 && !hasRootIdentity;
270 return numPairs <= _MaxLocalPairs ? localPairs : remotePairs.get();
274 return begin() + numPairs;
278 return numPairs == other.numPairs &&
279 hasRootIdentity == other.hasRootIdentity &&
284 return !(*
this == other);
288 PathPair localPairs[_MaxLocalPairs > 0 ? _MaxLocalPairs : 1];
289 std::shared_ptr<PathPair> remotePairs;
291 typedef int PairCount;
292 PairCount numPairs = 0;
293 bool hasRootIdentity =
false;
309 #endif // PXR_USD_PCP_MAP_FUNCTION_H
PCP_API size_t Hash() const
Return a size_t hash for this map function.
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
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()
PCP_API bool operator==(const PcpMapFunction &map) const
Equality.
const SdfLayerOffset & GetTimeOffset() const
The time offset of the mapping.
std::map< SdfPath, SdfPath, SdfPath::FastLessThan > PathMap
A mapping from path to path.
std::pair< SdfPath, SdfPath > PathPair
GLsizei const GLchar *const * string
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.
PCP_API PcpMapFunction GetInverse() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
PcpMapFunction()=default
Construct a null function.
OIIO_API bool copy(string_view from, string_view to, std::string &err)
#define PXR_NAMESPACE_CLOSE_SCOPE
bool equal(T1 a, T2 b, T3 t)
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