8#ifndef SEN_KERNEL_COMPONENT_H
9#define SEN_KERNEL_COMPONENT_H
87#define SEN_COMPONENT_MAKER senMakeKernelComponent
88#define SEN_COMPONENT_INFO_MAKER senMakeKernelComponentInfo
102#if defined(DEBUG) || defined(_DEBUG)
111 if constexpr (
sizeof(size_t) == 4U)
113 return WordSize::bits32;
117 return WordSize::bits64;
142 const auto* statusStr = GIT_STATUS;
144 const auto* statusStr =
"";
147 if (std::string(statusStr) ==
"clean")
149 return GitStatus::clean;
152 if (std::string(statusStr) ==
"dirty")
154 return GitStatus::modified;
157 return GitStatus::unknown;
168#define SEN_COMPONENT(component_name) \
170 extern "C" SEN_EXPORT sen::kernel::Component* SEN_COMPONENT_MAKER() \
172 return new component_name(); \
175 extern "C" SEN_EXPORT const sen::kernel::ComponentInfo* SEN_COMPONENT_INFO_MAKER() \
177 static sen::kernel::ComponentInfo info {}; \
178 info.name = SEN_TARGET_NAME; \
179 info.description = SEN_TARGET_DESCRIPTION; \
180 info.buildInfo.maintainer = SEN_TARGET_MAINTAINER; \
181 info.buildInfo.version = SEN_TARGET_VERSION; \
182 info.buildInfo.compiler = SEN_COMPILER_STRING; \
183 info.buildInfo.debugMode = sen::kernel::getDebugEnabled(); \
184 info.buildInfo.wordSize = sen::kernel::getWordSize(); \
185 info.buildInfo.buildTime = std::string(__DATE__) + " " + __TIME__; \
186 info.buildInfo.gitRef = sen::kernel::getGitRef(); \
187 info.buildInfo.gitHash = sen::kernel::getGitHash(); \
188 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:68
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:60
virtual FuncResult preload(PreloadApi &&)
Preload the component and initialize all self-contained resources. This function is just called once.
Definition component.h:44
virtual FuncResult load(LoadApi &&)
Load the component and initialize all self-contained resources. This function is just called once.
Definition component.h:48
virtual bool isRealTimeOnly() const noexcept
Return true here if your component is not designed to work with virtualized time.
Definition component.h:71
virtual PassResult init(InitApi &&)
Initialize the component and perform kernel-related operations. This may include dependency resolutio...
Definition component.h:53
static PassResult delay(Duration time) noexcept
Convenience function to return an operation delay request.
Definition component.h:75
static PassResult done() noexcept
Convenience function to return a finished operation result.
Definition component.h:78
Component() noexcept=default
virtual FuncResult unload(UnloadApi &&)
Unload any self-contained resources. This function is just called once.
Definition component.h:64
What can be done when initializing a component.
Definition component_api.h:213
What can be done when loading a component.
Definition component_api.h:202
What can be done when preloading a component.
Definition component_api.h:181
What can be done while a component is running.
Definition component_api.h:224
What can be done when unloading a component.
Definition component_api.h:291
#define SEN_COMPONENT_INFO_MAKER
Definition component.h:88
#define SEN_COMPONENT_MAKER
Definition component.h:87
impl::Ok< void > Ok() noexcept
If T is void, use the void specialization of Ok.
Definition result.h:434
@ 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 const char * getGitRef() noexcept
Definition component.h:121
constexpr auto * componentMakerFuncName
Definition component.h:93
Result< OpState, ExecError > PassResult
The result of operations that may be called multiple times.
Definition component_api.h:53
Result< void, ExecError > FuncResult
The result of operations that are called once.
Definition component_api.h:50
constexpr auto * componentInfoMakerFuncName
Definition component.h:94
constexpr bool getDebugEnabled() noexcept
Definition component.h:100
constexpr const char * getGitHash() noexcept
Definition component.h:130
constexpr WordSize getWordSize() noexcept
Definition component.h:109
GitStatus getGitStatus() noexcept
Definition component.h:139