|
Common System 0.2.0
Common interfaces and patterns for system integration
|
Namespaces | |
| namespace | di_error_codes |
| Error codes specific to dependency injection. | |
Classes | |
| struct | bootstrapper_options |
| Configuration options for the unified bootstrapper. More... | |
| class | IBootstrapper |
| Interface for system bootstrapping. More... | |
| class | IServiceContainer |
| Abstract interface for dependency injection containers. More... | |
| interface | IServiceScope |
| Scoped service container for request-level isolation. More... | |
| class | service_container |
| Concrete implementation of IServiceContainer. More... | |
| struct | service_descriptor |
| Metadata describing a registered service. More... | |
| class | service_scope |
| Scoped service container implementation. More... | |
| class | ServiceContainer |
| Simple thread-safe service container implementation. More... | |
| class | unified_bootstrapper |
| Coordinates system initialization and shutdown. More... | |
Typedefs | |
| using | shutdown_hook = std::function<void(std::chrono::milliseconds remaining_timeout)> |
| Shutdown hook callback type. | |
| using | module_registration_fn = std::function<VoidResult(IServiceContainer&)> |
| Module registration callback type. | |
Enumerations | |
| enum class | service_lifetime { singleton , transient , scoped } |
| Defines the lifetime policy for registered services. More... | |
Functions | |
| const char * | to_string (service_lifetime lifetime) |
| Convert service_lifetime to string representation. | |
| using kcenon::common::di::module_registration_fn = std::function<VoidResult(IServiceContainer&)> |
Module registration callback type.
Each subsystem module provides a registration function that registers its services with the service container. This replaces compile-time #ifdef guards with runtime module registration.
Definition at line 90 of file unified_bootstrapper.h.
| using kcenon::common::di::shutdown_hook = std::function<void(std::chrono::milliseconds remaining_timeout)> |
Shutdown hook callback type.
Shutdown hooks are called in reverse order of registration during shutdown. Each hook receives the remaining timeout duration.
Definition at line 79 of file unified_bootstrapper.h.
|
strong |
Defines the lifetime policy for registered services.
The lifetime determines how instances are created and cached:
| Enumerator | |
|---|---|
| singleton | Single instance shared globally. The container creates one instance on first resolution and returns the same instance for all subsequent requests. The instance lives until the container is destroyed. Use for: Stateless services, expensive-to-create services, services that maintain global state (loggers, configuration, etc.) |
| transient | New instance created for each request. The container creates a new instance every time the service is resolved. Each instance is independent and caller owns its lifetime. Use for: Stateful services where each consumer needs its own instance, services with short lifespans, or services that cannot be shared safely. |
| scoped | Single instance within a scope. Similar to singleton, but scoped to a particular IServiceScope. Each scope gets its own instance, which is shared within that scope but separate from instances in other scopes. Use for: Request-scoped services (web handlers), unit-of-work patterns, services that should be isolated per logical operation. |
Definition at line 52 of file service_container_interface.h.
|
inline |
Convert service_lifetime to string representation.
| lifetime | The lifetime value to convert |
Definition at line 94 of file service_container_interface.h.