When retrieving the value from a `ControlValue` usually one of two things happen: a small, trivially copyable object is returned by value; or a view into the internal buffer is provided. This is true for everything except strings, which are returned in `std::string`, incurring the overhead of string construction. To guarantee no potentially "expensive" copies, use `std::string_view` pointing to the internal buffer to return the value. This is similar to how other array-like types are returned with a `Span<>`. This is an API break, but its scope is limited to just `properties::Model`. Bug: https://bugs.libcamera.org/show_bug.cgi?id=256 Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* {{mode|capitalize}} ID list
|
|
*
|
|
* This file is auto-generated. Do not edit.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <map>
|
|
#include <stdint.h>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
#include <libcamera/controls.h>
|
|
|
|
namespace libcamera {
|
|
|
|
namespace {{mode}} {
|
|
|
|
extern const ControlIdMap {{mode}};
|
|
|
|
{%- for vendor, ctrls in controls -%}
|
|
|
|
{% if vendor != 'libcamera' %}
|
|
namespace {{vendor}} {
|
|
|
|
#define LIBCAMERA_HAS_{{vendor|upper}}_VENDOR_{{mode|upper}}
|
|
{%- endif %}
|
|
|
|
{% if ctrls %}
|
|
enum {
|
|
{%- for ctrl in ctrls %}
|
|
{{ctrl.name|snake_case|upper}} = {{ctrl.id}},
|
|
{%- endfor %}
|
|
};
|
|
{% endif %}
|
|
|
|
{% for ctrl in ctrls -%}
|
|
{% if ctrl.is_enum -%}
|
|
enum {{ctrl.name}}Enum {
|
|
{%- for enum in ctrl.enum_values %}
|
|
{{enum.name}} = {{enum.value}},
|
|
{%- endfor %}
|
|
};
|
|
extern const std::array<const ControlValue, {{ctrl.enum_values_count}}> {{ctrl.name}}Values;
|
|
extern const std::map<std::string, {{ctrl.type}}> {{ctrl.name}}NameValueMap;
|
|
{% endif -%}
|
|
extern const Control<{{ctrl.type}}> {{ctrl.name}};
|
|
#define LIBCAMERA_HAS_{{vendor|upper}}_VENDOR_{{mode|upper}}_{{ctrl.name|snake_case|upper}}
|
|
{% endfor -%}
|
|
|
|
{% if vendor != 'libcamera' %}
|
|
} /* namespace {{vendor}} */
|
|
{% endif -%}
|
|
|
|
{% endfor %}
|
|
} /* namespace {{mode}} */
|
|
|
|
} /* namespace libcamera */
|