|
UCILoader 1.1.2
Small C++ library that allows user to connect to a chess engines via UCI protocol.
|
Builder class for constructing and composing loggers with traits. More...
#include <Logger.h>
Public Member Functions | |
| LoggerBuilder (std::unique_ptr< Logger > &&base) | |
| Construct a LoggerBuilder with a base logger. | |
| LoggerBuilder (LoggerBuilder &&other) | |
| Move constructor. | |
| LoggerBuilder & | addTrait (const LoggerTrait &trait) |
| Add a trait to customize the logger behavior. | |
| std::unique_ptr< Logger > | build () |
| Build and return the final logger instance. | |
Friends | |
| LoggerBuilder | operator| (LoggerBuilder builder, const LoggerTrait &trait) |
| Operator overload for applying traits using pipe operator. | |
Builder class for constructing and composing loggers with traits.
LoggerBuilder provides a fluent interface for creating loggers with custom behavior. Loggers are created using factory functions in the Loggers namespace, then composed with traits using the pipe operator (|).
The builder uses the pipe operator for readability and to allow chaining multiple trait applications. Once all traits are applied, call build() to obtain the final logger instance.
Usage Examples:
| UCILoader::LoggerBuilder::LoggerBuilder | ( | std::unique_ptr< Logger > && | base | ) |
Construct a LoggerBuilder with a base logger.
| base | The base logger instance |
| UCILoader::LoggerBuilder::LoggerBuilder | ( | LoggerBuilder && | other | ) |
Move constructor.
| other | The LoggerBuilder to move from |
| LoggerBuilder & UCILoader::LoggerBuilder::addTrait | ( | const LoggerTrait & | trait | ) |
Add a trait to customize the logger behavior.
This method applies a trait by wrapping the current logger. Traits are applied in the order they are added.
| trait | The trait to add |
| std::unique_ptr< Logger > UCILoader::LoggerBuilder::build | ( | ) |
Build and return the final logger instance.
|
friend |
Operator overload for applying traits using pipe operator.
This allows fluent syntax using the | operator:
| builder | The logger builder |
| trait | The trait to apply |