40 std::vector<const config_strategy_interface*> sorted;
43 sorted.push_back(strategy.get());
45 std::sort(sorted.begin(), sorted.end(),
46 [](
const auto* a,
const auto* b) {
47 return a->priority() > b->priority();
51 for (
const auto* strategy : sorted) {
52 if (strategy->is_applicable()) {
53 strategy->apply(config);
61 [](
const auto& strategy) {
62 return strategy->is_applicable();
85 template<
typename Strategy,
typename... Args>
88 std::make_unique<Strategy>(std::forward<Args>(args)...)
119 std::vector<std::unique_ptr<config_strategy_interface>>
strategies_;
Combines multiple configuration strategies.
composite_strategy & add(Args &&... args)
Add a strategy by constructing it in-place.
composite_strategy & clear()
Clear all strategies.
bool is_applicable() const override
Check if this strategy is applicable in the current context.
std::size_t size() const
Get the number of strategies.
void apply(logger_config &config) const override
Apply this strategy to a logger configuration.
std::string get_name() const override
Get the strategy name.
composite_strategy & add(std::unique_ptr< config_strategy_interface > strategy)
Add a strategy to the composite.
bool empty() const
Check if composite is empty.
std::vector< std::unique_ptr< config_strategy_interface > > strategies_
Abstract interface for logger configuration strategies.
Interface for logger configuration strategies (Strategy Pattern)
Configuration structure for logger with validation.
Configuration structure for logger with validation.