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.cpp | 217 ++++++++++++++++++++++++++++++++++++++++++++-------- src/cam/options.h | 14 +++- 2 files changed, 199 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 379b68c3..59b26be4 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -79,6 +79,12 @@ * \var Option::isArray * \brief Whether the option can appear once or multiple times * + * \var Option::parent + * \brief The parent option + * + * \var Option::children + * \brief List of child options, storing all options whose parent is this option + * * \fn Option::hasShortOption() * \brief Tell if the option has a short option specifier (e.g. `-f`) * \return True if the option has a short option specifier, false otherwise @@ -96,6 +102,8 @@ struct Option { const char *help; KeyValueParser *keyValueParser; bool isArray; + Option *parent; + std::list