20 typename EventVariant,
22 typename SignalPolicy,
23 typename StoragePolicy,
24 typename OverflowPolicy,
25 typename TimerStoragePolicy,
26 typename ProfilerPolicy
37template <
typename Derived,
typename EventVariantOrBus = DefaultEvents, std::
size_t MaxServices = 8>
59 template <
typename Handler>
60 bool on(Handler&& handler)
68 template <
typename Filter,
typename Handler>
69 requires (std::is_invocable_r_v<bool, Filter&, const callable_event_type_t<Handler>&>)
70 bool on(Filter&& filter, Handler&& handler)
82 template <
typename Rep,
typename Period>
89 template <
typename Rep,
typename Period>
110 return _serviceRegistry;
116 return _serviceRegistry;
120 template <
typename ServiceType>
123 return _serviceRegistry.template getService<ServiceType>();
138 template <
typename Registry>
139 void configureServices(Registry& registry)
141 if constexpr (
requires(Derived& d, Registry& r) { d.onConfigureServices(r); }) {
142 static_cast<Derived*
>(
this)->onConfigureServices(registry);
146 void initializeServices(EventSinkT<EventVariant> sink)
148 configureServices(_serviceRegistry);
149 _serviceRegistry.
initialize(BasicServiceContext<EventVariant>{sink});
152 void shutdownServices() noexcept
157 void registerHandlers()
159 if constexpr (
requires(Derived& d) { d.onRegisterHandlers(); }) {
160 static_cast<Derived*
>(
this)->onRegisterHandlers();
166 if constexpr (
requires(Derived& d) { d.onInitialize(); }) {
167 static_cast<Derived*
>(
this)->onInitialize();
173 if constexpr (
requires(Derived& d) { d.onShutdown(); }) {
174 static_cast<Derived*
>(
this)->onShutdown();
178 void setContext(ApplicationContext<EventVariant> context)
181 if constexpr (
requires(Derived& d, ApplicationContext<EventVariant> c) { d.onSetContext(c); }) {
182 static_cast<Derived*
>(
this)->onSetContext(context);
186 void resetContext() noexcept
191 ApplicationContext<EventVariant> _context;
Type-erased context for application runtime introspection and lifecycle control.
Non-allocating type-erased fat pointer handle for lock-free event posting.
Fixed-capacity static container for background worker services.
Compile-time type index resolution for std::variant alternative types.
bool registerFilteredHandler(Filter &&filter, Handler &&handler)
Register a filtered event handler executed only when predicate evaluates to true.
Definition ApplicationContext.hpp:113
TimerId schedulePeriodic(EventVariant event, const std::chrono::duration< Rep, Period > &interval, EventPriority priority=EventPriority::Normal) const
Schedule a recurring periodic event with std::chrono duration.
Definition ApplicationContext.hpp:141
void reset() noexcept
Reset context state to empty.
Definition ApplicationContext.hpp:184
bool registerHandler(Handler &&handler)
Register an event handler into the application event bus.
Definition ApplicationContext.hpp:77
EventSinkT< EventVariant > eventSink() const noexcept
Access event sink handle.
Definition ApplicationContext.hpp:124
bool cancelTimer(TimerId id) const noexcept
Cancel an active timer.
Definition ApplicationContext.hpp:150
TimerId scheduleDelayed(EventVariant event, const std::chrono::duration< Rep, Period > &delay, EventPriority priority=EventPriority::Normal) const
Schedule a single-shot delayed event with std::chrono duration.
Definition ApplicationContext.hpp:131
void requestQuit() const
Request graceful application exit.
Definition ApplicationContext.hpp:159
void detachFromRuntime() noexcept
Detach application from runtime to prevent dangling callbacks on shutdown.
Definition ApplicationContext.hpp:174
Static CRTP base class for applications managed by Corium Runtime. Subclass Application<Derived> or A...
Definition Application.hpp:38
ServiceRegistryType & services() noexcept
Access background service registry.
Definition Application.hpp:108
void requestQuit()
Request graceful runtime shutdown.
Definition Application.hpp:102
EventSinkT< EventVariant > eventSink()
Access event sink handle.
Definition Application.hpp:76
TimerId postDelayed(EventVariant event, const std::chrono::duration< Rep, Period > &delay, EventPriority priority=EventPriority::Normal)
Schedule a single-shot delayed event.
Definition Application.hpp:83
const ServiceRegistryType & services() const noexcept
Access const background service registry.
Definition Application.hpp:114
Application(Application &&)=delete
ServiceType * getService() const noexcept
Retrieve registered background service by concrete type.
Definition Application.hpp:121
TimerId postPeriodic(EventVariant event, const std::chrono::duration< Rep, Period > &interval, EventPriority priority=EventPriority::Normal)
Schedule a recurring periodic event.
Definition Application.hpp:90
~Application()
Definition Application.hpp:45
bool on(Handler &&handler)
Register event handler with automatic event type deduction from callable signature.
Definition Application.hpp:60
Application & operator=(const Application &)=delete
bool cancelTimer(TimerId id) noexcept
Cancel an active timer.
Definition Application.hpp:96
internal::extract_event_variant_t< EventVariantOrBus > EventVariant
Definition Application.hpp:40
Application & operator=(Application &&)=delete
bool on(Filter &&filter, Handler &&handler)
Register a filtered event handler executed only when predicate evaluates to true.
Definition Application.hpp:70
Application(const Application &)=delete
BasicServiceRegistry< MaxServices, EventVariant > ServiceRegistryType
Definition Application.hpp:41
Corium Application Runtime managing MPSC event loops and static policy execution. Zero dynamic heap a...
Definition Runtime.hpp:48
Non-allocating ServiceRegistry storing service handles in a fixed stack/static array....
Definition ServiceRegistry.hpp:57
void shutdown() noexcept
Stop and join all registered background service threads.
Definition ServiceRegistry.hpp:165
void initialize(ServiceContextType ctx)
Initialize and launch all registered background service jthreads.
Definition ServiceRegistry.hpp:148
typename extract_event_variant< T >::type extract_event_variant_t
Definition VariantIndex.hpp:79
Definition Application.hpp:16
EventPriority
Event priority levels for multi-priority queue policies.
Definition QueuePolicies.hpp:32
uint32_t TimerId
Definition TimerScheduler.hpp:22