carb::getCachedInterface

Defined in carb/InterfaceUtils.h

template<typename InterfaceT, const char *PluginName = nullptr>
inline InterfaceT *carb::getCachedInterface()

Retrieves the specified interface as if from Framework::tryAcquireInterface() and caches it for fast retrieval.

If the interface is released with Framework::releaseInterface(), the cached interface will be automatically cleared. Calls to getCachedInterface() after this point will return nullptr. In order for getCachedInterface() to call Framework::tryAcquireInterface() again, first call resetCachedInterface().

Note

Releasing the Carbonite Framework with carb::releaseFramework() automatically calls resetCachedInterface().

Template Parameters
  • InterfaceT – The interface class to retrieve.

  • PluginName – The name of a specific plugin to keep cached. Note: this must be a global char array or nullptr.

Returns

The loaded and acquired interface class if successfully acquired through Framework::tryAcquireInterface(), or a previously cached value. If the interface could not be found, or has been released with releaseFramework(), nullptr is returned.