Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::ApplicationContext< EventVariant > Class Template Reference

Context object passed to Application providing event registration, sink access, quit requests, and timer scheduling. Completely encapsulates EventBus and Reactor internals. More...

#include <ApplicationContext.hpp>

+ Inheritance diagram for corium::ApplicationContext< EventVariant >:
+ Collaboration diagram for corium::ApplicationContext< EventVariant >:

Public Types

using CancelTimerFn = bool(*)(void *ptr, TimerId id)
 
using EventVariantType = EventVariant
 
using ScheduleDelayedFn = TimerId(*)(void *ptr, EventVariant event, std::chrono::microseconds delay, EventPriority priority)
 
using SchedulePeriodicFn = TimerId(*)(void *ptr, EventVariant event, std::chrono::microseconds interval, EventPriority priority)
 

Public Member Functions

 ApplicationContext ()=default
 
template<typename EventBusType >
 ApplicationContext (EventBusType &events, StaticCallback quitCallback)
 
bool cancelTimer (TimerId id) const noexcept
 Cancel an active timer.
 
void detachFromRuntime () noexcept
 Detach application from runtime to prevent dangling callbacks on shutdown.
 
EventSinkT< EventVariant > eventSink () const noexcept
 Access event sink handle.
 
 operator bool () const noexcept
 
template<typename Filter , typename Handler >
bool registerFilteredHandler (Filter &&filter, Handler &&handler)
 Register a filtered event handler executed only when predicate evaluates to true.
 
template<typename Handler >
bool registerHandler (Handler &&handler)
 Register an event handler into the application event bus.
 
void requestQuit () const
 Request graceful application exit.
 
void reset () noexcept
 Reset context state to empty.
 
template<typename Rep , typename Period >
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.
 
template<typename Rep , typename Period >
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.
 
void setRuntimeDetach (void *runtimePtr, void(*detachFn)(void *) noexcept) noexcept
 Attach runtime detachment handle.
 
template<typename Scheduler >
void setTimerScheduler (Scheduler &scheduler) noexcept
 

Detailed Description

template<typename EventVariant = DefaultEvents>
class corium::ApplicationContext< EventVariant >

Context object passed to Application providing event registration, sink access, quit requests, and timer scheduling. Completely encapsulates EventBus and Reactor internals.

Template Parameters
EventVariantSupported event variant list type (defaults to DefaultEvents).

Member Typedef Documentation

◆ CancelTimerFn

template<typename EventVariant = DefaultEvents>
using corium::ApplicationContext< EventVariant >::CancelTimerFn = bool (*)(void* ptr, TimerId id)

◆ EventVariantType

template<typename EventVariant = DefaultEvents>
using corium::ApplicationContext< EventVariant >::EventVariantType = EventVariant

◆ ScheduleDelayedFn

template<typename EventVariant = DefaultEvents>
using corium::ApplicationContext< EventVariant >::ScheduleDelayedFn = TimerId (*)(void* ptr, EventVariant event, std::chrono::microseconds delay, EventPriority priority)

◆ SchedulePeriodicFn

template<typename EventVariant = DefaultEvents>
using corium::ApplicationContext< EventVariant >::SchedulePeriodicFn = TimerId (*)(void* ptr, EventVariant event, std::chrono::microseconds interval, EventPriority priority)

Constructor & Destructor Documentation

◆ ApplicationContext() [1/2]

template<typename EventVariant = DefaultEvents>
corium::ApplicationContext< EventVariant >::ApplicationContext ( )
default

◆ ApplicationContext() [2/2]

template<typename EventVariant = DefaultEvents>
template<typename EventBusType >
corium::ApplicationContext< EventVariant >::ApplicationContext ( EventBusType &  events,
StaticCallback  quitCallback 
)
inline

Member Function Documentation

◆ cancelTimer()

template<typename EventVariant = DefaultEvents>
bool corium::ApplicationContext< EventVariant >::cancelTimer ( TimerId  id) const
inlinenoexcept

Cancel an active timer.

+ Here is the caller graph for this function:

◆ detachFromRuntime()

template<typename EventVariant = DefaultEvents>
void corium::ApplicationContext< EventVariant >::detachFromRuntime ( )
inlinenoexcept

Detach application from runtime to prevent dangling callbacks on shutdown.

+ Here is the caller graph for this function:

◆ eventSink()

template<typename EventVariant = DefaultEvents>
EventSinkT< EventVariant > corium::ApplicationContext< EventVariant >::eventSink ( ) const
inlinenoexcept

Access event sink handle.

+ Here is the caller graph for this function:

◆ operator bool()

template<typename EventVariant = DefaultEvents>
corium::ApplicationContext< EventVariant >::operator bool ( ) const
inlineexplicitnoexcept

◆ registerFilteredHandler()

template<typename EventVariant = DefaultEvents>
template<typename Filter , typename Handler >
bool corium::ApplicationContext< EventVariant >::registerFilteredHandler ( Filter &&  filter,
Handler &&  handler 
)
inline

Register a filtered event handler executed only when predicate evaluates to true.

Template Parameters
FilterCallable returning bool when passed the event.
HandlerCallable accepting const EventType&.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerHandler()

template<typename EventVariant = DefaultEvents>
template<typename Handler >
bool corium::ApplicationContext< EventVariant >::registerHandler ( Handler &&  handler)
inline

Register an event handler into the application event bus.

+ Here is the caller graph for this function:

◆ requestQuit()

template<typename EventVariant = DefaultEvents>
void corium::ApplicationContext< EventVariant >::requestQuit ( ) const
inline

Request graceful application exit.

+ Here is the caller graph for this function:

◆ reset()

template<typename EventVariant = DefaultEvents>
void corium::ApplicationContext< EventVariant >::reset ( )
inlinenoexcept

Reset context state to empty.

◆ scheduleDelayed()

template<typename EventVariant = DefaultEvents>
template<typename Rep , typename Period >
TimerId corium::ApplicationContext< EventVariant >::scheduleDelayed ( EventVariant  event,
const std::chrono::duration< Rep, Period > &  delay,
EventPriority  priority = EventPriority::Normal 
) const
inline

Schedule a single-shot delayed event with std::chrono duration.

+ Here is the caller graph for this function:

◆ schedulePeriodic()

template<typename EventVariant = DefaultEvents>
template<typename Rep , typename Period >
TimerId corium::ApplicationContext< EventVariant >::schedulePeriodic ( EventVariant  event,
const std::chrono::duration< Rep, Period > &  interval,
EventPriority  priority = EventPriority::Normal 
) const
inline

Schedule a recurring periodic event with std::chrono duration.

+ Here is the caller graph for this function:

◆ setRuntimeDetach()

template<typename EventVariant = DefaultEvents>
void corium::ApplicationContext< EventVariant >::setRuntimeDetach ( void *  runtimePtr,
void(*)(void *) noexcept  detachFn 
)
inlinenoexcept

Attach runtime detachment handle.

◆ setTimerScheduler()

template<typename EventVariant = DefaultEvents>
template<typename Scheduler >
void corium::ApplicationContext< EventVariant >::setTimerScheduler ( Scheduler &  scheduler)
inlinenoexcept
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: