Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
ComponentInterfaceAdapters.h File Reference

Registry for extracting interfaces from components without RTTI or vtable changes. More...

Namespaces

namespace  ComponentInterfaceAdapters

Typedefs

using InterfaceAdapter = void* (*)(DekiComponent*)

Functions

void ComponentInterfaceAdapters::Register (uint32_t interfaceId, ComponentType componentType, InterfaceAdapter adapter)
void * ComponentInterfaceAdapters::Query (uint32_t interfaceId, DekiComponent *comp)
InterfaceAdapter ComponentInterfaceAdapters::Find (uint32_t interfaceId, ComponentType componentType, ComponentType baseType)
 The adapter Query would call for a component of this type (exact type first, then its base type), or nullptr.
uint32_t ComponentInterfaceAdapters::Version ()
 Bumped by every Register.

Detailed Description

Registry for extracting interfaces from components without RTTI or vtable changes.

Packages register adapter functions that convert a DekiComponent* to an interface pointer based on the component's StaticType. The renderer queries this to find IClipProvider, ISortableProvider, etc. without knowing the concrete component class.

Usage:

// In your component .cpp:
static struct MyAdapterRegistrar {
MyAdapterRegistrar() {
IClipProvider::InterfaceID, MyComponent::StaticType,
[](DekiComponent* c) -> void* {
return static_cast<IClipProvider*>(static_cast<MyComponent*>(c));
});
}
} s_reg;
Registry for extracting interfaces from components without RTTI or vtable changes.
Base class for all components (data-only).
Definition DekiComponent.h:51
Definition IClipProvider.h:36
static constexpr uint32_t InterfaceID
Definition IClipProvider.h:38
void Register(uint32_t interfaceId, ComponentType componentType, InterfaceAdapter adapter)

Typedef Documentation

◆ InterfaceAdapter

using InterfaceAdapter = void* (*)(DekiComponent*)