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

What can be done when loading a component. More...

#include <component_api.h>

Inheritance diagram for sen::kernel::LoadApi:

Public Member Functions

 LoadApi (Kernel &kernel, impl::Runner *runner, const VarMap &config) noexcept
 ~LoadApi () noexcept=default
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)
 Subscribe to every object of type T on bus. The returned Subscription owns the kernel-side wiring; destruct it to stop.
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)
 As above, plus addition/removal callbacks installed before subscribing so they fire for objects already present. Pass nullptr to skip either.
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)
 Subscription against an arbitrary Sen query (with WHERE conditions). Example: selectFrom<Shape>(bus, R"(SELECT Shape FROM local.bus WHERE color IN ("red"))"). Installs the callbacks before subscribing. Pass nullptr to skip either.
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.

Static Public Member Functions

static std::shared_ptr< spdlog::logger > getOrCreateLogger (const std::string &loggerName)
 Registers a new logger in the kernel if it does not exist, or returns the existing one by name. Used to propagate the logger configuration to other packages/components that use it.
static void applyToAllLoggers (std::function< void(std::shared_ptr< spdlog::logger >)> &&func)
 Applies the input function to all loggers kept in the logger registry. Used by the logmaster component.

Detailed Description

What can be done when loading a component.

Constructor & Destructor Documentation

◆ LoadApi()

sen::kernel::LoadApi::LoadApi ( Kernel & kernel,
impl::Runner * runner,
const VarMap & config )
noexcept

◆ ~LoadApi()

sen::kernel::LoadApi::~LoadApi ( )
defaultnoexcept

Member Function Documentation

◆ 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

Subscribe to every object of type T on bus. The returned Subscription owns the kernel-side wiring; destruct it to stop.

Callback lifetime (this overload, the next, and selectFrom): onAdded / onRemoved fire on the kernel's run() thread between subscribe and the Subscription's destruction. References they capture must outlive the Subscription. Capture state by shared_ptr or via a component member.

◆ 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

As above, plus addition/removal callbacks installed before subscribing so they fire for objects already present. Pass nullptr to skip either.

◆ 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

Subscription against an arbitrary Sen query (with WHERE conditions). Example: selectFrom<Shape>(bus, R"(SELECT Shape FROM local.bus WHERE color IN ("red"))"). Installs the callbacks before subscribing. Pass nullptr to skip either.

◆ 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.

◆ getOrCreateLogger()

std::shared_ptr< spdlog::logger > sen::kernel::KernelApi::getOrCreateLogger ( const std::string & loggerName)
staticnodiscardinherited

Registers a new logger in the kernel if it does not exist, or returns the existing one by name. Used to propagate the logger configuration to other packages/components that use it.

◆ applyToAllLoggers()

void sen::kernel::KernelApi::applyToAllLoggers ( std::function< void(std::shared_ptr< spdlog::logger >)> && func)
staticinherited

Applies the input function to all loggers kept in the logger registry. Used by the logmaster component.


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