24 #ifndef PXR_USD_AR_RESOLVER_CONTEXT_H
25 #define PXR_USD_AR_RESOLVER_CONTEXT_H
36 #ifdef PXR_PYTHON_SUPPORT_ENABLED
48 #include <type_traits>
62 static const bool value =
false;
66 template <
class Context>
75 template <
class Object,
class ...Other>
153 _AddObjects(objs...);
171 return _contexts.empty();
177 template <
class ContextObj>
178 const ContextObj*
Get()
const
180 for (
const auto& context : _contexts) {
181 if (context->IsHolding(
typeid(ContextObj))) {
182 return &_GetTyped<ContextObj>(*context)._context;
199 return !(*
this == rhs);
210 return TfHash()(context._contexts);
216 template <
class Context>
struct _Typed;
223 template <
class Object,
class ...Other>
224 void _AddObjects(
const Object& obj,
const Other&... other)
227 _AddObjects(other...);
233 template <
class Object>
234 void _Add(
const Object& obj)
236 _Add(std::shared_ptr<_Untyped>(
new _Typed<Object>(obj)));
240 void _Add(std::shared_ptr<_Untyped>&& context);
242 template <
class Context>
243 static const _Typed<Context>& _GetTyped(
const _Untyped& untyped)
245 return static_cast<const _Typed<Context>&
>(untyped);
253 bool IsHolding(
const std::type_info& ti)
const
258 virtual _Untyped* Clone()
const = 0;
259 virtual const std::type_info& GetTypeid()
const = 0;
260 virtual bool LessThan(
const _Untyped& rhs)
const = 0;
261 virtual bool Equals(
const _Untyped& rhs)
const = 0;
262 virtual size_t Hash()
const = 0;
267 template <
class Context>
268 struct _Typed :
public _Untyped
270 virtual ~_Typed() { }
272 _Typed(
const Context& context) : _context(context)
276 virtual _Untyped* Clone()
const
278 return new _Typed<Context>(_context);
281 virtual const std::type_info& GetTypeid()
const
286 virtual bool LessThan(
const _Untyped& rhs)
const
288 return _context < _GetTyped<Context>(rhs)._context;
291 virtual bool Equals(
const _Untyped& rhs)
const
293 return _context == _GetTyped<Context>(rhs)._context;
296 virtual size_t Hash()
const
308 #ifdef PXR_PYTHON_SUPPORT_ENABLED
319 template <
class HashState>
321 HashState&
h,
const std::shared_ptr<_Untyped>& context)
323 h.Append(context->Hash());
326 #ifdef PXR_PYTHON_SUPPORT_ENABLED
327 friend class Ar_ResolverContextPythonAccess;
330 std::vector<std::shared_ptr<_Untyped>> _contexts;
338 template <
class Context>
342 static_cast<void const*>(&context));
friend size_t hash_value(const ArResolverContext &context)
Returns hash value for this asset resolver context.
AR_API bool operator==(const ArResolverContext &rhs) const
bool operator!=(const ArResolverContext &rhs) const
STATIC_INLINE size_t Hash(const char *s, size_t len)
const ContextObj * Get() const
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
AR_API std::string Ar_GetDebugString(const std::type_info &, void const *)
AR_API std::string GetDebugString() const
Returns a debug string representing the contained context objects.
AR_API bool operator<(const ArResolverContext &rhs) const
ArResolverContext(const Objects &...objs)
bool IsEmpty() const
Returns whether this resolver context is empty.
std::string ArGetDebugString(const Context &context)
Default implementation for providing debug info on the contained context.
ArResolverContext()
Construct an empty asset resolver context.
GLfloat GLfloat GLfloat GLfloat h
friend void TfHashAppend(HashState &h, const std::shared_ptr< _Untyped > &context)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
PXR_NAMESPACE_OPEN_SCOPE bool TfSafeTypeCompare(const std::type_info &t1, const std::type_info &t2)