1 #pragma once 2 3 #include <string> 4 5 namespace ikvm 6 { 7 /* 8 * @class Args 9 * @brief Command line argument parser and storage 10 */ 11 class Args 12 { 13 public: 14 /* 15 * @struct CommandLine 16 * @brief Stores the original command line arguments for later use 17 */ 18 struct CommandLine 19 { 20 /* 21 * @brief Constructs CommandLine object 22 * 23 * @param[in] c - Number of arguments 24 * @param[in] v - Array of arguments 25 */ CommandLineikvm::Args::CommandLine26 CommandLine(int c, char** v) : argc(c), argv(v) {} 27 ~CommandLine() = default; 28 CommandLine(const CommandLine&) = default; 29 CommandLine& operator=(const CommandLine&) = default; 30 CommandLine(CommandLine&&) = default; 31 CommandLine& operator=(CommandLine&&) = default; 32 33 int argc; 34 char** argv; 35 }; 36 37 /* 38 * @brief Constructs Args object 39 * 40 * @param[in] argc - The number of arguments in the command line call 41 * @param[in] argv - The array of arguments from the command line 42 */ 43 Args(int argc, char* argv[]); 44 ~Args() = default; 45 Args(const Args&) = default; 46 Args& operator=(const Args&) = default; 47 Args(Args&&) = default; 48 Args& operator=(Args&&) = default; 49 50 /* 51 * @brief Get the original command line arguments 52 * 53 * @return Reference to the CommandLine structure storing the original 54 * command line arguments 55 */ getCommandLine() const56 inline const CommandLine& getCommandLine() const 57 { 58 return commandLine; 59 } 60 61 /* 62 * @brief Get the desired video frame rate 63 * 64 * @return Value of the desired frame rate in frames per second 65 */ getFrameRate() const66 inline int getFrameRate() const 67 { 68 return frameRate; 69 } 70 71 /* 72 * @brief Get the video subsampling 73 * 74 * @return Value of the video subsampling 75 */ getSubsampling() const76 inline int getSubsampling() const 77 { 78 return subsampling; 79 } 80 81 /* 82 * @brief Get the path to the USB keyboard device 83 * 84 * @return Reference to the string storing the path to the keyboard device 85 */ getKeyboardPath() const86 inline const std::string& getKeyboardPath() const 87 { 88 return keyboardPath; 89 } 90 91 /* 92 * @brief Get the path to the USB mouse device 93 * 94 * @return Reference to the string storing the path to the mouse device 95 */ getPointerPath() const96 inline const std::string& getPointerPath() const 97 { 98 return pointerPath; 99 } 100 101 /* 102 * @brief Get the name of UDC 103 * 104 * @return Reference to the string storing the name of UDC 105 */ getUdcName() const106 inline const std::string& getUdcName() const 107 { 108 return udcName; 109 } 110 111 /* 112 * @brief Get the path to the V4L2 video device 113 * 114 * @return Reference to the string storing the path to the video device 115 */ getVideoPath() const116 inline const std::string& getVideoPath() const 117 { 118 return videoPath; 119 } 120 121 /* 122 * @brief Get the identical frames detection setting 123 * 124 * @return True if identical frames detection is enabled 125 */ getCalcFrameCRC() const126 inline bool getCalcFrameCRC() const 127 { 128 return calcFrameCRC; 129 } 130 131 private: 132 /* @brief Prints the application usage to stderr */ 133 void printUsage(); 134 135 /* 136 * @brief Desired frame rate (in frames per second) of the video 137 * stream 138 */ 139 int frameRate; 140 /* @brief Desired subsampling (0: 444, 1: 420) */ 141 int subsampling; 142 /* @brief Path to the USB keyboard device */ 143 std::string keyboardPath; 144 /* @brief Path to the USB mouse device */ 145 std::string pointerPath; 146 /* @brief Name of UDC */ 147 std::string udcName; 148 /* @brief Path to the V4L2 video device */ 149 std::string videoPath; 150 /* @brief Identical frames detection */ 151 bool calcFrameCRC; 152 /* @brief Original command line arguments passed to the application */ 153 CommandLine commandLine; 154 }; 155 156 } // namespace ikvm 157