[libcamera-devel,v2,5/6] libcamera: formats: Expose std::map::value_type

Message ID 20200608232844.10150-6-jacopo@jmondi.org
State Superseded
Delegated to: Jacopo Mondi
Headers show
Series
  • ImageFormats, you again
Related show

Commit Message

Jacopo Mondi June 8, 2020, 11:28 p.m. UTC
In order to prepare to replace usage of custom map in pipeline handlers,
expose the formats map value_type type definition, to allow pipeline
handlers to use STL functions to iterate the class.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 include/libcamera/internal/formats.h | 2 ++
 src/libcamera/formats.cpp            | 5 +++++
 2 files changed, 7 insertions(+)

Comments

Laurent Pinchart June 26, 2020, 1:38 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Jun 09, 2020 at 01:28:43AM +0200, Jacopo Mondi wrote:
> In order to prepare to replace usage of custom map in pipeline handlers,
> expose the formats map value_type type definition, to allow pipeline
> handlers to use STL functions to iterate the class.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

So we're already starting to extend the std::map API being exposed.
Didn't take long :-) Let's discuss that as part of 3/6. I would squash
3/6 and 5/6 together.

> ---
>  include/libcamera/internal/formats.h | 2 ++
>  src/libcamera/formats.cpp            | 5 +++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h
> index 914fdde27d0c..1361b55d63d2 100644
> --- a/include/libcamera/internal/formats.h
> +++ b/include/libcamera/internal/formats.h
> @@ -22,6 +22,8 @@ template<typename T>
>  class ImageFormats
>  {
>  public:
> +	using value_type = typename std::map<T, std::vector<SizeRange>>::value_type;
> +
>  	using iterator = typename std::map<T, std::vector<SizeRange>>::iterator;
>  	using const_iterator = typename std::map<T, std::vector<SizeRange>>::const_iterator;
>  
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index 9f46f82c9059..5037c5928669 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -34,6 +34,11 @@ LOG_DEFINE_CATEGORY(Formats)
>   * Sizes are stored as a list of SizeRange.
>   */
>  
> +/**
> + * \typedef ImageFormats::value_type
> + * \brief Value type of the entries in the formats map
> + */
> +
>  /**
>   * \typedef ImageFormats::iterator
>   * \brief Iterator for the formats map

Patch

diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h
index 914fdde27d0c..1361b55d63d2 100644
--- a/include/libcamera/internal/formats.h
+++ b/include/libcamera/internal/formats.h
@@ -22,6 +22,8 @@  template<typename T>
 class ImageFormats
 {
 public:
+	using value_type = typename std::map<T, std::vector<SizeRange>>::value_type;
+
 	using iterator = typename std::map<T, std::vector<SizeRange>>::iterator;
 	using const_iterator = typename std::map<T, std::vector<SizeRange>>::const_iterator;
 
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 9f46f82c9059..5037c5928669 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -34,6 +34,11 @@  LOG_DEFINE_CATEGORY(Formats)
  * Sizes are stored as a list of SizeRange.
  */
 
+/**
+ * \typedef ImageFormats::value_type
+ * \brief Value type of the entries in the formats map
+ */
+
 /**
  * \typedef ImageFormats::iterator
  * \brief Iterator for the formats map