HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArResolverContext Class Reference

#include <resolverContext.h>

Public Member Functions

 ArResolverContext ()
 Construct an empty asset resolver context. More...
 
template<class... Objects, typename std::enable_if< Ar_AllValidForContext< Objects...>::value >::type * = nullptr>
 ArResolverContext (const Objects &...objs)
 
AR_API ArResolverContext (const std::vector< ArResolverContext > &ctxs)
 
bool IsEmpty () const
 Returns whether this resolver context is empty. More...
 
template<class ContextObj >
const ContextObj * Get () const
 
AR_API std::string GetDebugString () const
 Returns a debug string representing the contained context objects. More...
 
Operators
AR_API bool operator== (const ArResolverContext &rhs) const
 
bool operator!= (const ArResolverContext &rhs) const
 
AR_API bool operator< (const ArResolverContext &rhs) const
 

Friends

size_t hash_value (const ArResolverContext &context)
 Returns hash value for this asset resolver context. More...
 
template<class HashState >
void TfHashAppend (HashState &h, const std::shared_ptr< _Untyped > &context)
 

Detailed Description

An asset resolver context allows clients to provide additional data to the resolver for use during resolution. Clients may provide this data via context objects of their own (subject to restrictions below). An ArResolverContext is simply a wrapper around these objects that allows it to be treated as a single type. Note that an ArResolverContext may not hold multiple context objects with the same type.

A client-defined context object must provide the following:

  • Default and copy constructors
  • operator<
  • operator==
  • An overload for size_t hash_value(const T&)

Note that the user may define a free function:

std::string ArGetDebugString(const Context& ctx); (Where Context is the type of the user's path resolver context.)

This is optional; a default generic implementation has been predefined. This function should return a string representation of the context to be utilized for debugging purposes(such as in TF_DEBUG statements).

The ArIsContextObject template must also be specialized for this object to declare that it can be used as a context object. This is to avoid accidental use of an unexpected object as a context object. The AR_DECLARE_RESOLVER_CONTEXT macro can be used to do this as a convenience.

See Also
AR_DECLARE_RESOLVER_CONTEXT
ArResolver::BindContext
ArResolver::UnbindContext
ArResolverContextBinder

Definition at line 124 of file resolverContext.h.

Constructor & Destructor Documentation

ArResolverContext::ArResolverContext ( )
inline

Construct an empty asset resolver context.

Definition at line 128 of file resolverContext.h.

template<class... Objects, typename std::enable_if< Ar_AllValidForContext< Objects...>::value >::type * = nullptr>
ArResolverContext::ArResolverContext ( const Objects &...  objs)
inline

Construct a resolver context using the given objects objs.

Each argument must either be an ArResolverContext or a registered context object. See class documentation for requirements on context objects.

If an argument is a context object, it will be added to the constructed ArResolverContext. If an argument is an ArResolverContext, all of the context objects it holds will be added to the constructed ArResolverContext.

Arguments are ordered from strong-to-weak. If a context object is encountered with the same type as a previously-added object, the previously-added object will remain and the other context object will be ignored.

Definition at line 151 of file resolverContext.h.

AR_API ArResolverContext::ArResolverContext ( const std::vector< ArResolverContext > &  ctxs)
explicit

Construct a resolver context using the ArResolverContexts in ctxs.

All of the context objects held by each ArResolverContext in ctxs will be added to the constructed ArResolverContext.

Arguments are ordered from strong-to-weak. If a context object is encountered with the same type as a previously-added object, the previously-added object will remain and the other context object will be ignored.

Member Function Documentation

template<class ContextObj >
const ContextObj* ArResolverContext::Get ( ) const
inline

Returns pointer to the context object of the given type held in this resolver context. Returns NULL if this resolver context is not holding an object of the requested type.

Definition at line 178 of file resolverContext.h.

AR_API std::string ArResolverContext::GetDebugString ( ) const

Returns a debug string representing the contained context objects.

bool ArResolverContext::IsEmpty ( ) const
inline

Returns whether this resolver context is empty.

Definition at line 169 of file resolverContext.h.

bool ArResolverContext::operator!= ( const ArResolverContext rhs) const
inline

Definition at line 197 of file resolverContext.h.

AR_API bool ArResolverContext::operator< ( const ArResolverContext rhs) const
AR_API bool ArResolverContext::operator== ( const ArResolverContext rhs) const

Friends And Related Function Documentation

size_t hash_value ( const ArResolverContext context)
friend

Returns hash value for this asset resolver context.

Definition at line 208 of file resolverContext.h.

template<class HashState >
void TfHashAppend ( HashState &  h,
const std::shared_ptr< _Untyped > &  context 
)
friend

Definition at line 320 of file resolverContext.h.


The documentation for this class was generated from the following file: