Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::kernel::RunApi Class Reference

What can be done while a component is running. More...

#include <component_api.h>

Inheritance diagram for sen::kernel::RunApi:

Public Member Functions

 RunApi (Kernel &kernel, impl::KernelImpl &kernelImpl, impl::Runner *runner, std::atomic_bool &stopRequested, const VarMap &config, Guarded< TimeStamp > &timePoint) noexcept
 ~RunApi () noexcept=default
const std::atomic_bool & stopRequested () const noexcept
 True if stop has been requested by the runtime.
void drainInputs ()
 Perform any request coming from the outside and drainInputs all the local data structures with their most up-to-date value. This method is thread-safe.
void update ()
 This calls update() on all the objects registered by the component.
void commit ()
 Send changes, so that they become visible to other participants. This includes object additions and removals, property changes and emitted events that others might have interest in. This method is thread-safe.
FuncResult execLoop (Duration cycleTime, std::function< void()> &&func=nullptr, bool logOverruns=true)
 A basic execution loop. Func is an optional callback that will be invoked on each cycle.
TimeStamp getStartTime () const noexcept
 The initial simulation time for the objects in the component.
TimeStamp getTime () const noexcept
 The (potentially virtualized) time.
std::optional< DurationgetTargetCycleTime () const noexcept
 If present, it returns the configured cycle time for iterations.
KernelMonitoringInfo fetchMonitoringInfo () const
 Monitoring information.
Span< const ComponentInfo > getImportedPackages () const noexcept
 Build information for all imported packages (from pipeline components). The returned span references kernel-owned storage that is stable for the lifetime of the kernel.
Span< const ComponentInfo > getLoadedComponents () const noexcept
 Build information for every component loaded into the kernel, excluding pipeline components (which are built from imports and have no individual build identity) and the internal kernel component. The returned span references kernel-owned storage that is stable for the lifetime of the kernel.
std::optional< uint32_t > getTransportProtocolVersion () const noexcept
 Version of the currently installed transport protocol. Empty when no transport is installed. Static for the lifetime of the kernel.
TracergetTracer () const noexcept
 Create a scoped zone used for tracing runtime performance.
const VarMapgetConfig () const noexcept
 Gets the configuration associated with this component.
CustomTypeRegistrygetTypes () noexcept
 The types registered into the kernel.
void requestKernelStop (int exitCode=0)
 Issues an asynchronous request to stop the kernel. The request is ignored if a previous stop request was issued.
std::shared_ptr< ObjectSourcegetSource (const BusAddress &address)
 Gets an object source, where objects can be found and published.
std::shared_ptr< ObjectSourcegetSource (const std::string &address)
 Gets an object source, where objects can be found and published. The address parameter must be given as <session-name>.<bus-name>.
SessionsDiscoverergetSessionsDiscoverer () noexcept
 Object that allows discovering sessions and buses.
const ProcessInfo * fetchOwnerInfo (const Object *object) const noexcept
 Gets information about the process where an object is. Returns nullptr if the object resides in the current process.
const std::string & getAppName () const noexcept
 Gets the (optional) application name passed to the kernel as a configuration parameter.
::sen::impl::WorkQueue * getWorkQueue () const noexcept
 The work queue of this runner.
template<typename T, typename Bus>
std::shared_ptr< Subscription< T > > selectAllFrom (const Bus &bus)
template<typename T, typename Bus>
std::shared_ptr< Subscription< T > > selectAllFrom (const Bus &bus, typename sen::ObjectList< T >::Callback onAdded, typename sen::ObjectList< T >::Callback onRemoved=nullptr)
 Overload of selectAllFrom that installs addition and removal callbacks before subscribing, so they fire for objects already present at subscription time. Pass nullptr for either callback to skip it.
