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

Event bus abstraction and common events. More...

#include <string>
#include <chrono>
#include <cstdint>
#include <functional>
#include <memory>
#include <mutex>
#include <atomic>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <typeinfo>
#include <typeindex>
#include <concepts>
#include <kcenon/common/concepts/event.h>
Include dependency graph for event_bus.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kcenon::common::detail::event_type_id< T >
 Generate unique type ID for each event type using std::type_index. More...
 
struct  kcenon::common::event
 Generic event structure for the event bus. More...
 
class  kcenon::common::simple_event_bus
 Simple synchronous event bus for testing when monitoring is disabled. More...
 
struct  kcenon::common::simple_event_bus::subscription_info
 
struct  kcenon::common::events::module_started_event
 Event published when a module starts. More...
 
struct  kcenon::common::events::module_stopped_event
 Event published when a module stops. More...
 
struct  kcenon::common::events::error_event
 Event published when an error occurs. More...
 
struct  kcenon::common::events::metric_event
 Event for publishing metrics. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::common
 Core interfaces.
 
namespace  kcenon::common::detail
 
namespace  kcenon::common::events
 

Typedefs

using kcenon::common::subscription_id = uint64_t
 Type alias for subscription ID.
 
using kcenon::common::event_bus = simple_event_bus
 
template<typename T >
using kcenon::common::event_handler = std::function<void(const T&)>
 

Enumerations

enum class  kcenon::common::event_priority { kcenon::common::low = 0 , kcenon::common::normal = 1 , kcenon::common::high = 2 }
 

Functions

simple_event_buskcenon::common::get_event_bus ()
 Access the global event bus instance.
 
constexpr int kcenon::common::detail::get_event_bus_abi_version ()
 Get the ABI version of the event_bus implementation.
 
bool kcenon::common::verify_event_bus_abi (int expected_version)
 Verify ABI compatibility between modules.
 

Variables

constexpr int kcenon::common::detail::event_bus_abi_version = 1
 

Detailed Description

Event bus abstraction and common events.

This header provides a standalone event bus implementation that can be used across modules without external dependencies. The simple_event_bus provides a thread-safe, synchronous publish/subscribe mechanism for inter-module communication.

Other systems (like monitoring_system) can extend or wrap this implementation if they need additional features like async processing or advanced filtering.

Example:

auto& bus = common::get_event_bus();
bus.publish(common::events::module_started_event{"network_system"});

Definition in file event_bus.h.