7 #ifndef PXR_USD_AR_RESOLVER_CONTEXT_H
8 #define PXR_USD_AR_RESOLVER_CONTEXT_H
19 #ifdef PXR_PYTHON_SUPPORT_ENABLED
31 #include <type_traits>
45 static const bool value =
false;
49 template <
class Context>
58 template <
class Object,
class ...Other>
136 _AddObjects(objs...);
154 return _contexts.empty();
160 template <
class ContextObj>
161 const ContextObj*
Get()
const
163 for (
const auto& context : _contexts) {
164 if (context->IsHolding(
typeid(ContextObj))) {
165 return &_GetTyped<ContextObj>(*context)._context;
182 return !(*
this == rhs);
193 return TfHash()(context._contexts);
199 template <
class Context>
struct _Typed;
206 template <
class Object,
class ...Other>
207 void _AddObjects(
const Object& obj,
const Other&... other)
210 _AddObjects(other...);
216 template <
class Object>
217 void _Add(
const Object& obj)
219 _Add(std::shared_ptr<_Untyped>(
new _Typed<Object>(obj)));
223 void _Add(std::shared_ptr<_Untyped>&& context);
225 template <
class Context>
226 static const _Typed<Context>& _GetTyped(
const _Untyped& untyped)
228 return static_cast<const _Typed<Context>&
>(untyped);
236 bool IsHolding(
const std::type_info& ti)
const
241 virtual _Untyped* Clone()
const = 0;
242 virtual const std::type_info& GetTypeid()
const = 0;
243 virtual bool LessThan(
const _Untyped& rhs)
const = 0;
244 virtual bool Equals(
const _Untyped& rhs)
const = 0;
245 virtual size_t Hash()
const = 0;
250 template <
class Context>
251 struct _Typed :
public _Untyped
253 virtual ~_Typed() { }
255 _Typed(
const Context& context) : _context(context)
259 virtual _Untyped* Clone()
const
261 return new _Typed<Context>(_context);
264 virtual const std::type_info& GetTypeid()
const
269 virtual bool LessThan(
const _Untyped& rhs)
const
271 return _context < _GetTyped<Context>(rhs)._context;
274 virtual bool Equals(
const _Untyped& rhs)
const
276 return _context == _GetTyped<Context>(rhs)._context;
279 virtual size_t Hash()
const
291 #ifdef PXR_PYTHON_SUPPORT_ENABLED
302 template <
class HashState>
304 HashState&
h,
const std::shared_ptr<_Untyped>& context)
306 h.Append(context->Hash());
309 #ifdef PXR_PYTHON_SUPPORT_ENABLED
310 friend class Ar_ResolverContextPythonAccess;
313 std::vector<std::shared_ptr<_Untyped>> _contexts;
321 template <
class Context>
325 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 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
GLint GLint GLsizei GLint GLenum GLenum type
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
Context provides a wrapper around the Core library context object.
PXR_NAMESPACE_OPEN_SCOPE bool TfSafeTypeCompare(const std::type_info &t1, const std::type_info &t2)