template<typename T, typename Bus>
std::shared_ptr< Subscription< T > > selectFrom (const Bus &bus, const std::string &query, typename sen::ObjectList< T >::Callback onAdded=nullptr, typename sen::ObjectList< T >::Callback onRemoved=nullptr)
 Creates a subscription for objects matching the given Sen query string. Unlike selectAllFrom, this lets you supply an arbitrary query with WHERE conditions. Example: selectFrom<Shape>(bus, "SELECT Shape FROM local.bus WHERE color IN (\"red\")"). It installs addition and removal callbacks before subscribing. Pass nullptr for either callback to skip it.
std::filesystem::path getConfigFilePath () const noexcept
 Gets the path to the configuration file used to construct the kernel. It might be empty if the kernel is programmatically configured.

Friends

void impl::remoteProcessDetected (RunApi &api, const ProcessInfo &processInfo)
void impl::remoteProcessLost (RunApi &api, const ProcessInfo &processInfo)

Detailed Description

What can be done while a component is running.

Constructor & Destructor Documentation

◆ RunApi()

sen::kernel::RunApi::RunApi ( Kernel & kernel,
impl::KernelImpl & kernelImpl,
impl::Runner * runner,
std::atomic_bool & stopRequested,
const VarMap & config,
Guarded< TimeStamp > & timePoint )
noexcept

◆ ~RunApi()

sen::kernel::RunApi::~RunApi ( )
defaultnoexcept

Member Function Documentation

◆ stopRequested()

const std::atomic_bool & sen::kernel::RunApi::stopRequested ( ) const
nodiscardnoexcept

True if stop has been requested by the runtime.

◆ drainInputs()

void sen::kernel::RunApi::drainInputs ( )

Perform any request coming from the outside and drainInputs all the local data structures with their most up-to-date value. This method is thread-safe.

◆ update()

void sen::kernel::RunApi::update ( )

This calls update() on all the objects registered by the component.

◆ commit()

void sen::kernel::RunApi::commit ( )

Send changes, so that they become visible to other participants. This includes object additions and removals, property changes and emitted events that others might have interest in. This method is thread-safe.

◆ execLoop()

FuncResult sen::kernel::RunApi::execLoop ( Duration cycleTime,
std::function< void()> && func = nullptr,
bool logOverruns = true )
nodiscard

A basic execution loop. Func is an optional callback that will be invoked on each cycle.

◆ getStartTime()

TimeStamp sen::kernel::RunApi::getStartTime ( ) const
nodiscardnoexcept

The initial simulation time for the objects in the component.

◆ getTime()

TimeStamp sen::kernel::RunApi::getTime ( ) const
nodiscardnoexcept

The (potentially virtualized) time.

◆ getTargetCycleTime()

std::optional< Duration > sen::kernel::RunApi::getTargetCycleTime ( ) const
nodiscardnoexcept

If present, it returns the configured cycle time for iterations.

◆ fetchMonitoringInfo()

KernelMonitoringInfo sen::kernel::RunApi::fetchMonitoringInfo ( ) const
nodiscard

Monitoring information.

◆ getImportedPackages()

Span< const ComponentInfo > sen::kernel::RunApi::getImportedPackages ( ) const
nodiscardnoexcept

Build information for all imported packages (from pipeline components). The returned span references kernel-owned storage that is stable for the lifetime of the kernel.

◆ getLoadedComponents()

Span< const ComponentInfo > sen::kernel::RunApi::getLoadedComponents ( ) const
nodiscardnoexcept

Build information for every component loaded into the kernel, excluding pipeline components (which are built from imports and have no individual build identity) and the internal kernel component. The returned span references kernel-owned storage that is stable for the lifetime of the kernel.

◆ getTransportProtocolVersion()

std::optional< uint32_t > sen::kernel::RunApi::getTransportProtocolVersion ( ) const
nodiscardnoexcept

Version of the currently installed transport protocol. Empty when no transport is installed. Static for the lifetime of the kernel.

◆ getTracer()

Tracer & sen::kernel::RunApi::getTracer ( ) const
nodiscardnoexcept

