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

Static Public Member Functions | |
| template<typename Interface , typename Impl > | |
| static std::shared_ptr< Interface > | create (std::shared_ptr< Impl > impl) |
| Create an adapter with automatic optimization. | |
| template<typename AdapterType , typename... Args> | |
| static std::shared_ptr< AdapterType > | create_explicit (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:
|
inlinestatic |
Create an adapter with automatic optimization.
If Impl already implements Interface, returns a static_pointer_cast (zero-cost). Otherwise, creates an interface_adapter wrapper.
| Interface | The target interface type |
| Impl | The implementation type |
| impl | Shared pointer to the implementation |
Definition at line 455 of file adapter.h.
References kcenon::common::adapters::implements_interface_v.
Referenced by kcenon::common::adapters::make_interface_adapter().

|
inlinestatic |
Create an adapter with explicit adapter type.
| AdapterType | The specific adapter class to use |
| Args | Constructor argument types |
| args | Arguments to forward to adapter constructor |
Definition at line 472 of file adapter.h.
|
inlinestaticconstexpr |
Check if zero-cost adaptation is possible.
| Interface | The target interface |
| Impl | The implementation type |
Definition at line 517 of file adapter.h.
References kcenon::common::adapters::implements_interface_v.
|
inlinestatic |
Try to unwrap an interface to get underlying implementation.
| T | The expected underlying type |
| Interface | The interface type |
| ptr | Shared pointer to the interface |
Definition at line 485 of file adapter.h.
Referenced by kcenon::common::adapters::safe_unwrap(), and kcenon::common::adapters::unwrap_adapter().
