|
Common System 0.2.0
Common interfaces and patterns for system integration
|
Smart adapter factory that avoids unnecessary wrapping. More...
#include <smart_adapter.h>

Static Public Member Functions | |
| template<typename Interface , typename Impl > | |
| static std::shared_ptr< Interface > | make_adapter (std::shared_ptr< Impl > impl) |
| Create an adapter with automatic optimization. | |
| template<typename AdapterType , typename... Args> | |
| static std::shared_ptr< AdapterType > | make_explicit_adapter (Args &&... args) |
| Create an adapter with explicit adapter type. | |
| template<typename T , typename Interface > | |
| static std::shared_ptr< T > | try_unwrap (std::shared_ptr< Interface > ptr) |
| Try to unwrap an interface to get underlying implementation. | |
| template<typename Interface , typename Impl > | |
| static constexpr bool | is_zero_cost () |
| Check if zero-cost adaptation is possible. | |
Smart adapter factory that avoids unnecessary wrapping.
This factory uses compile-time checks to determine if adaptation is needed:
This provides zero-cost abstraction when possible.
Definition at line 46 of file smart_adapter.h.
|
inlinestaticconstexpr |
Check if zero-cost adaptation is possible.
| Interface | The target interface |
| Impl | The implementation type |
Definition at line 120 of file smart_adapter.h.
References kcenon::common::adapters::implements_interface_v.
|
inlinestatic |
Create an adapter with automatic optimization.
If Impl already implements Interface, returns a static_pointer_cast (zero-cost). Otherwise, creates a typed_adapter wrapper.
| Interface | The target interface type |
| Impl | The implementation type |
| impl | Shared pointer to the implementation |
Definition at line 60 of file smart_adapter.h.
References kcenon::common::adapters::implements_interface_v.
Referenced by kcenon::common::adapters::make_smart_adapter().

|
inlinestatic |
Create an adapter with explicit adapter type.
Always creates the specified adapter type, even if zero-cost cast is possible. Use this when you need specific adapter behavior beyond simple interface conversion.
| AdapterType | The specific adapter class to use |
| Args | Constructor argument types |
| args | Arguments to forward to adapter constructor |
Definition at line 82 of file smart_adapter.h.
|
inlinestatic |
Try to unwrap an interface to get underlying implementation.
If the interface is a interface_adapter, unwraps it. Otherwise, returns nullptr (strict type safety without RTTI).
| T | The expected underlying type |
| Interface | The interface type |
| ptr | Shared pointer to the interface |
Definition at line 98 of file smart_adapter.h.
References kcenon::common::adapters::safe_unwrap().
