Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DekiProviderRegistry< Interface > Class Template Reference

Header-only typed wrapper around DekiProviderRegistryBase. More...

#include <DekiProviderRegistry.h>

Static Public Member Functions

template<typename T>
static T * GetProvider ()
 Typed access.
static Interface * GetDefault ()
 First-registered provider, or nullptr if the registry is empty.
static int GetProviderCount ()
static Interface * GetProviderAt (int idx)
static void RegisterPlugin (Interface *provider)
 Register a provider owned by a plugin DLL.
static void Register (Interface *provider)
 Register a provider owned by engine-core (rare; typically packages use the plugin variant).
static void Unregister (Interface *provider)

Detailed Description

template<typename Interface>
class DekiProviderRegistry< Interface >

Header-only typed wrapper around DekiProviderRegistryBase.

Each multi-provider package aliases this template to expose its registry with two access methods only:

namespace Deki { using Location = DekiProviderRegistry<IDekiLocationProvider>; }

auto* p = Deki::Location::GetProvider<BeaconDBLocationProvider>(); // typed auto* d = Deki::Location::GetDefault(); // first registered

No GetProviderById(const char*) is exposed — selection is always either compile-time-checked (typed) or convention-driven (default). String-keyed runtime lookups invite the "if A fails, try B" fallback pattern that the project's NEVER USE FALLBACKS rule forbids.

Interface contract:

  • Interface must derive from IDekiPackage.
  • Interface must define static constexpr const char* Category matching the category string used by ForCategory().
  • Each concrete provider T must define static constexpr const char* ProviderId.

RTTI: not used. Lookups go through string comparison on ProviderId, and the static_cast to T* is safe because the (category, ProviderId) pair is owned by exactly one type. Builds cleanly under -fno-rtti.

Member Function Documentation

◆ GetProvider()

template<typename Interface>
template<typename T>
T * DekiProviderRegistry< Interface >::GetProvider ( )
inlinestatic

Typed access.

T must derive from Interface and define ProviderId. Returns nullptr if no provider with T::ProviderId has registered.

◆ GetDefault()

template<typename Interface>
Interface * DekiProviderRegistry< Interface >::GetDefault ( )
inlinestatic

First-registered provider, or nullptr if the registry is empty.

Registration order is the order of calls to Register() at DekiPlugin_RegisterComponents time — i.e. source-code order in the package that registers them. This is the only "default" knob.

◆ GetProviderCount()

template<typename Interface>
int DekiProviderRegistry< Interface >::GetProviderCount ( )
inlinestatic

◆ GetProviderAt()

template<typename Interface>
Interface * DekiProviderRegistry< Interface >::GetProviderAt ( int idx)
inlinestatic

◆ RegisterPlugin()

template<typename Interface>
void DekiProviderRegistry< Interface >::RegisterPlugin ( Interface * provider)
inlinestatic

Register a provider owned by a plugin DLL.

The registry takes ownership and will delete the pointer during ClearPluginProviders() (called by PackageLoader before FreeLibrary).

◆ Register()

template<typename Interface>
void DekiProviderRegistry< Interface >::Register ( Interface * provider)
inlinestatic

Register a provider owned by engine-core (rare; typically packages use the plugin variant).

The registry never deletes these.

◆ Unregister()

template<typename Interface>
void DekiProviderRegistry< Interface >::Unregister ( Interface * provider)
inlinestatic

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