|
Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
|
Type-keyed dependency-injection container. More...
#include <container.hpp>
Public Member Functions | |
| Container () | |
| ~Container () | |
| Container (const Container &)=delete | |
| Container & | operator= (const Container &)=delete |
| Container (Container &&)=delete | |
| Container & | operator= (Container &&)=delete |
| template<typename Interface, typename Impl> | |
| void | register_singleton () |
| template<typename Interface> | |
| void | register_instance (std::shared_ptr< Interface > ptr) |
| template<typename Interface, typename Impl> | |
| void | register_transient () |
| template<typename Interface> | |
| void | register_factory (std::function< std::shared_ptr< Interface >()> fn) |
| template<typename Interface> | |
| std::shared_ptr< Interface > | resolve () |
| template<typename Interface> | |
| bool | has () const |
| void | clear () |
| Release every registration in reverse registration order (L-40). | |
Type-keyed dependency-injection container.
Thread-safe.
Supports four registration forms:
Teardown order (contract L-40): clear() and ~Container() release registrations in reverse registration order, so a service registered after its dependency is destroyed before it. Register providers before consumers and the container will not hand a destroyed dependency to a destructor. Re-registering a type keeps its original position — the instance changed, not the dependency order. A new registration replaces both the value and lifetime mode for its type. Factories retain their captured state between resolves and run outside the registry lock; factories called concurrently must synchronize their own state.
Each registration is destroyed with the internal mutex released, so a service destructor may call back into the container (resolve / has / register_*) without deadlocking. Note that reverse order only mirrors registration, not the resolution graph; a consumer that was registered before the provider it resolves is still a bug on the caller's side.
| aria::runtime::Container::Container | ( | ) |
| aria::runtime::Container::~Container | ( | ) |
|
delete |
|
delete |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenodiscard |
|
inlinenodiscard |
| void aria::runtime::Container::clear | ( | ) |
Release every registration in reverse registration order (L-40).
Each value is destroyed with the internal mutex released.