Sen API
Sen Libraries
Loading...
Searching...
No Matches
kernel.h
Go to the documentation of this file.
1// === kernel.h ========================================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_KERNEL_KERNEL_H
9#define SEN_KERNEL_KERNEL_H
10
11// sen
13#include "sen/core/base/span.h"
15
16// kernel
18
19// generated code
20#include "stl/sen/kernel/basic_types.stl.h"
21#include "stl/sen/kernel/network_footprint.stl.h"
22
23// std
24#include <filesystem>
25#include <memory>
26#include <optional>
27
28namespace sen::kernel
29{
30
31// Forward declarations
32class TestKernel;
33
40
42class Kernel final
43{
44 SEN_NOCOPY_NOMOVE(Kernel)
45
46public:
47 explicit Kernel(KernelConfig config);
48 ~Kernel() noexcept;
49
50public:
54 [[nodiscard]] int run(KernelBlockMode blockMode = KernelBlockMode::doBlock);
55
58 void requestStop(int exitCode = 0);
59
64 [[nodiscard]] NetworkFootprint getNetworkFootprint(Span<const BusAddress> suppliedBusAddresses);
65
68 [[nodiscard]] const KernelConfig& getConfig() const noexcept;
69
72 [[nodiscard]] std::filesystem::path getConfigPath() const noexcept;
73
75 [[nodiscard]] static const BuildInfo& getBuildInfo() noexcept;
76
77private:
78 friend class KernelApi;
79 friend class PreloadApi;
80 friend class UnloadApi;
81 friend class impl::Runner;
82 friend class TestKernel;
83
84private:
85 std::unique_ptr<impl::KernelImpl> pimpl_;
86};
87
90namespace crash
91{
92
114bool arm(const std::filesystem::path& reportDirectory = {});
115
120[[nodiscard]] std::optional<int> runHandlerIfRequested(int argc, char* argv[]);
121
122} // namespace crash
123
124} // namespace sen::kernel
125
126#endif // SEN_KERNEL_KERNEL_H
Here we define a set of template meta-programming helpers to let the compiler take some decisions bas...
Contiguous view of elements of type T. Inspired by http://www.open-std.org/jtc1/sc22/wg21/docs/papers...
Definition span.h:34
Holds the kernel configuration information.
Definition kernel_config.h:33
static const BuildInfo & getBuildInfo() noexcept
Gets the kernel build information.
friend class KernelApi
Definition kernel.h:78
const KernelConfig & getConfig() const noexcept
Gets the configuration used to construct the kernel. This method is thread-safe.
Kernel(KernelConfig config)
int run(KernelBlockMode blockMode=KernelBlockMode::doBlock)
Fire up the execution of the kernel. In case the is already running, -1 is returned....
friend class PreloadApi
Definition kernel.h:79
friend class impl::Runner
Definition kernel.h:81
void requestStop(int exitCode=0)
Stops the execution and deallocates runtime resources. This method is thread-safe.
std::filesystem::path getConfigPath() const noexcept
Gets the path to the configuration file used to construct the kernel. This method is thread-safe.
friend class TestKernel
Definition kernel.h:82
NetworkFootprint getNetworkFootprint(Span< const BusAddress > suppliedBusAddresses)
Builds the process network footprint after preloading the configured components.
friend class UnloadApi
Definition kernel.h:80
Kernel class only meant for unit testing your packages or components. It starts in virtual time mode.
Definition test_kernel.h:27
Crash reporting, which belongs to the process rather than to any one kernel: a process has one crash ...
Definition kernel.h:91
std::optional< int > runHandlerIfRequested(int argc, char *argv[])
Give main() its own arguments here, before anything else, and leave with the value it returns when it...
bool arm(const std::filesystem::path &reportDirectory={})
Turns on crash reporting for this process: a terminate handler for an uncaught exception,...
Strong type for the unique identifier for a transport timer.
Definition native_object_impl.h:39
KernelBlockMode
How to deal with the thread that calls the Kernel::run() function.
Definition kernel.h:36
@ doNotBlock
Does not block the caller thread.
Definition kernel.h:37
@ doBlock
Blocks the caller thread.
Definition kernel.h:38
STL namespace.