Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <string> |
| 4 | |
| 5 | namespace ikvm |
| 6 | { |
| 7 | |
| 8 | /* |
| 9 | * @class Args |
| 10 | * @brief Command line argument parser and storage |
| 11 | */ |
| 12 | class Args |
| 13 | { |
| 14 | public: |
| 15 | /* |
| 16 | * @struct CommandLine |
| 17 | * @brief Stores the original command line arguments for later use |
| 18 | */ |
| 19 | struct CommandLine |
| 20 | { |
| 21 | /* |
| 22 | * @brief Constructs CommandLine object |
| 23 | * |
| 24 | * @param[in] c - Number of arguments |
| 25 | * @param[in] v - Array of arguments |
| 26 | */ |
| 27 | CommandLine(int c, char** v) : argc(c), argv(v) |
| 28 | { |
| 29 | } |
| 30 | ~CommandLine() = default; |
| 31 | CommandLine(const CommandLine&) = default; |
| 32 | CommandLine& operator=(const CommandLine&) = default; |
| 33 | CommandLine(CommandLine&&) = default; |
| 34 | CommandLine& operator=(CommandLine&&) = default; |
| 35 | |
| 36 | int argc; |
| 37 | char** argv; |
| 38 | }; |
| 39 | |
| 40 | /* |
| 41 | * @brief Constructs Args object |
| 42 | * |
| 43 | * @param[in] argc - The number of arguments in the command line call |
| 44 | * @param[in] argv - The array of arguments from the command line |
| 45 | */ |
| 46 | Args(int argc, char* argv[]); |
| 47 | ~Args() = default; |
| 48 | Args(const Args&) = default; |
| 49 | Args& operator=(const Args&) = default; |
| 50 | Args(Args&&) = default; |
| 51 | Args& operator=(Args&&) = default; |
| 52 | |
| 53 | /* |
| 54 | * @brief Get the original command line arguments |
| 55 | * |
| 56 | * @return Reference to the CommandLine structure storing the original |
| 57 | * command line arguments |
| 58 | */ |
| 59 | inline const CommandLine& getCommandLine() const |
| 60 | { |
| 61 | return commandLine; |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | * @brief Get the desired video frame rate |
| 66 | * |
| 67 | * @return Value of the desired frame rate in frames per second |
| 68 | */ |
| 69 | inline int getFrameRate() const |
| 70 | { |
| 71 | return frameRate; |
| 72 | } |
| 73 | |
| 74 | /* |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 75 | * @brief Get the path to the USB keyboard device |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 76 | * |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 77 | * @return Reference to the string storing the path to the keyboard device |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 78 | */ |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 79 | inline const std::string& getKeyboardPath() const |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 80 | { |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 81 | return keyboardPath; |
| 82 | } |
| 83 | |
| 84 | /* |
| 85 | * @brief Get the path to the USB mouse device |
| 86 | * |
| 87 | * @return Reference to the string storing the path to the mouse device |
| 88 | */ |
| 89 | inline const std::string& getPointerPath() const |
| 90 | { |
| 91 | return pointerPath; |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | /* |
| 95 | * @brief Get the path to the V4L2 video device |
| 96 | * |
| 97 | * @return Reference to the string storing the path to the video device |
| 98 | */ |
| 99 | inline const std::string& getVideoPath() const |
| 100 | { |
| 101 | return videoPath; |
| 102 | } |
| 103 | |
Paul Fertser | 2d2f3da | 2021-06-18 11:16:43 +0000 | [diff] [blame] | 104 | /* |
| 105 | * @brief Get the identical frames detection setting |
| 106 | * |
| 107 | * @return True if identical frames detection is enabled |
| 108 | */ |
| 109 | inline bool getCalcFrameCRC() const |
| 110 | { |
| 111 | return calcFrameCRC; |
| 112 | } |
| 113 | |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 114 | private: |
| 115 | /* @brief Prints the application usage to stderr */ |
| 116 | void printUsage(); |
| 117 | |
| 118 | /* |
| 119 | * @brief Desired frame rate (in frames per second) of the video |
| 120 | * stream |
| 121 | */ |
| 122 | int frameRate; |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 123 | /* @brief Path to the USB keyboard device */ |
| 124 | std::string keyboardPath; |
| 125 | /* @brief Path to the USB mouse device */ |
| 126 | std::string pointerPath; |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 127 | /* @brief Path to the V4L2 video device */ |
| 128 | std::string videoPath; |
Paul Fertser | 2d2f3da | 2021-06-18 11:16:43 +0000 | [diff] [blame] | 129 | /* @brief Identical frames detection */ |
| 130 | bool calcFrameCRC; |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 131 | /* @brief Original command line arguments passed to the application */ |
| 132 | CommandLine commandLine; |
| 133 | }; |
| 134 | |
| 135 | } // namespace ikvm |