Skip to content

refactor(adapters): consolidate adapter utilities into unified template#301

Merged
kcenon merged 1 commit into
mainfrom
refactor/issue-299-consolidate-adapters
Jan 22, 2026
Merged

refactor(adapters): consolidate adapter utilities into unified template#301
kcenon merged 1 commit into
mainfrom
refactor/issue-299-consolidate-adapters

Conversation

@kcenon

@kcenon kcenon commented Jan 22, 2026

Copy link
Copy Markdown
Owner

Closes #299

Summary

  • Consolidate adapter utilities (typed_adapter, smart_adapter) into a unified generic adapter system
  • Add adapter<T> template with adapter_traits for wrapping values, shared_ptr, and unique_ptr
  • Add interface_adapter<Interface, Implementation> for interface adaptation with depth tracking
  • Add adapter_factory class for zero-cost adapter creation when implementation already implements interface
  • Maintain full backward compatibility with existing API through legacy file preservation

Changes

New Files

  • include/kcenon/common/adapters/adapter.h: Unified adapter implementation
  • tests/adapter_test.cpp: Comprehensive tests (31 test cases)

Modified Files

  • include/kcenon/common/adapters/adapters.h: Updated to include new adapter, added migration guide
  • include/kcenon/common/adapters/typed_adapter.h: Added deprecation notes and migration documentation
  • include/kcenon/common/adapters/smart_adapter.h: Added deprecation notes and migration documentation
  • tests/CMakeLists.txt: Added new adapter test target

Migration Guide

// Old API
typed_adapter<Interface, Impl>
make_smart_adapter<Interface>(impl)
smart_adapter_factory::make_adapter<Interface>(impl)

// New API
interface_adapter<Interface, Impl>
make_interface_adapter<Interface>(impl)
adapter_factory::create<Interface>(impl)

Test Plan

  • All 31 adapter tests pass
  • All 112 project tests pass (no regressions)
  • Build succeeds with no warnings
  • Backward compatibility maintained

- Add adapter<T> template with adapter_traits for value/smart pointer wrapping
- Add interface_adapter<I, T> template for interface adaptation with depth tracking
- Add adapter_factory for zero-cost adapter creation
- Add comprehensive tests for all adapter functionality
- Mark typed_adapter and smart_adapter as legacy with migration notes
- Maintain full backward compatibility with existing API
@kcenon kcenon merged commit 0e01bea into main Jan 22, 2026
24 checks passed
@kcenon kcenon deleted the refactor/issue-299-consolidate-adapters branch January 22, 2026 12:20
kcenon added a commit that referenced this pull request Apr 13, 2026
…te (#301)

- Add adapter<T> template with adapter_traits for value/smart pointer wrapping
- Add interface_adapter<I, T> template for interface adaptation with depth tracking
- Add adapter_factory for zero-cost adapter creation
- Add comprehensive tests for all adapter functionality
- Mark typed_adapter and smart_adapter as legacy with migration notes
- Maintain full backward compatibility with existing API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Consolidate adapter utilities (typed_adapter, smart_adapter) into single generic adapter

1 participant