iceoryx_doc  1.0.1
roudi_cmd_line_parser.hpp
1 // Copyright (c) 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_CMD_LINE_PARSER_HPP
18 #define IOX_POSH_ROUDI_ROUDI_CMD_LINE_PARSER_HPP
19 
20 #include "iceoryx_posh/iceoryx_posh_types.hpp"
21 #include "iceoryx_posh/roudi/cmd_line_args.hpp"
22 #include "iceoryx_posh/version/compatibility_check_level.hpp"
23 #include "iceoryx_utils/cxx/expected.hpp"
24 #include "iceoryx_utils/cxx/optional.hpp"
25 #include "iceoryx_utils/internal/units/duration.hpp"
26 #include "iceoryx_utils/log/logcommon.hpp"
27 
28 namespace iox
29 {
30 namespace config
31 {
32 enum class CmdLineParserResult
33 {
34  INVALID_STATE,
35  UNKNOWN_OPTION_USED,
36  INFO_OUTPUT_ONLY
37 };
38 
40 {
41  public:
42  enum class CmdLineArgumentParsingMode
43  {
44  ALL,
45  ONE
46  };
47 
48  CmdLineParser() noexcept = default;
49  virtual ~CmdLineParser() noexcept = default;
50  CmdLineParser& operator=(const CmdLineParser& other) = delete;
51  CmdLineParser(const CmdLineParser& other) = delete;
52  CmdLineParser& operator=(CmdLineParser&&) = delete;
53  CmdLineParser(CmdLineParser&& other) = delete;
54 
61  virtual cxx::expected<CmdLineArgs_t, CmdLineParserResult>
62  parse(int argc,
63  char* argv[],
64  const CmdLineArgumentParsingMode cmdLineParsingMode = CmdLineArgumentParsingMode::ALL) noexcept;
65 
66  protected:
67  bool m_run{true};
68  iox::log::LogLevel m_logLevel{iox::log::LogLevel::kWarn};
69  roudi::MonitoringMode m_monitoringMode{roudi::MonitoringMode::ON};
70  version::CompatibilityCheckLevel m_compatibilityCheckLevel{version::CompatibilityCheckLevel::PATCH};
71  cxx::optional<uint16_t> m_uniqueRouDiId;
72  units::Duration m_processKillDelay{roudi::PROCESS_DEFAULT_KILL_DELAY};
73 };
74 
75 } // namespace config
76 } // namespace iox
77 
78 #endif // IOX_POSH_ROUDI_ROUDI_CMD_LINE_PARSER_HPP
Definition: roudi_cmd_line_parser.hpp:40
virtual cxx::expected< CmdLineArgs_t, CmdLineParserResult > parse(int argc, char *argv[], const CmdLineArgumentParsingMode cmdLineParsingMode=CmdLineArgumentParsingMode::ALL) noexcept
process the passed command line arguments
MonitoringMode
Controls process alive monitoring. Upon timeout, a monitored process is removed and its resources are...
Definition: iceoryx_posh_types.hpp:221
Definition: service_description.hpp:29