|
Common System 0.2.0
Common interfaces and patterns for system integration
|
Language: English | 한국어
A foundational C++20 header-only library providing essential interfaces and design patterns for building modular, loosely-coupled system architectures. Designed as the cornerstone of the ecosystem, it enables seamless integration between system modules while maintaining zero runtime overhead through template-based abstractions and interface-driven design.
Key Value Propositions:
v1.0.0 — Stable API release. All public headers are frozen under SemVer guarantees. Breaking changes will only occur in future major versions (v2.0+).
Starting with v1.0.0, common_system provides the following guarantees:
common_system::common_system, kcenon::common_system, kcenon::common#include paths: All headers under kcenon/common/ are part of the public APIResult<T> instead of throwing exceptions. The unwrap() method intentionally throws when called on an error result (Rust-style panic semantics)See VERSIONING.md for the full versioning policy and release process.
| Category | Feature | Description | Status |
|---|---|---|---|
| Patterns | Result<T> | Rust-inspired monadic error handling (and_then, map, or_else) | Stable |
| Patterns | Circuit Breaker | Resilience pattern with CLOSED/OPEN/HALF_OPEN states | Stable |
| Patterns | Event Bus | Thread-safe synchronous pub/sub | Stable |
| Interfaces | IExecutor / IJob | Universal task execution abstraction | Stable |
| Interfaces | ILogger / IMetricCollector | Monitoring and logging interfaces | Stable |
| DI | Service Container | Thread-safe DI with singleton/transient/scoped lifetimes | Stable |
| Config | Config Loader / Watcher | Configuration management with file watching | Stable |
| Config | CLI Parser | Command-line argument parsing | Stable |
| Utils | Circular Buffer / Object Pool | High-performance utility data structures | Stable |
| Concepts | C++20 Concepts | Resultable, Unwrappable, callable, container, etc. | Stable |
Full Getting Started Guide
| Dependency | Version | Required | Description |
|---|---|---|---|
| C++20 Compiler | GCC 11+ / Clang 14+ / MSVC 2022+ / Apple Clang 14+ | Yes | C++20 features (concepts) |
| CMake | 3.28+ | Yes | Build system |
common_system enforces minimum compiler versions at CMake configure time via KcenonCompilerRequirements.cmake. Downstream systems can include this module for consistent enforcement.
| Build Mode | GCC | Clang | MSVC | Apple Clang |
|---|---|---|---|---|
| Header-only (default) | 11+ | 14+ | 2022 (19.30+) | 14+ |
| C++20 Modules (optional) | 14+ | 16+ | 2022 17.4 (19.34+) | Not supported |
When using multiple systems together, use the highest requirement from your dependency chain:
| Usage Scenario | GCC | Clang | MSVC | Apple Clang | Notes |
|---|---|---|---|---|---|
| common_system only | 11+ | 14+ | 2022+ | 14+ | Baseline |
| + thread_system | 13+ | 17+ | 2022+ | 14+ | Higher requirements |
| + logger_system | 11+ | 14+ | 2022+ | 14+ | Optional thread_system |
| + container_system | 11+ | 14+ | 2022+ | 14+ | Uses common_system |
| + monitoring_system | 13+ | 17+ | 2022+ | 14+ | Requires thread_system |
| + database_system | 13+ | 17+ | 2022+ | 14+ | Full ecosystem |
| + network_system | 13+ | 17+ | 2022+ | 14+ | Requires thread_system |
Note: If using any system that depends on thread_system, you need GCC 13+ or Clang 17+. All systems can include
KcenonCompilerRequirements.cmakefrom common_system for automated version enforcement at configure time.
In your CMakeLists.txt:
Complete Architecture Guide
Type-safe error handling without exceptions, inspired by Rust:
Universal task execution abstraction for any threading backend:
Comprehensive health check system with dependency graph:
Centralized error code registry providing system-specific ranges:
| System | Range | Purpose |
|---|---|---|
| common_system | -1 to -99 | Core errors |
| thread_system | -100 to -199 | Threading errors |
| logger_system | -200 to -299 | Logging errors |
| monitoring_system | -300 to -399 | Monitoring errors |
| container_system | -400 to -499 | Container errors |
| database_system | -500 to -599 | Database errors |
| network_system | -600 to -699 | Network errors |
Resilience pattern for fault tolerance:
| Component | Purpose | Header |
|---|---|---|
Result<T> / VoidResult | Monadic error handling | patterns/result.h |
IExecutor / IJob | Task execution interface | interfaces/executor_interface.h |
ILogger | Logging abstraction | interfaces/logger_interface.h |
service_container | Dependency injection | di/service_container.h |
simple_event_bus | Synchronous pub/sub | patterns/event_bus.h |
circuit_breaker | Resilience pattern | resilience/circuit_breaker.h |
config_loader | Configuration management | config/config_loader.h |
circular_buffer | Fixed-size ring buffer | utils/circular_buffer.h |
object_pool | Object pooling | utils/object_pool.h |
Complete API Reference
| Example | Description | Difficulty |
|---|---|---|
| result_example | Result<T> error handling patterns | Beginner |
| executor_example | Executor interface and thread management | Beginner |
| abi_version_example | ABI version checking and compatibility | Intermediate |
| unwrap_demo | Result unwrapping and chaining | Intermediate |
| multi_system_app | Multi-system integration example | Advanced |
| Operation | Time (ns) | Allocations | Notes |
|---|---|---|---|
| Result<T> creation | 2.3 | 0 | Stack-only operation |
| Result<T> error check | 0.8 | 0 | Single bool check |
| IExecutor submit | 45.2 | 1 | Task queue insertion |
| Event publish | 12.4 | 0 | Lock-free operation |
Key Performance Characteristics:
Quality Metrics:
Full Benchmarks
Ecosystem reference: thread_system — Tier 1: Implements IExecutor interface container_system — Tier 1: Uses Result<T> for error handling logger_system — Tier 2: Uses ILogger, Result<T> monitoring_system — Tier 3: Uses event bus, IMonitor database_system — Tier 3: Uses Result<T>, IExecutor network_system — Tier 4: Uses IExecutor, Result<T> pacs_system — Tier 5: Full ecosystem consumer
The Ecosystem vcpkg Integration workflow validates that all 8 ecosystem ports install and build correctly as a consumer would experience them. It tests each port in bottom-up dependency order (Layer 0 through Layer 7) on Ubuntu and macOS, running on every PR that touches vcpkg ports and nightly at 03:00 UTC.
This common system serves as the foundational layer (Tier 0) that all other system modules build upon:
| Category | Document | Description |
|---|---|---|
| Guides | Quick Start | Get up and running in minutes |
| Best Practices | Recommended usage patterns | |
| FAQ | Frequently asked questions | |
| Troubleshooting | Common issues and solutions | |
| Advanced | Architecture | System design and principles |
| Migration | Version upgrade guide | |
| IExecutor Migration | Executor API migration | |
| Runtime Binding | Core design pattern | |
| Contributing | Contributing | How to contribute |
| Error Code Guidelines | Error code management |
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.
Made with care by the kcenon team