AYON Usd Resolver  1.0.0
Loading...
Searching...
No Matches
resolverContext.h
Go to the documentation of this file.
1#ifndef AR_AYONUSDRESOLVER_RESOLVER_CONTEXT_H
2#define AR_AYONUSDRESOLVER_RESOLVER_CONTEXT_H
3
4#include "pluginData/api.h"
5
6#include "pxr/pxr.h"
7#include "pxr/usd/ar/defineResolverContext.h"
8
10
11#include <string>
12
14 public:
15 // Constructors
21 AyonUsdResolverContext(const std::string &filePath);
24
25 // Standard Ops
27 bool operator<(const AyonUsdResolverContext &ctx) const;
29 bool operator==(const AyonUsdResolverContext &ctx) const;
31 bool operator!=(const AyonUsdResolverContext &ctx) const;
33 friend size_t hash_value(const AyonUsdResolverContext &ctx);
34
35 // Methods
37 void Initialize();
40
42 void DropCache();
43
45 void DeleteFromCache(const std::string &key);
46
48 void ClearCache();
49
51 const std::string& GetMappingFilePath() const;
53 void SetMappingFilePath(std::string filePath);
57 void AddMappingPair(const std::string& sourceStr, const std::string& targetStr);
59 void RemoveMappingByKey(const std::string& sourceStr);
61 void RemoveMappingByValue(const std::string& targetStr);
63 void ClearMappingPairs();
65 const std::map<std::string, std::string> GetMappingPairs() const;
66
67 std::shared_ptr<ResolverContextCache> GetCachePtr() const;
68
69 private:
70 std::shared_ptr<ResolverContextCache> cache;
71 ArResolvedPath rootPath;
72 std::string mappingFilePath;
73 std::unordered_map<std::string, std::string> mappingPairs;
74
75 bool _getMappingPairsFromFile(const std::string& filePath);
76 bool _getMappingPairsFromUsdFile(const std::string& filePath);
77 bool _getMappingPairsFromJsonFile(const std::string& filePath);
78};
79
80PXR_NAMESPACE_OPEN_SCOPE
82PXR_NAMESPACE_CLOSE_SCOPE
83
84#endif // AR_AYONUSDRESOLVER_RESOLVER_CONTEXT_H
#define AR_AYONUSDRESOLVER_API
Definition: api.h:17
Definition: resolverContext.h:13
AR_AYONUSDRESOLVER_API const std::map< std::string, std::string > GetMappingPairs() const
Definition: resolverContext.cpp:318
AR_AYONUSDRESOLVER_API void DropCache()
Definition: resolverContext.cpp:112
std::shared_ptr< ResolverContextCache > GetCachePtr() const
Definition: resolverContext.cpp:154
AR_AYONUSDRESOLVER_API bool operator==(const AyonUsdResolverContext &ctx) const
Definition: resolverContext.cpp:83
bool _getMappingPairsFromFile(const std::string &filePath)
Definition: resolverContext.cpp:159
ArResolvedPath rootPath
Definition: resolverContext.h:71
bool _getMappingPairsFromUsdFile(const std::string &filePath)
Definition: resolverContext.cpp:194
AR_AYONUSDRESOLVER_API bool operator<(const AyonUsdResolverContext &ctx) const
Definition: resolverContext.cpp:78
bool _getMappingPairsFromJsonFile(const std::string &filePath)
Definition: resolverContext.cpp:238
AR_AYONUSDRESOLVER_API void Initialize()
Definition: resolverContext.cpp:97
AR_AYONUSDRESOLVER_API AyonUsdResolverContext()
Definition: resolverContext.cpp:49
std::shared_ptr< ResolverContextCache > cache
Definition: resolverContext.h:70
AR_AYONUSDRESOLVER_API void ClearCache()
Definition: resolverContext.cpp:133
AR_AYONUSDRESOLVER_API void RemoveMappingByValue(const std::string &targetStr)
Definition: resolverContext.cpp:302
AR_AYONUSDRESOLVER_API friend size_t hash_value(const AyonUsdResolverContext &ctx)
Definition: resolverContext.cpp:93
AR_AYONUSDRESOLVER_API void RemoveMappingByKey(const std::string &sourceStr)
Definition: resolverContext.cpp:294
AR_AYONUSDRESOLVER_API ~AyonUsdResolverContext()
Definition: resolverContext.cpp:73
AR_AYONUSDRESOLVER_API void SetMappingFilePath(std::string filePath)
Definition: resolverContext.cpp:144
AR_AYONUSDRESOLVER_API void ClearAndReinitialize()
Definition: resolverContext.cpp:105
AR_AYONUSDRESOLVER_API void ClearMappingPairs()
Definition: resolverContext.cpp:313
AR_AYONUSDRESOLVER_API AyonUsdResolverContext(const AyonUsdResolverContext &ctx)
AR_AYONUSDRESOLVER_API void DeleteFromCache(const std::string &key)
Definition: resolverContext.cpp:127
std::unordered_map< std::string, std::string > mappingPairs
Definition: resolverContext.h:73
AR_AYONUSDRESOLVER_API void RefreshFromMappingFilePath()
Definition: resolverContext.cpp:149
AR_AYONUSDRESOLVER_API bool operator!=(const AyonUsdResolverContext &ctx) const
Definition: resolverContext.cpp:88
std::string mappingFilePath
Definition: resolverContext.h:72
AR_AYONUSDRESOLVER_API void AddMappingPair(const std::string &sourceStr, const std::string &targetStr)
Definition: resolverContext.cpp:282
AR_AYONUSDRESOLVER_API const std::string & GetMappingFilePath() const
Definition: resolverContext.cpp:139
PXR_NAMESPACE_OPEN_SCOPE AR_DECLARE_RESOLVER_CONTEXT(AyonUsdResolverContext)