Create a scoped zone used for tracing runtime performance.

◆ getConfig()

const VarMap & sen::kernel::ConfigGetter::getConfig ( ) const
nodiscardnoexceptinherited

Gets the configuration associated with this component.

◆ getTypes()

CustomTypeRegistry & sen::kernel::KernelApi::getTypes ( )
nodiscardnoexceptinherited

The types registered into the kernel.

◆ requestKernelStop()

void sen::kernel::KernelApi::requestKernelStop ( int exitCode = 0)
inherited

Issues an asynchronous request to stop the kernel. The request is ignored if a previous stop request was issued.

◆ getSource() [1/2]

std::shared_ptr< ObjectSource > sen::kernel::KernelApi::getSource ( const BusAddress & address)
nodiscardinherited

Gets an object source, where objects can be found and published.

◆ getSource() [2/2]

std::shared_ptr< ObjectSource > sen::kernel::KernelApi::getSource ( const std::string & address)
nodiscardinherited

Gets an object source, where objects can be found and published. The address parameter must be given as <session-name>.<bus-name>.

◆ getSessionsDiscoverer()

SessionsDiscoverer & sen::kernel::KernelApi::getSessionsDiscoverer ( )
nodiscardnoexceptinherited

Object that allows discovering sessions and buses.

◆ fetchOwnerInfo()

const ProcessInfo * sen::kernel::KernelApi::fetchOwnerInfo ( const Object * object) const
nodiscardnoexceptinherited

Gets information about the process where an object is. Returns nullptr if the object resides in the current process.

◆ getAppName()

const std::string & sen::kernel::KernelApi::getAppName ( ) const
nodiscardnoexceptinherited

Gets the (optional) application name passed to the kernel as a configuration parameter.

◆ getWorkQueue()

::sen::impl::WorkQueue * sen::kernel::KernelApi::getWorkQueue ( ) const
nodiscardnoexceptinherited

The work queue of this runner.

◆ selectAllFrom() [1/2]

template<typename T, typename Bus>
std::shared_ptr< Subscription< T > > sen::kernel::KernelApi::selectAllFrom ( const Bus & bus)
inlinenodiscardinherited

◆ selectAllFrom() [2/2]

template<typename T, typename Bus>
std::shared_ptr< Subscription< T > > sen::kernel::KernelApi::selectAllFrom ( const Bus & bus,
typename sen::ObjectList< T >::Callback onAdded,
typename sen::ObjectList< T >::Callback onRemoved = nullptr )
inlinenodiscardinherited

Overload of selectAllFrom that installs addition and removal callbacks before subscribing, so they fire for objects already present at subscription time. Pass nullptr for either callback to skip it.

◆ selectFrom()

template<typename T, typename Bus>
std::shared_ptr< Subscription< T > > sen::kernel::KernelApi::selectFrom ( const Bus & bus,
const std::string & query,
typename sen::ObjectList< T >::Callback onAdded = nullptr,
typename sen::ObjectList< T >::Callback onRemoved = nullptr )
inlinenodiscardinherited

Creates a subscription for objects matching the given Sen query string. Unlike selectAllFrom, this lets you supply an arbitrary query with WHERE conditions. Example: selectFrom<Shape>(bus, "SELECT Shape FROM local.bus WHERE color IN (\"red\")"). It installs addition and removal callbacks before subscribing. Pass nullptr for either callback to skip it.

◆ getConfigFilePath()

std::filesystem::path sen::kernel::KernelApi::getConfigFilePath ( ) const
inlinenodiscardnoexceptinherited

Gets the path to the configuration file used to construct the kernel. It might be empty if the kernel is programmatically configured.

◆ impl::remoteProcessDetected

void impl::remoteProcessDetected ( RunApi & api,
const ProcessInfo & processInfo )
friend

◆ impl::remoteProcessLost

void impl::remoteProcessLost ( RunApi & api,
const ProcessInfo & processInfo )
friend

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