8#ifndef SEN_KERNEL_COMPONENT_H
9#define SEN_KERNEL_COMPONENT_H
89#define SEN_COMPONENT_MAKER senMakeKernelComponent
90#define SEN_COMPONENT_INFO_MAKER senMakeKernelComponentInfo
104#if defined(DEBUG) || defined(_DEBUG)
113 if constexpr (
sizeof(size_t) == 4U)
115 return WordSize::bits32;
119 return WordSize::bits64;
127[[nodiscard]] SEN_PRIVATE
const char*
getGitRef() noexcept;
143#define SEN_COMPONENT(component_name) \
145 extern "C" SEN_EXPORT sen::kernel::Component* SEN_COMPONENT_MAKER() \
147 return new component_name(); \
150 extern "C" SEN_EXPORT const sen::kernel::ComponentInfo* SEN_COMPONENT_INFO_MAKER() \
152 static sen::kernel::ComponentInfo info {}; \
153 info.name = SEN_TARGET_NAME; \
154 info.description = SEN_TARGET_DESCRIPTION; \
155 info.buildInfo.maintainer = SEN_TARGET_MAINTAINER; \
156 info.buildInfo.version = SEN_TARGET_VERSION; \
157 info.buildInfo.compiler = SEN_COMPILER_STRING; \
158 info.buildInfo.debugMode = sen::kernel::getDebugEnabled(); \
159 info.buildInfo.wordSize = sen::kernel::getWordSize(); \
160 info.buildInfo.buildTime = sen::kernel::getBuildTime(); \
161 info.buildInfo.gitRef = sen::kernel::getGitRef(); \
162 info.buildInfo.gitHash = sen::kernel::getGitHash(); \
163 info.buildInfo.gitStatus = sen::kernel::getGitStatus(); \
A time duration.
Definition duration.h:25
Base class for implementing sen kernel components.
Definition component.h:34
virtual void postUnloadCleanup()
Do an additional (and final) clean up step after unloading the component. This function is just calle...
Definition component.h:69
virtual FuncResult run(RunApi &)
Runs the component in a dedicated thread. This function is called once and only when the kernel has r...
Definition component.h:61
virtual FuncResult preload(PreloadApi &&)
Preload the component and initialize all self-contained resources. This function is just called once.
Definition component.h:45
virtual FuncResult load(LoadApi &&)
Load the component and initialize all self-contained resources. This function is just called once.
Definition component.h:49
virtual bool isRealTimeOnly() const noexcept
Return true here if your component is not designed to work with virtualized time.
Definition component.h:72
virtual PassResult init(InitApi &&)
Initialize the component and perform kernel-related operations. This may include dependency resolutio...
Definition component.h:54
static PassResult delay(Duration time) noexcept
Convenience function to return an operation delay request.
Definition component.h:77
static PassResult done() noexcept
Convenience function to return a finished operation result.
Definition component.h:80
Component() noexcept=default
virtual FuncResult unload(UnloadApi &&)
Unload any self-contained resources. This function is just called once.
Definition component.h:65
What can be done when initializing a component.
Definition component_api.h:458
What can be done when loading a component.
Definition component_api.h:447
What can be done when preloading a component.
Definition component_api.h:418
What can be done while a component is running.
Definition component_api.h:469
What can be done when unloading a component.
Definition component_api.h:557
#define SEN_COMPONENT_INFO_MAKER
Definition component.h:90
#define SEN_COMPONENT_MAKER
Definition component.h:89
impl::Ok< void > Ok() noexcept
If T is void, use the void specialization of Ok.
Definition result.h:437
@ time
Definition unit.h:34
Strong type for the unique identifier for a transport timer.
Definition native_object_impl.h:39
PassResult done()
Convenience helper for doing sen::Ok(sen::kernel::OpState {sen::kernel::OpFinished {}...
Definition component.h:25
constexpr auto * componentMakerFuncName
Definition component.h:95
Result< OpState, ExecError > PassResult
The result of operations that may be called multiple times.
Definition component_api.h:64
SEN_PRIVATE GitStatus getGitStatus() noexcept
SEN_PRIVATE const char * getBuildTime() noexcept
SEN_PRIVATE const char * getGitHash() noexcept
Result< void, ExecError > FuncResult
The result of operations that are called once.
Definition component_api.h:61
constexpr auto * componentInfoMakerFuncName
Definition component.h:96
constexpr bool getDebugEnabled() noexcept
Definition component.h:102
SEN_PRIVATE const char * getGitRef() noexcept
constexpr WordSize getWordSize() noexcept
Definition component.h:111