Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
adapters.h File Reference

Unified adapter utilities for type-safe and zero-cost adaptation. More...

#include "adapter.h"
#include "smart_adapter.h"
Include dependency graph for adapters.h:

Go to the source code of this file.

Detailed Description

Unified adapter utilities for type-safe and zero-cost adaptation.

This header provides a unified adapter system:

  • adapter<T>: Generic wrapper for values and smart pointers
  • adapter_traits<T>: Type traits for adapter configuration
  • interface_adapter<I, Impl>: Interface adaptation with depth tracking
  • adapter_factory: Factory for creating zero-cost adapters

Usage:

// Create value adapter
auto val = make_adapter<int>(42);
// Create shared pointer adapter
auto shared = make_shared_adapter<MyClass>(args...);
// Create interface adapter (zero-cost if possible)
auto executor = make_interface_adapter<IExecutor>(thread_pool);
// Unwrap an adapter to get underlying implementation
auto pool = unwrap_adapter<thread_pool_type>(executor);
// Check wrapper depth
if (executor->get_wrapper_depth() > 1) {
// Multiple layers of wrapping detected
}

Migration Guide:

  • make_smart_adapter<I>(impl) -> make_interface_adapter<I>(impl)
  • smart_adapter_factory::make_adapter -> adapter_factory::create

Definition in file adapters.h.