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

C++20 concepts for dependency injection and service container. More...

#include <concepts>
#include <type_traits>
#include <memory>
#include <functional>
Include dependency graph for service.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  kcenon
 
namespace  kcenon::common
 Core interfaces.
 
namespace  kcenon::common::di
 
namespace  kcenon::common::concepts
 C++20 concepts for compile-time type validation.
 

Concepts

concept  kcenon::common::concepts::ServiceInterface
 A type that can be used as a service interface.
 
concept  kcenon::common::concepts::ServiceImplementation
 A type that implements a service interface.
 
concept  kcenon::common::concepts::ServiceFactory
 A callable that creates service instances.
 
concept  kcenon::common::concepts::SimpleServiceFactory
 A callable that creates service instances without container access.
 
concept  kcenon::common::concepts::ServiceContainerLike
 A type that satisfies service container interface requirements.
 
concept  kcenon::common::concepts::ServiceScopeLike
 A type that represents a service scope.
 
concept  kcenon::common::concepts::InjectableService
 A service that can be automatically injected.
 
concept  kcenon::common::concepts::SharedService
 A type that can be shared via shared_ptr.
 
concept  kcenon::common::concepts::ConfigSection
 A serializable configuration section type.
 
concept  kcenon::common::concepts::Validatable
 A type that can validate its own state.
 
concept  kcenon::common::concepts::ServiceWithDependencies
 A service that declares its dependencies.
 
concept  kcenon::common::concepts::InitializableService
 A service that requires explicit initialization.
 
concept  kcenon::common::concepts::DisposableService
 A service that requires explicit cleanup.
 
concept  kcenon::common::concepts::ModuleRegistrar
 A class-based module registrar for ecosystem DI integration.
 

Detailed Description

C++20 concepts for dependency injection and service container.

This header provides concepts for validating service interfaces, implementations, and factories used in the dependency injection system. These concepts enable compile-time validation with clear error messages.

Requirements:

  • C++20 compiler with concepts support
  • GCC 10+, Clang 10+, MSVC 2022+

Thread Safety:

  • Concepts are evaluated at compile-time only.
  • No runtime thread-safety considerations apply.
See also
service_container_interface.h for IServiceContainer definition
service_container.h for service_container implementation
https://en.cppreference.com/w/cpp/language/constraints

Definition in file service.h.