From bb682d258517c7ed9c773f184df113e83f26c4f2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 6 Jul 2021 05:29:57 +0300 Subject: cam: options: Support parent-child relationship between options Add support for creating a tree-based hieararchy of options instead of a flat list. This is useful to support options that need to be interpreted in the context of a particular occurrence of an array option. The usage text automatically documents the options in their corresponding context: Options: -c, --camera camera ... Specify which camera to operate on, by id or by index -h, --help Display this help message -I, --info Display information about stream(s) -l, --list List all cameras --list-controls List cameras controls -p, --list-properties List cameras properties -m, --monitor Monitor for hotplug and unplug camera events Options valid in the context of --camera: -C, --capture[=count] Capture until interrupted by user or until frames captured -F, --file[=filename] Write captured frames to disk If the file name ends with a '/', it sets the directory in which to write files, using the default file name. Otherwise it sets the full file path and name. The first '#' character in the file name is expanded to the camera index, stream name and frame sequence number. The default file name is 'frame-#.bin'. -s, --stream key=value[,key=value,...] ... Set configuration of a camera stream height=integer Height in pixels pixelformat=string Pixel format name role=string Role for the stream (viewfinder, video, still, raw) width=integer Width in pixels --strict-formats Do not allow requested stream format(s) to be adjusted --metadata Print the metadata for completed requests Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/cam/options.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/cam/options.h') diff --git a/src/cam/options.h b/src/cam/options.h index 5c51a94c..e894822c 100644 --- a/src/cam/options.h +++ b/src/cam/options.h @@ -10,6 +10,7 @@ #include #include #include +#include #include class KeyValueParser; @@ -91,9 +92,11 @@ public: bool addOption(int opt, OptionType type, const char *help, const char *name = nullptr, OptionArgument argument = ArgumentNone, - const char *argumentName = nullptr, bool array = false); + const char *argumentName = nullptr, bool array = false, + int parent = 0); bool addOption(int opt, KeyValueParser *parser, const char *help, - const char *name = nullptr, bool array = false); + const char *name = nullptr, bool array = false, + int parent = 0); Options parse(int argc, char *argv[]); void usage(); @@ -104,6 +107,10 @@ private: void usageOptions(const std::list