iceoryx_posh 2.0.3
roudi_app.hpp
1// Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved.
2// Copyright (c) 2020 - 2021 by Apex.AI Inc. All rights reserved.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16// SPDX-License-Identifier: Apache-2.0
17#ifndef IOX_POSH_ROUDI_ROUDI_APP_HPP
18#define IOX_POSH_ROUDI_ROUDI_APP_HPP
19
20#include "iceoryx_hoofs/log/logcommon.hpp"
21#include "iceoryx_hoofs/posix_wrapper/semaphore.hpp"
22#include "iceoryx_posh/iceoryx_posh_config.hpp"
23#include "iceoryx_posh/mepoo/mepoo_config.hpp"
24#include "iceoryx_posh/roudi/cmd_line_args.hpp"
25
26#include <cstdint>
27#include <cstdio>
28
29namespace iox
30{
31namespace roudi
32{
35{
36 public:
38 static void roudiSigHandler(int32_t signal) noexcept;
39
43 RouDiApp(const config::CmdLineArgs_t& cmdLineArgs, const RouDiConfig_t& config) noexcept;
44
45 virtual ~RouDiApp() noexcept {};
46
49 virtual uint8_t run() noexcept = 0;
50
51 protected:
53 void registerSigHandler() noexcept;
54
56 bool waitForSignal() noexcept;
57
58 iox::log::LogLevel m_logLevel{iox::log::LogLevel::kWarn};
59 roudi::MonitoringMode m_monitoringMode{roudi::MonitoringMode::ON};
60 bool m_run{true};
61 RouDiConfig_t m_config;
62
63 posix::Semaphore m_semaphore =
64 std::move(posix::Semaphore::create(posix::CreateUnnamedSingleProcessSemaphore, 0u)
65 .or_else([](posix::SemaphoreError&) {
66 errorHandler(Error::kROUDI_APP__FAILED_TO_CREATE_SEMAPHORE, nullptr, ErrorLevel::FATAL);
67 })
68 .value());
69 version::CompatibilityCheckLevel m_compatibilityCheckLevel{version::CompatibilityCheckLevel::PATCH};
70 units::Duration m_processKillDelay{roudi::PROCESS_DEFAULT_KILL_DELAY};
71
72 private:
73 bool checkAndOptimizeConfig(const RouDiConfig_t& config) noexcept;
74};
75
76} // namespace roudi
77} // namespace iox
78
79#endif // IOX_POSH_ROUDI_ROUDI_APP_HPP
base class for RouDi daemons
Definition: roudi_app.hpp:35
void registerSigHandler() noexcept
Tells the OS which signals shall be hooked.
RouDiApp(const config::CmdLineArgs_t &cmdLineArgs, const RouDiConfig_t &config) noexcept
C'tor with command line parser, which has already parsed the command line parameters.
bool waitForSignal() noexcept
waits for the next signal to RouDi daemon
virtual uint8_t run() noexcept=0
interface to start the execution of the RouDi daemon
static void roudiSigHandler(int32_t signal) noexcept
Method passed to the OS signal handler.
MonitoringMode
Controls process alive monitoring. Upon timeout, a monitored process is removed and its resources are...
Definition: iceoryx_posh_types.hpp:243
Definition: cmd_line_args.hpp:30