FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
arg_parser.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2024-present FERS Contributors (see AUTHORS.md).
4//
5// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
6
7/**
8 * @file arg_parser.h
9 * @brief Command-line argument parsing utilities for the application.
10 *
11 * This header file provides utilities for parsing command-line arguments,
12 * displaying help, version information, and configuring the application via a configuration structure.
13 */
14
15#pragma once
16
17#include <cstdint>
18#include <expected>
19#include <libfers/api.h>
20#include <optional>
21#include <string>
22#include <thread>
23
24namespace core
25{
26 /**
27 * @class Config
28 * @brief Configuration structure for the application.
29 */
30 struct Config
31 {
32 std::string script_file; ///< Path to the script file.
34 unsigned num_threads = std::thread::hardware_concurrency(); ///< Number of threads to use.
35 bool validate = true; ///< Validate the input .fersxml file by default.
36 std::optional<std::string> log_file; ///< Optional log file path for logging output.
37 bool generate_kml = false; ///< Optional flag to generate KML visualization output.
38 std::optional<std::string> kml_file; ///< Optional specific file path for KML output.
39 std::optional<std::string> output_dir; ///< Optional output directory for simulation results.
40 bool vita49_enabled = false; ///< True when VITA 49.2 UDP output is selected.
41 std::string vita49_host; ///< VITA 49.2 UDP destination host.
42 uint16_t vita49_port = 0; ///< VITA 49.2 UDP destination port.
43 std::optional<double> vita49_fullscale; ///< Fixed ADC full-scale for VITA int16 IQ output.
44 std::optional<uint64_t> vita49_epoch_unix_nanoseconds; ///< Optional deterministic VITA epoch.
45 std::optional<uint16_t> vita49_max_udp_payload; ///< Optional VITA UDP payload cap in bytes.
46 std::optional<uint32_t> vita49_queue_depth; ///< Optional VITA sender queue depth in packets.
47 };
48
49 /**
50 * @brief Displays the help message.
51 *
52 * @param programName The name of the program.
53 */
54 void showHelp(const char* programName) noexcept;
55
56 /**
57 * @brief Displays the version information.
58 */
59 void showVersion() noexcept;
60
61 /**
62 * @brief Parses command-line arguments.
63 *
64 * Processes the command-line arguments, validating them and extracting
65 * configurations like script file, logging level, and thread count.
66 *
67 * @param argc The argument count.
68 * @param argv The argument vector.
69 * @return std::expected<Config, std::string> Parsed configuration or an error message.
70 */
71 std::expected<Config, std::string> parseArguments(int argc, char* argv[]) noexcept;
72}
fers_log_level_t
Log levels for the FERS library.
Definition api.h:193
@ FERS_LOG_INFO
Informational logging.
Definition api.h:196
void showVersion() noexcept
Displays the version information.
std::expected< Config, std::string > parseArguments(const int argc, char *argv[]) noexcept
Parses command-line arguments.
void showHelp(const char *programName) noexcept
Displays the help message.
Configuration structure for the application.
Definition arg_parser.h:31
std::string script_file
Path to the script file.
Definition arg_parser.h:32
fers_log_level_t log_level
Logging level.
Definition arg_parser.h:33
std::optional< std::string > output_dir
Optional output directory for simulation results.
Definition arg_parser.h:39
bool validate
Validate the input .fersxml file by default.
Definition arg_parser.h:35
std::optional< uint64_t > vita49_epoch_unix_nanoseconds
Optional deterministic VITA epoch.
Definition arg_parser.h:44
std::optional< double > vita49_fullscale
Fixed ADC full-scale for VITA int16 IQ output.
Definition arg_parser.h:43
std::optional< uint32_t > vita49_queue_depth
Optional VITA sender queue depth in packets.
Definition arg_parser.h:46
std::optional< std::string > kml_file
Optional specific file path for KML output.
Definition arg_parser.h:38
bool generate_kml
Optional flag to generate KML visualization output.
Definition arg_parser.h:37
std::string vita49_host
VITA 49.2 UDP destination host.
Definition arg_parser.h:41
bool vita49_enabled
True when VITA 49.2 UDP output is selected.
Definition arg_parser.h:40
unsigned num_threads
Number of threads to use.
Definition arg_parser.h:34
std::optional< uint16_t > vita49_max_udp_payload
Optional VITA UDP payload cap in bytes.
Definition arg_parser.h:45
uint16_t vita49_port
VITA 49.2 UDP destination port.
Definition arg_parser.h:42
std::optional< std::string > log_file
Optional log file path for logging output.
Definition arg_parser.h:36