capydi
Loading...
Searching...
No Matches
capy::di::ChainableConfig Concept Reference

Concept for configuration objects that transform/decorate dependencies. More...

#include <ChainableConfig.hpp>

Concept definition

template<typename Config>
requires() {
typename Config::RelatedEntity;
typename Config::RelatedKeysPack;
Config::CONFIG_TYPE;
}
&& std::same_as<std::remove_cv_t<decltype(Config::CONFIG_TYPE)>, ConfigType>
&& Config::CONFIG_TYPE == ConfigType::CHAINABLE
Concept for configuration objects that transform/decorate dependencies.
Definition ChainableConfig.hpp:58
ConfigType
Categorization of configuration strategies in the DI container.
Definition ConfigType.hpp:24
@ CHAINABLE
Chainable configs form a pipeline of transformations applied after creation. Examples: proxies,...
Definition ConfigType.hpp:35

Detailed Description

Concept for configuration objects that transform/decorate dependencies.

A ChainableConfig is a compile-time concept that ensures a type can participate in the transformation pipeline. Each chainable config:

  • Declares a RelatedEntity type (the type it transforms/decorates)
  • Declares a RelatedKey type (used for lookup/matching in the chain)
  • Implements a pipe() method that applies the transformation
  • Is statically classified as ConfigType::CHAINABLE
Template Parameters
ConfigThe configuration type being tested.

The pipe() method signature (when enabled) should be:

Reference<RelatedEntity> auto pipe(Reference<RelatedEntity> auto entity) const;

This enables powerful decorator patterns like:

class CacheDecorator {
using RelatedEntity = MyService;
using RelatedKey = CacheKey;
static constexpr ConfigType CONFIG_TYPE = ConfigType::CHAINABLE;
Reference<MyService> auto pipe(Reference<MyService> auto service) const {
return cached_service(service);
}
};
See also
ConfigType
CreationalConfig