Fracanto Vtable Pattern

Fracanto Vtable Pattern #2 — Type Erasure

Type Erasure via void *ctx

Type Erasure via void *ctx

The core idea of the pattern is type erasure: the generic code does not know the concrete type of the context and does not need to. Each backend defines its own data structure and populates the vtable with its functions. The SocketCAN implementation uses socketcan_init, socketcan_send, etc., the STM32 implementation correspondingly stm32_fdcan_init, stm32_fdcan_send, and so on. The calling code remains identical.