|
Common System 0.2.0
Common interfaces and patterns for system integration
|
Core interfaces. More...
Namespaces | |
| namespace | adapters |
| namespace | bootstrap |
| namespace | concepts |
| C++20 concepts for compile-time type validation. | |
| namespace | config |
| namespace | detail |
| namespace | di |
| namespace | error |
| namespace | error_codes |
| namespace | events |
| namespace | helpers |
| namespace | interfaces |
| namespace | logging |
| namespace | patterns |
| namespace | resilience |
| namespace | utils |
Classes | |
| class | common_error_category |
| Error category for common/shared error codes. More... | |
| struct | database_null |
| Represents NULL values in database results. More... | |
| struct | enum_traits |
| Primary template for enum traits (must be specialized for each enum) More... | |
| struct | enum_traits< interfaces::health_check_type > |
| Specialization of enum_traits for health_check_type. More... | |
| struct | enum_traits< interfaces::health_status > |
| Specialization of enum_traits for health_status. More... | |
| struct | enum_traits< interfaces::log_level > |
| Specialization of enum_traits for log_level. More... | |
| struct | enum_traits< interfaces::metric_type > |
| Specialization of enum_traits for metric_type. More... | |
| class | error_category |
| Abstract base class for error code categories. More... | |
| struct | error_info |
| Standard error information used by Result<T>. More... | |
| struct | event |
| Generic event structure for the event bus. More... | |
| class | exception_mapper |
| Maps standard exception types to appropriate error codes. More... | |
| struct | module_version |
| Version information for common_system module. More... | |
| class | Option |
| class | Optional |
| Optional type similar to std::optional with Rust-like API. More... | |
| class | Result |
| Result type for error handling with member function support. More... | |
| class | simple_event_bus |
| Simple synchronous event bus for testing when monitoring is disabled. More... | |
| struct | source_location |
| C++17-compatible source_location implementation using compiler builtins. More... | |
| class | typed_error_code |
| A type-safe error code that carries its category. More... | |
| struct | version_info |
| Version information for Common System. More... | |
Concepts | |
| concept | EnumSerializable |
| Concept to check if an enum has valid traits defined. | |
Typedefs | |
| using | database_value = std::variant<database_null, std::string, std::int64_t, double, bool> |
| Variant type for database column values. | |
| using | database_row = std::map<std::string, database_value> |
| Map of column names to values representing a database row. | |
| using | database_result = std::vector<database_row> |
| Vector of rows representing a complete query result set. | |
| using | subscription_id = uint64_t |
| Type alias for subscription ID. | |
| using | event_bus = simple_event_bus |
| template<typename T > | |
| using | event_handler = std::function<void(const T&)> |
| using | kcenon::common::VoidResult = Result<std::monostate> |
| Specialized Result for void operations. | |
Enumerations | |
| enum class | event_priority { low = 0 , normal = 1 , high = 2 } |
| enum class | result_state { uninitialized , ok , error , uninitialized , ok , error } |
| Result state enum for tracking initialization. More... | |
| enum class | kcenon::common::result_state { uninitialized , ok , error , uninitialized , ok , error } |
| Result state enum for tracking initialization. More... | |
Functions | |
| typed_error_code | make_typed_error_code (common_error_category::codes code) noexcept |
| Creates a typed_error_code from common_error_category::codes enum. | |
| template<typename Category > | |
| typed_error_code | make_typed_error_code (int code) noexcept |
| Creates a typed_error_code from a code value and category. | |
| bool | is_success (const typed_error_code &ec) noexcept |
| Checks if a typed_error_code represents success (no error). | |
| bool | is_error (const typed_error_code &ec) noexcept |
| Checks if a typed_error_code represents an error. | |
| simple_event_bus & | get_event_bus () |
| Access the global event bus instance. | |
| bool | verify_event_bus_abi (int expected_version) |
| Verify ABI compatibility between modules. | |
| template<typename T > | |
| Optional< T > | kcenon::common::Some (T value) |
| Create an Optional with value. | |
| template<typename T > | |
| Optional< T > | kcenon::common::None () |
| Create an empty Optional. | |
| template<typename T > | |
| Result< T > | kcenon::common::ok (T value) |
| Create a successful result. | |
| VoidResult | kcenon::common::ok () |
| Create a successful void result. | |
| template<typename T > | |
| Result< T > | kcenon::common::make_error (int code, const std::string &message, const std::string &module="") |
| Create an error result with code and message. | |
| template<typename T > | |
| Result< T > | kcenon::common::make_error (int code, const std::string &message, const std::string &module, const std::string &details) |
| Create an error result with details. | |
| template<typename T > | |
| Result< T > | kcenon::common::make_error (const error_info &err) |
| Create an error result from existing error_info. | |
| template<typename T , typename F > | |
| Result< T > | kcenon::common::try_catch (F &&func, const std::string &module="") |
| Convert exception to Result with automatic error code mapping. | |
| template<typename F > | |
| VoidResult | kcenon::common::try_catch_void (F &&func, const std::string &module="") |
| Convert exception to VoidResult with automatic error code mapping. | |
| template<EnumSerializable Enum> | |
| std::string | enum_to_string (Enum value) |
| Convert an enum value to its string representation. | |
| template<EnumSerializable Enum> | |
| Result< Enum > | enum_from_string (std::string_view str) |
| Convert a string to its enum value (case-insensitive) | |
| VoidResult | kcenon::common::err (const error_info &error) |
| Factory function to create error VoidResult. | |
| VoidResult | kcenon::common::err (int code, const std::string &message, const std::string &module="") |
| Factory function to create error VoidResult. | |
Core interfaces.
Unified logging (Issue #175) Bootstrap (Issue #176) Common patterns Common utilities
| using kcenon::common::database_result = std::vector<database_row> |
Vector of rows representing a complete query result set.
Definition at line 51 of file database_interface.h.
| using kcenon::common::database_row = std::map<std::string, database_value> |
Map of column names to values representing a database row.
Definition at line 45 of file database_interface.h.
| using kcenon::common::database_value = std::variant<database_null, std::string, std::int64_t, double, bool> |
Variant type for database column values.
Supports NULL, string, 64-bit integer, double, and boolean types.
Definition at line 39 of file database_interface.h.
Definition at line 443 of file event_bus.h.
| using kcenon::common::event_handler = std::function<void(const T&)> |
Definition at line 446 of file event_bus.h.
| using kcenon::common::subscription_id = uint64_t |
Type alias for subscription ID.
Definition at line 105 of file event_bus.h.
|
export |
Specialized Result for void operations.
Forward declaration of VoidResult typedef. Full definition in void_result.h.
|
strong |
| Enumerator | |
|---|---|
| low | |
| normal | |
| high | |
Definition at line 96 of file event_bus.h.
|
strong |
Result state enum for tracking initialization.
| Enumerator | |
|---|---|
| uninitialized | |
| ok | |
| error | |
| uninitialized | Result has not been initialized with a value or error. |
| ok | Result contains a valid value. |
| error | Result contains an error. |
Definition at line 58 of file core.h.
|
exportstrong |
|
inlinenodiscard |
Convert a string to its enum value (case-insensitive)
| Enum | The enum type (must satisfy EnumSerializable concept) |
| str | The string to convert |
Definition at line 93 of file enum_serialization.h.
References kcenon::common::Result< T >::err(), and kcenon::common::Result< T >::ok().
Referenced by kcenon::common::interfaces::from_string(), kcenon::common::interfaces::health_check_type_from_string(), and kcenon::common::interfaces::metric_type_from_string().


|
inlinenodiscard |
Convert an enum value to its string representation.
| Enum | The enum type (must satisfy EnumSerializable concept) |
| value | The enum value to convert |
Definition at line 76 of file enum_serialization.h.
Referenced by kcenon::common::interfaces::to_string(), kcenon::common::interfaces::to_string(), kcenon::common::interfaces::to_string(), and kcenon::common::interfaces::to_string().

|
inlineexport |
Factory function to create error VoidResult.
| error | The error information |
Definition at line 432 of file core.cppm.
Referenced by mock_executor::execute(), mock_executor::execute_delayed(), main(), and make_error().

|
inlineexport |
|
inline |
Access the global event bus instance.
Definition at line 452 of file event_bus.h.
References kcenon::common::simple_event_bus::instance().
Referenced by main().


|
inlinenoexcept |
Checks if a typed_error_code represents an error.
| ec | The error code to check |
Definition at line 428 of file error_category.h.
|
inlinenoexcept |
Checks if a typed_error_code represents success (no error).
| ec | The error code to check |
Definition at line 418 of file error_category.h.
|
inlineexport |
Create an error result from existing error_info.
Definition at line 110 of file utilities.h.
References err().

|
inlineexport |
Create an error result with details.
Definition at line 100 of file utilities.h.
|
inlineexport |
Create an error result with code and message.
| code | Error code |
| message | Error message |
| module | Optional module name |
Example:
| code | Error code |
| message | Error message |
| module | Optional module name |
Definition at line 91 of file utilities.h.
Referenced by kcenon::common::config::cli_config_parser::apply_override(), kcenon::common::di::service_container::check_already_registered(), kcenon::common::di::service_container::check_frozen_for_registration(), kcenon::common::di::service_container::clear(), divide(), divide(), kcenon::common::config::config_watcher::do_reload(), kcenon::common::config::config_watcher::init_platform_watcher(), kcenon::common::bootstrap::SystemBootstrapper::initialize(), kcenon::common::di::service_container::invoke_factory_safe(), kcenon::common::config::config_loader::load(), kcenon::common::config::config_loader::load_from_env(), kcenon::common::config::config_loader::load_from_string(), kcenon::common::config::cli_config_parser::load_with_cli_overrides(), main(), kcenon::common::config::cli_config_parser::parse(), parse_and_compute(), kcenon::common::config::cli_config_parser::parse_key_value(), read_file(), kcenon::common::interfaces::GlobalLoggerRegistry::register_factory(), kcenon::common::di::IServiceContainer::register_instance(), kcenon::common::interfaces::GlobalLoggerRegistry::register_logger(), kcenon::common::bootstrap::SystemBootstrapper::register_loggers(), kcenon::common::di::unified_bootstrapper::register_module(), kcenon::common::di::unified_bootstrapper::register_optional_services(), kcenon::common::di::unified_bootstrapper::register_shutdown_hook(), register_user(), kcenon::common::di::IServiceContainer::resolve(), kcenon::common::di::service_container::resolve_with_detection(), kcenon::common::config::config_watcher::rollback(), kcenon::common::interfaces::GlobalLoggerRegistry::set_default_factory(), kcenon::common::interfaces::GlobalLoggerRegistry::set_default_logger(), kcenon::common::di::unified_bootstrapper::shutdown(), kcenon::common::config::config_watcher::start(), kcenon::common::di::service_container::unregister_internal(), kcenon::common::interfaces::GlobalLoggerRegistry::unregister_logger(), kcenon::common::di::unified_bootstrapper::unregister_module(), kcenon::common::di::unified_bootstrapper::unregister_shutdown_hook(), and kcenon::common::config::config_loader::validate().

|
inlinenoexcept |
Creates a typed_error_code from common_error_category::codes enum.
| code | Common error code enum value |
Definition at line 396 of file error_category.h.
References kcenon::common::common_error_category::instance().

|
noexcept |
Creates a typed_error_code from a code value and category.
| Category | The error category type (must have instance() method) |
| code | Error code value |
Definition at line 408 of file error_category.h.
|
inlineexport |
Create an empty Optional.
|
inlineexport |
Create a successful void result.
Factory function to create successful VoidResult.
Example:
Definition at line 71 of file utilities.h.
Referenced by kcenon::common::interfaces::health_dependency_graph::add_dependency(), kcenon::common::interfaces::health_dependency_graph::add_node(), kcenon::common::interfaces::health_check_builder::build(), kcenon::common::interfaces::health_dependency_graph::check_with_dependencies_internal(), divide(), divide(), mock_executor::execute(), mock_executor::execute_delayed(), kcenon::common::logging::ConsoleLogger::flush(), kcenon::common::di::service_container::invoke_factory_safe(), kcenon::common::logging::ConsoleLogger::log(), kcenon::common::logging::ConsoleLogger::log(), main(), kcenon::common::config::cli_config_parser::parse_key_value(), read_file(), register_user(), kcenon::common::interfaces::health_dependency_graph::remove_dependency(), kcenon::common::interfaces::health_dependency_graph::remove_node(), kcenon::common::di::IServiceContainer::resolve(), kcenon::common::di::service_container::resolve_with_detection(), kcenon::common::logging::ConsoleLogger::set_level(), kcenon::common::interfaces::health_monitor::start(), kcenon::common::interfaces::health_monitor::stop(), kcenon::common::interfaces::health_dependency_graph::topological_sort(), try_catch(), and try_catch_void().

|
inlineexport |
Create a successful result.
Create a successful result with a value.
| value | The value to wrap |
Example:
| value | The value to wrap |
Definition at line 54 of file utilities.h.
|
inlineexport |
Create an Optional with value.
|
export |
Convert exception to Result with automatic error code mapping.
Enhanced version that automatically assigns appropriate error codes based on exception type, providing better error diagnostics. Uses multiple catch blocks instead of RTTI for better performance.
| T | Return type |
| F | Callable type |
| func | Callable to execute |
| module | Module name for error context |
Example:
| T | Return type |
| F | Callable type |
| func | Callable to execute |
| module | Module name for error context |
Definition at line 173 of file utilities.h.
References kcenon::common::error_codes::INTERNAL_ERROR, kcenon::common::error_codes::INVALID_ARGUMENT, kcenon::common::exception_mapper::map_generic_exception(), kcenon::common::exception_mapper::map_unknown_exception(), ok(), and kcenon::common::error_codes::OUT_OF_MEMORY.
Referenced by main().


|
export |
Convert exception to VoidResult with automatic error code mapping.
Specialization for void return type. Uses multiple catch blocks instead of RTTI for better performance.
| F | Callable type |
| func | Callable to execute (returns void) |
| module | Module name for error context |
| F | Callable type |
| func | Callable to execute (returns void) |
| module | Module name for error context |
Definition at line 224 of file utilities.h.
References kcenon::common::error_codes::INTERNAL_ERROR, kcenon::common::error_codes::INVALID_ARGUMENT, kcenon::common::exception_mapper::map_generic_exception(), kcenon::common::exception_mapper::map_unknown_exception(), ok(), and kcenon::common::error_codes::OUT_OF_MEMORY.

|
inline |
Verify ABI compatibility between modules.
Call this function during initialization to verify that all linked modules were compiled with the same event_bus configuration. This helps catch subtle bugs caused by mixing object files compiled with different settings.
| expected_version | The ABI version your module expects |
Example usage:
Definition at line 493 of file event_bus.h.
References kcenon::common::detail::get_event_bus_abi_version().
