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

SystemBootstrapper implementation for runtime binding. More...

#include "../interfaces/global_logger_registry.h"
#include "../di/service_container.h"
#include "../patterns/result.h"
#include <functional>
#include <memory>
#include <mutex>
#include <string>
#include <utility>
#include <vector>
Include dependency graph for system_bootstrapper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  kcenon::common::bootstrap::SystemBootstrapper
 Fluent API for system initialization and logger registration. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::common
 Core interfaces.
 
namespace  kcenon::common::bootstrap
 

Detailed Description

SystemBootstrapper implementation for runtime binding.

This header provides a fluent API for system initialization at the application level. It integrates with GlobalLoggerRegistry to provide centralized logger management and supports initialization/shutdown hooks for lifecycle management.

Thread Safety:

  • SystemBootstrapper is NOT thread-safe for concurrent modification.
  • All configuration methods should be called from a single thread.
  • Once initialized, the registered loggers can be safely accessed from multiple threads through GlobalLoggerRegistry.

RAII Support:

  • Destructor automatically calls shutdown() if initialized.
  • Prevents duplicate initialization and duplicate shutdown.

Usage Example:

int main() {
SystemBootstrapper bootstrapper;
bootstrapper
.with_default_logger([] { return create_console_logger(); })
.with_logger("database", [] { return create_file_logger("db.log"); })
.on_initialize([] { LOG_INFO("System started"); })
.on_shutdown([] { LOG_INFO("System stopped"); });
auto result = bootstrapper.initialize();
if (result.is_err()) {
std::cerr << "Failed to initialize: " << result.error().message;
return 1;
}
// Application logic here...
// Shutdown is called automatically by destructor
return 0;
}
int main()
#define LOG_INFO(...)
Log an info-level message.
Definition log_macros.h:116
SystemBootstrapper implementation for runtime binding.
See also
Issue #176 for implementation requirements.
global_logger_registry.h for logger management.

Definition in file system_bootstrapper.h.